]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
tests: fix LBA format calculation
authorDennis Maisenbacher <dennis.maisenbacher@wdc.com>
Thu, 13 Feb 2025 08:23:46 +0000 (08:23 +0000)
committerDaniel Wagner <wagi@monom.org>
Fri, 14 Feb 2025 17:08:49 +0000 (18:08 +0100)
We assumed that the test drive is always formatted with lbaf 0 which
leads to miscalculation of the maximum available size on namespace
creation.
Now we query the LBA size according to the selected `self.flbas`.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
tests/nvme_create_max_ns_test.py
tests/nvme_test.py

index f4fa72c7bb279656c60314fec6eae53b02cde5bb..41e7a8d3c8411dcfe114bc76725ac06fd5371150 100644 (file)
@@ -50,8 +50,9 @@ class TestNVMeCreateMaxNS(TestNVMe):
         super().setUp()
         self.dps = 0
         self.flbas = 0
+        (ds, ms) = self.get_lba_format_size()
         self.nsze = int(self.get_ncap() /
-                        self.get_format() / self.get_max_ns())
+                        (ds + ms) / self.get_max_ns())
         # Make sure that we have enough capacity for each ns.
         # Creating a ns might allocate more bits (NVMCAP) than specified by
         # nsze and ncap.
index 2fea4ec016f49a2c008a5cd95c31277e9439e5e1..d306ddef3488ee0ed5dde3b986c39574887ac37b 100644 (file)
@@ -314,31 +314,6 @@ class TestNVMe(unittest.TestCase):
         """
         return int(self.get_id_ctrl_field_value("ocfs"), 16)
 
-    def get_format(self):
-        """ Wrapper for extracting format.
-            - Args:
-                - None
-            - Returns:
-                - maximum format of namespace.
-        """
-        # defaulting to 4K
-        nvm_format = 4096
-        nvm_format_cmd = f"{self.nvme_bin} id-ns {self.ctrl} " + \
-            f"--namespace-id={self.default_nsid}"
-        proc = subprocess.Popen(nvm_format_cmd,
-                                shell=True,
-                                stdout=subprocess.PIPE,
-                                encoding='utf-8')
-        err = proc.wait()
-        self.assertEqual(err, 0, "ERROR : reading nvm capacity failed")
-
-        # Not using json output here because parsing flbas makes this less
-        # readable as the format index is split into lower and upper bits
-        for line in proc.stdout:
-            if "in use" in line:
-                nvm_format = 2 ** int(line.split(":")[3].split()[0])
-        return int(nvm_format)
-
     def delete_all_ns(self):
         """ Wrapper for deleting all the namespaces.
             - Args: