| 1 | #include "drivers/nvme/tests/test_internal.h" |
|---|---|
| 2 | #include <block/bio.h> |
| 3 | #include <test/export.h> |
| 4 | |
| 5 | TEST_GROUP_DEFINE(nvme); |
| 6 | |
| 7 | TEST_DEFINE_UNIT(nvme, status_code_decode) { |
| 8 | /* Status 0 (with phase bit 0 or 1) -> BIO_STATUS_OK */ |
| 9 | TEST_ASSERT_EQ_S(TEST_CALL(nvme_to_bio_status)(0x0000), BIO_STATUS_OK); |
| 10 | TEST_ASSERT_EQ_S(TEST_CALL(nvme_to_bio_status)(0x0001), BIO_STATUS_OK); |
| 11 | |
| 12 | /* NVMe error mapping */ |
| 13 | TEST_ASSERT_EQ_S(TEST_CALL(nvme_to_bio_status)(0x80 << 1), |
| 14 | BIO_STATUS_INVAL_ARG); |
| 15 | TEST_ASSERT_EQ_S(TEST_CALL(nvme_to_bio_status)(0x81 << 1), |
| 16 | BIO_STATUS_INVAL_INTERNAL); |
| 17 | |
| 18 | /* Unhandled errors must NOT be swallowed as OK */ |
| 19 | TEST_ASSERT_EQ_S(TEST_CALL(nvme_to_bio_status)(0x02 << 1), |
| 20 | BIO_STATUS_UNKNOWN_ERR); |
| 21 | TEST_ASSERT_EQ_S(TEST_CALL(nvme_to_bio_status)(0x280 << 1), |
| 22 | BIO_STATUS_UNKNOWN_ERR); |
| 23 | |
| 24 | return TEST_SUCCESS; |
| 25 | } |
| 26 |