]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
tests: Fix nvme_get_lba_status_test and nvme_lba_status_log_test
authorDennis Maisenbacher <dennis.maisenbacher@wdc.com>
Thu, 17 Oct 2024 14:18:45 +0000 (14:18 +0000)
committerDaniel Wagner <wagi@monom.org>
Tue, 29 Oct 2024 06:37:41 +0000 (07:37 +0100)
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 <dennis.maisenbacher@wdc.com>
tests/nvme_get_lba_status_test.py
tests/nvme_lba_status_log_test.py
tests/nvme_test.py

index 539c493763a3bc8e2cd9a00cb1e968719ebb057c..d9e543c5a4823ff2b372cfb8c06be8172f6ed932 100644 (file)
@@ -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) + \
index c91d1e5690bf26114521ba3252e33f87c731dac0..a50e211cec511d4dc1ba7633712a60e2e2210951 100644 (file)
@@ -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):
index ba62add24ba3935f2cedb5040819a488bd3efe4a..65a43cfd3cbb8ff9ee152724e31fbde98a4a0b99 100644 (file)
@@ -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: