From: Dennis Maisenbacher Date: Thu, 17 Oct 2024 14:18:45 +0000 (+0000) Subject: tests: Fix nvme_get_lba_status_test and nvme_lba_status_log_test X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=67bd20efb0198b8cdc97240e285455cbc5d5f0ef;p=users%2Fsagi%2Fnvme-cli.git tests: Fix nvme_get_lba_status_test and nvme_lba_status_log_test Look up if the drive supports the `Get LBA Status` optional admin command before executing a `nvme get-lba-status` or `nvme lba-status-log` command. Furthermore use the correct action value on `get-lba-status`. Signed-off-by: Dennis Maisenbacher --- diff --git a/tests/nvme_get_lba_status_test.py b/tests/nvme_get_lba_status_test.py index 539c4937..d9e543c5 100644 --- a/tests/nvme_get_lba_status_test.py +++ b/tests/nvme_get_lba_status_test.py @@ -26,11 +26,12 @@ class TestNVMeGetLbaStatusCmd(TestNVMe): def setUp(self): """ Pre Section for TestNVMeGetLbaStatusCmd. """ super().setUp() + if not self.get_lba_status_supported(): + self.skipTest("because: Optional Admin Command 'Get LBA Status' (OACS->GLSS) not supported") self.start_lba = 0 self.block_count = 0 - self.namespace = 1 self.max_dw = 1 - self.action = 11 + self.action = 0x11 self.range_len = 1 self.setup_log_dir(self.__class__.__name__) @@ -51,7 +52,7 @@ class TestNVMeGetLbaStatusCmd(TestNVMe): """ err = 0 get_lba_status_cmd = "nvme get-lba-status " + self.ctrl + \ - " --namespace-id=" + str(self.namespace) + \ + " --namespace-id=" + str(self.ns1) + \ " --start-lba=" + str(self.start_lba) + \ " --max-dw=" + str(self.max_dw) + \ " --action=" + str(self.action) + \ diff --git a/tests/nvme_lba_status_log_test.py b/tests/nvme_lba_status_log_test.py index c91d1e56..a50e211c 100644 --- a/tests/nvme_lba_status_log_test.py +++ b/tests/nvme_lba_status_log_test.py @@ -26,6 +26,8 @@ class TestNVMeLbaStatLogCmd(TestNVMe): def setUp(self): """ Pre Section for TestNVMeLbaStatLogCmd. """ super().setUp() + if not self.get_lba_status_supported(): + self.skipTest("because: Optional Admin Command 'Get LBA Status' (OACS->GLSS) not supported") self.setup_log_dir(self.__class__.__name__) def tearDown(self): diff --git a/tests/nvme_test.py b/tests/nvme_test.py index ba62add2..65a43cfd 100644 --- a/tests/nvme_test.py +++ b/tests/nvme_test.py @@ -208,6 +208,15 @@ class TestNVMe(unittest.TestCase): print(max_ns) return int(max_ns) + def get_lba_status_supported(self): + """ Check if 'Get LBA Status' command is supported by the device + - Args: + - None + - Returns: + - True if 'Get LBA Status' command is supported, otherwise False + """ + return int(self.get_id_ctrl_field_value("oacs"), 16) & (1 << 9) + def get_lba_format_size(self): """ Wrapper for extracting lba format size of the given flbas - Args: