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