From 4116a5a7a7d5a03e572c74f06880b32df5a2e13f Mon Sep 17 00:00:00 2001 From: Dennis Maisenbacher Date: Thu, 13 Feb 2025 08:23:46 +0000 Subject: [PATCH] tests: fix LBA format calculation 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 --- tests/nvme_create_max_ns_test.py | 3 ++- tests/nvme_test.py | 25 ------------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/tests/nvme_create_max_ns_test.py b/tests/nvme_create_max_ns_test.py index f4fa72c7..41e7a8d3 100644 --- a/tests/nvme_create_max_ns_test.py +++ b/tests/nvme_create_max_ns_test.py @@ -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. diff --git a/tests/nvme_test.py b/tests/nvme_test.py index 2fea4ec0..d306ddef 100644 --- a/tests/nvme_test.py +++ b/tests/nvme_test.py @@ -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: -- 2.50.1