]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
tests: Introduce configurable nvme binary path
authorDennis Maisenbacher <dennis.maisenbacher@wdc.com>
Wed, 6 Nov 2024 15:31:32 +0000 (15:31 +0000)
committerDaniel Wagner <wagi@monom.org>
Tue, 10 Dec 2024 16:09:11 +0000 (17:09 +0100)
Introducing the `nvme_bin` config to point to a different nvme-cli
binary.

With this change all nvme cmd strings are reworked for uniformity.
This includes using f-strings and expanding short options into long
options.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
16 files changed:
tests/nvme_compare_test.py
tests/nvme_copy_test.py
tests/nvme_ctrl_reset_test.py
tests/nvme_dsm_test.py
tests/nvme_flush_test.py
tests/nvme_format_test.py
tests/nvme_fw_log_test.py
tests/nvme_get_features_test.py
tests/nvme_get_lba_status_test.py
tests/nvme_id_ns_test.py
tests/nvme_lba_status_log_test.py
tests/nvme_test.py
tests/nvme_test_io.py
tests/nvme_verify_test.py
tests/nvme_writeuncor_test.py
tests/nvme_writezeros_test.py

index a34df68e30021e818c4fe1f7362006c02abf9b38..e6b2b75ab9904805fbb14f7a2a75ac54046231d5 100644 (file)
@@ -78,10 +78,10 @@ class TestNVMeCompareCmd(TestNVMeIO):
            - Returns:
                - return code of the nvme compare command.
         """
-        compare_cmd = "nvme compare " + self.ns1 + " --start-block=" + \
-                      str(self.start_block) + " --block-count=" + \
-                      str(self.block_count) + " --data-size=" + \
-                      str(self.data_size) + " --data=" + cmp_file
+        compare_cmd = f"{self.nvme_bin} compare {self.ns1} " + \
+            f"--start-block={str(self.start_block)} " + \
+            f"--block-count={str(self.block_count)} " + \
+            f"--data-size={str(self.data_size)} --data={cmp_file}"
         return self.exec_cmd(compare_cmd)
 
     def test_nvme_compare(self):
index 5d16b00ddab005e4ed7302a7db1a567f033143c5..085c765053c0e9923c45dc9c82404292861e00dd 100644 (file)
@@ -40,9 +40,15 @@ class TestNVMeCopy(TestNVMe):
         cross_namespace_copy = self.ocfs & 0xc
         if cross_namespace_copy:
             # get host behavior support data
-            get_features_cmd = ["nvme", "get-feature", self.ctrl, "--feature-id=0x16", "--data-len=512", "-b"]
-            print("Running command:", " ".join(get_features_cmd))
-            self.host_behavior_data = subprocess.check_output(get_features_cmd)
+            get_features_cmd = f"{self.nvme_bin} get-feature {self.ctrl} " + \
+                "--feature-id=0x16 --data-len=512 --raw-binary"
+            proc = subprocess.Popen(get_features_cmd,
+                                    shell=True,
+                                    stdout=subprocess.PIPE,
+                                    encoding='utf-8')
+            err = proc.wait()
+            self.assertEqual(err, 0, "ERROR : nvme get-feature failed")
+            self.host_behavior_data = proc.stdout.read()
             # enable cross-namespace copy formats
             if self.host_behavior_data[4] & cross_namespace_copy:
                 # skip if already enabled
@@ -50,17 +56,24 @@ class TestNVMeCopy(TestNVMe):
                 self.host_behavior_data = None
             else:
                 data = self.host_behavior_data[:4] + cross_namespace_copy.to_bytes(2, 'little') + self.host_behavior_data[6:]
-                set_features_cmd = ["nvme", "set-feature", self.ctrl, "--feature-id=0x16", "--data-len=512"]
-                print("Running command:", " ".join(set_features_cmd))
+                set_features_cmd = f"{self.nvme_bin} set-feature " + \
+                    f"{self.ctrl} --feature-id=0x16 --data-len=512"
                 proc = subprocess.Popen(set_features_cmd,
+                                        shell=True,
                                         stdout=subprocess.PIPE,
-                                        stdin=subprocess.PIPE)
+                                        stdin=subprocess.PIPE,
+                                        encoding='utf-8')
                 proc.communicate(input=data)
                 self.assertEqual(proc.returncode, 0, "Failed to enable cross-namespace copy formats")
-        get_ns_id_cmd = ["nvme", "get-ns-id", self.ns1]
-        print("Running command:", " ".join(get_ns_id_cmd))
-        output = subprocess.check_output(get_ns_id_cmd)
-        self.ns1_nsid = int(output.decode().strip().split(':')[-1])
+        get_ns_id_cmd = f"{self.nvme_bin} get-ns-id {self.ns1}"
+        proc = subprocess.Popen(get_ns_id_cmd,
+                                shell=True,
+                                stdout=subprocess.PIPE,
+                                encoding='utf-8')
+        err = proc.wait()
+        self.assertEqual(err, 0, "ERROR : nvme get-ns-id failed")
+        output = proc.stdout.read()
+        self.ns1_nsid = int(output.strip().split(':')[-1])
         self.setup_log_dir(self.__class__.__name__)
 
     def tearDown(self):
@@ -68,11 +81,13 @@ class TestNVMeCopy(TestNVMe):
         print("Tearing down test...")
         if self.host_behavior_data:
             # restore saved host behavior support data
-            set_features_cmd = ["nvme", "set-feature", self.ctrl, "--feature-id=0x16", "--data-len=512"]
-            print("Running command:", " ".join(set_features_cmd))
+            set_features_cmd = f"{self.nvme_bin} set-feature {self.ctrl} " + \
+                "--feature-id=0x16 --data-len=512"
             proc = subprocess.Popen(set_features_cmd,
+                                    shell=True,
                                     stdout=subprocess.PIPE,
-                                    stdin=subprocess.PIPE)
+                                    stdin=subprocess.PIPE,
+                                    encoding='utf-8')
             proc.communicate(input=self.host_behavior_data)
         super().tearDown()
 
@@ -94,7 +109,9 @@ class TestNVMeCopy(TestNVMe):
             print(f"Skip copy because descriptor format {desc_format} is not supported")
             return
         # build copy command
-        copy_cmd = f"nvme copy {self.ns1} --format={desc_format} --sdlba={sdlba} --blocks={blocks} --slbs={slbs}"
+        copy_cmd = f"{self.nvme_bin} copy {self.ns1} " + \
+            f"--format={desc_format} --sdlba={sdlba} --blocks={blocks} " + \
+            f"--slbs={slbs}"
         if "snsids" in kwargs:
             copy_cmd += f" --snsids={kwargs['snsids']}"
         if "sopts" in kwargs:
index e2c8a00636e2b065971fb35c986dbc951a5f0c7c..f32042e8a8c8882502b8a93ad2896702e4d24e85 100644 (file)
@@ -40,7 +40,7 @@ class TestNVMeCtrlReset(TestNVMe):
             - Returns:
                 - return code for nvme controller reset.
         """
-        ctrl_reset_cmd = "nvme reset " + self.ctrl
+        ctrl_reset_cmd = f"{self.nvme_bin} reset {self.ctrl}"
         return self.exec_cmd(ctrl_reset_cmd)
 
     def test_ctrl_reset(self):
index d92bf58e590ae221c1591f2e0b30ea4db095f963..4ad3e05ed52ba29793315af3e0b7968a528eaea7 100644 (file)
@@ -45,10 +45,9 @@ class TestNVMeDsm(TestNVMe):
             - Returns:
                 - return code for nvme dsm command.
         """
-        dsm_cmd = "nvme dsm " + self.ctrl + \
-                  " --namespace-id=" + str(self.namespace) + \
-                  " --blocks=" + str(self.range) + \
-                  " --slbs=" + str(self.start_block)
+        dsm_cmd = f"{self.nvme_bin} dsm {self.ctrl} " + \
+            f"--namespace-id={str(self.namespace)} " + \
+            f"--blocks={str(self.range)} --slbs={str(self.start_block)}"
         return self.exec_cmd(dsm_cmd)
 
     def test_dsm(self):
index e4f127dac1e1b4f324c8f9034c78cc6996205825..4c9e2b9e2f42efd6dae556cf5b23d866d8053f69 100644 (file)
@@ -53,7 +53,8 @@ class TestNVMeFlushCmd(TestNVMe):
            - Returns:
                - None
         """
-        flush_cmd = "nvme flush " + self.ctrl + " -n " + str(self.default_nsid)
+        flush_cmd = f"{self.nvme_bin} flush {self.ctrl} " + \
+            f"--namespace-id={str(self.default_nsid)}"
         print(flush_cmd)
         return self.exec_cmd(flush_cmd)
 
index 12bc128f9aa8e3ed91304d558743e972812957e3..1c8891373278588b2dd90cfae34fbf3f0856409d 100644 (file)
@@ -106,23 +106,24 @@ class TestNVMeFormatCmd(TestNVMe):
                                                      self.dps), 0)
         self.assertEqual(self.attach_ns(self.ctrl_id, self.default_nsid), 0)
         # read lbaf information
-        id_ns = "nvme id-ns " + self.ctrl + \
-                " -n1 | grep ^lbaf | awk '{print $2}' | tr -s \"\\n\" \" \""
+        id_ns = f"{self.nvme_bin} id-ns {self.ctrl} " + \
+            f"--namespace-id={self.default_nsid} " + \
+            "| grep ^lbaf | awk '{print $2}' | tr -s \"\\n\" \" \""
         proc = subprocess.Popen(id_ns, shell=True, stdout=subprocess.PIPE,
                                 encoding='utf-8')
         self.lba_format_list = proc.stdout.read().strip().split(" ")
         if proc.wait() == 0:
             # read lbads information
-            id_ns = "nvme id-ns " + self.ctrl + \
-                    " -n1 | grep ^lbaf | awk '{print $5}'" + \
-                    " | cut -f 2 -d ':' | tr -s \"\\n\" \" \""
+            id_ns = f"{self.nvme_bin} id-ns {self.ctrl} " + \
+                f"--namespace-id={self.default_nsid} " + \
+                "| grep ^lbaf | awk '{print $5}' | cut -f 2 -d ':' | tr -s \"\\n\" \" \""
             proc = subprocess.Popen(id_ns, shell=True, stdout=subprocess.PIPE,
                                     encoding='utf-8')
             self.lbads_list = proc.stdout.read().strip().split(" ")
             # read metadata information
-            id_ns = "nvme id-ns " + self.ctrl + \
-                    " -n1 | grep ^lbaf | awk '{print $4}'" + \
-                    " | cut -f 2 -d ':' | tr -s \"\\n\" \" \""
+            id_ns = f"{self.nvme_bin} id-ns {self.ctrl} " + \
+                f"--namespace-id={self.default_nsid} " + \
+                "| grep ^lbaf | awk '{print $4}' | cut -f 2 -d ':' | tr -s \"\\n\" \" \""
             proc = subprocess.Popen(id_ns, shell=True, stdout=subprocess.PIPE,
                                     encoding='utf-8')
             self.ms_list = proc.stdout.read().strip().split(" ")
index b67067170c0d9fa82221a7fcb17e2c4997411409..11d79cddb39b4ab371f7c1b5e3231306319dd73a 100644 (file)
@@ -58,7 +58,7 @@ class TestNVMeFwLogCmd(TestNVMe):
                 - 0 on success, error code on failure.
         """
         err = 0
-        fw_log_cmd = "nvme fw-log " + self.ctrl
+        fw_log_cmd = f"{self.nvme_bin} fw-log {self.ctrl}"
         proc = subprocess.Popen(fw_log_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
index fc3e5bfeb1f24e7be2b2e62daf1b6c1640cb97eb..6edf332444570c4c79264b9280d1e11bf327c134 100644 (file)
@@ -81,9 +81,9 @@ class TestNVMeGetMandatoryFeatures(TestNVMe):
         """
         if str(feature_id) == "0x09":
             for vector in range(self.vector_list_len):
-                get_feat_cmd = "nvme get-feature " + self.ctrl + \
-                               " --feature-id=" + str(feature_id) + \
-                               " --cdw11=" + str(vector) + " -H"
+                get_feat_cmd = f"{self.nvme_bin} get-feature {self.ctrl} " + \
+                    f"--feature-id={str(feature_id)} " + \
+                    f"--cdw11={str(vector)} --human-readable"
                 proc = subprocess.Popen(get_feat_cmd,
                                         shell=True,
                                         stdout=subprocess.PIPE,
@@ -92,8 +92,8 @@ class TestNVMeGetMandatoryFeatures(TestNVMe):
                 print(feature_output)
                 self.assertEqual(proc.wait(), 0)
         else:
-            get_feat_cmd = "nvme get-feature " + self.ctrl + \
-                           " --feature-id=" + str(feature_id) + " -H"
+            get_feat_cmd = f"{self.nvme_bin} get-feature {self.ctrl} " + \
+                f"--feature-id={str(feature_id)} --human-readable"
             if str(feature_id) == "0x05":
                 get_feat_cmd += f" --namespace-id={self.default_nsid}"
             proc = subprocess.Popen(get_feat_cmd,
index d9e543c5a4823ff2b372cfb8c06be8172f6ed932..7577f6d089890c6af0b4ccd9e5e5043d97bdcf0f 100644 (file)
@@ -51,12 +51,12 @@ class TestNVMeGetLbaStatusCmd(TestNVMe):
                 - 0 on success, error code on failure.
         """
         err = 0
-        get_lba_status_cmd = "nvme get-lba-status " + self.ctrl + \
-                             " --namespace-id=" + str(self.ns1) + \
-                             " --start-lba=" + str(self.start_lba) + \
-                             " --max-dw=" + str(self.max_dw) + \
-                             " --action=" + str(self.action) + \
-                             " --range-len=" + str(self.range_len)
+        get_lba_status_cmd = f"{self.nvme_bin} get-lba-status {self.ctrl} " + \
+            f"--namespace-id={str(self.ns1)} " + \
+            f"--start-lba={str(self.start_lba)} " + \
+            f"--max-dw={str(self.max_dw)} " + \
+            f"--action={str(self.action)} " + \
+            f"--range-len={str(self.range_len)}"
         proc = subprocess.Popen(get_lba_status_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
index 66e2f93adc719fd70e88161f720ede36eb100114..48ad92474a31d56fc907ab71232b21a87f95824b 100644 (file)
@@ -61,7 +61,8 @@ class TestNVMeIdentifyNamespace(TestNVMe):
                 - 0 on success, error code on failure.
         """
         err = 0
-        id_ns_cmd = "nvme id-ns " + self.ctrl + "n" + str(nsid)
+        id_ns_cmd = f"{self.nvme_bin} id-ns {self.ctrl} " + \
+            f"--namespace-id={str(nsid)}"
         proc = subprocess.Popen(id_ns_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
index a50e211cec511d4dc1ba7633712a60e2e2210951..8eca23bd0b078db404eb23794369822ed0ed8be3 100644 (file)
@@ -46,7 +46,7 @@ class TestNVMeLbaStatLogCmd(TestNVMe):
                 - 0 on success, error code on failure.
         """
         err = 0
-        lba_stat_log_cmd = "nvme lba-status-log " + self.ctrl
+        lba_stat_log_cmd = f"{self.nvme_bin} lba-status-log {self.ctrl}"
         proc = subprocess.Popen(lba_stat_log_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
index a13a9939f03c44e83f714708472f871256e3ca94..7c9101643af9d8419206408f47af68a2fa0084ef 100644 (file)
@@ -58,6 +58,7 @@ class TestNVMe(unittest.TestCase):
         self.ctrl = "XXX"
         self.ns1 = "XXX"
         self.test_log_dir = "XXX"
+        self.nvme_bin = "nvme"
         self.do_validate_pci_device = True
         self.default_nsid = 0x1
         self.config_file = 'tests/config.json'
@@ -119,7 +120,10 @@ class TestNVMe(unittest.TestCase):
             self.ctrl = config['controller']
             self.ns1 = config['ns1']
             self.log_dir = config['log_dir']
-            self.do_validate_pci_device = config.get('do_validate_pci_device', self.do_validate_pci_device)
+            self.nvme_bin = config.get('nvme_bin', self.nvme_bin)
+            print(f"\nUsing nvme binary '{self.nvme_bin}'")
+            self.do_validate_pci_device = config.get(
+                'do_validate_pci_device', self.do_validate_pci_device)
             self.clear_log_dir = False
 
             if self.clear_log_dir is True:
@@ -154,7 +158,7 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - None
         """
-        nvme_reset_cmd = "nvme reset " + self.ctrl
+        nvme_reset_cmd = f"{self.nvme_bin} reset {self.ctrl}"
         err = subprocess.call(nvme_reset_cmd,
                               shell=True,
                               stdout=subprocess.PIPE,
@@ -177,7 +181,8 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - controller id.
         """
-        get_ctrl_id = f"nvme list-ctrl {self.ctrl} --output-format=json"
+        get_ctrl_id = f"{self.nvme_bin} list-ctrl {self.ctrl} " + \
+            "--output-format=json"
         proc = subprocess.Popen(get_ctrl_id,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -197,7 +202,7 @@ class TestNVMe(unittest.TestCase):
                 - List of the namespaces.
         """
         ns_list = []
-        ns_list_cmd = "nvme list-ns " + self.ctrl
+        ns_list_cmd = f"{self.nvme_bin} list-ns {self.ctrl}"
         proc = subprocess.Popen(ns_list_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -217,7 +222,7 @@ class TestNVMe(unittest.TestCase):
         """
         pattern = re.compile("^nn[ ]+: [0-9]", re.IGNORECASE)
         max_ns = -1
-        max_ns_cmd = "nvme id-ctrl " + self.ctrl
+        max_ns_cmd = f"{self.nvme_bin} id-ctrl {self.ctrl}"
         proc = subprocess.Popen(max_ns_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -248,7 +253,8 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - lba format size as a tuple of (data_size, metadata_size) in bytes.
         """
-        nvme_id_ns_cmd = f"nvme id-ns {self.ns1} --output-format=json"
+        nvme_id_ns_cmd = f"{self.nvme_bin} id-ns {self.ns1} " + \
+            "--output-format=json"
         proc = subprocess.Popen(nvme_id_ns_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -278,7 +284,7 @@ class TestNVMe(unittest.TestCase):
         """
         pattern = re.compile("^tnvmcap[ ]+: [0-9]", re.IGNORECASE)
         ncap = -1
-        ncap_cmd = "nvme id-ctrl " + self.ctrl
+        ncap_cmd = f"{self.nvme_bin} id-ctrl {self.ctrl}"
         proc = subprocess.Popen(ncap_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -300,7 +306,8 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - Filed value of the given field
         """
-        id_ctrl_cmd = f"nvme id-ctrl {self.ctrl} --output-format=json"
+        id_ctrl_cmd = f"{self.nvme_bin} id-ctrl {self.ctrl} " + \
+            "--output-format=json"
         proc = subprocess.Popen(id_ctrl_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -330,7 +337,8 @@ class TestNVMe(unittest.TestCase):
         """
         # defaulting to 4K
         nvm_format = 4096
-        nvm_format_cmd = "nvme id-ns " + self.ctrl + " -n1"
+        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,
@@ -351,9 +359,10 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - None
         """
-        delete_ns_cmd = "nvme delete-ns " + self.ctrl + " -n 0xFFFFFFFF"
+        delete_ns_cmd = f"{self.nvme_bin} delete-ns {self.ctrl} " + \
+            "--namespace-id=0xFFFFFFFF"
         self.assertEqual(self.exec_cmd(delete_ns_cmd), 0)
-        list_ns_cmd = "nvme list-ns " + self.ctrl + " --all | wc -l"
+        list_ns_cmd = f"{self.nvme_bin} list-ns {self.ctrl} --all | wc -l"
         proc = subprocess.Popen(list_ns_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -371,9 +380,9 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - return code of the nvme create namespace command.
         """
-        create_ns_cmd = "nvme create-ns " + self.ctrl + " --nsze=" + \
-                        str(nsze) + " --ncap=" + str(ncap) + \
-                        " --flbas=" + str(flbas) + " --dps=" + str(dps)
+        create_ns_cmd = f"{self.nvme_bin} create-ns {self.ctrl} " + \
+            f"--nsze={str(nsze)} --ncap={str(ncap)} --flbas={str(flbas)} " + \
+            f"--dps={str(dps)}"
         return self.exec_cmd(create_ns_cmd)
 
     def create_and_validate_ns(self, nsid, nsze, ncap, flbas, dps):
@@ -390,7 +399,8 @@ class TestNVMe(unittest.TestCase):
         err = self.create_ns(nsze, ncap, flbas, dps)
         if err == 0:
             time.sleep(2)
-            id_ns_cmd = "nvme id-ns " + self.ctrl + " -n " + str(nsid)
+            id_ns_cmd = f"{self.nvme_bin} id-ns {self.ctrl} " + \
+                f"--namespace-id={str(nsid)}"
             err = subprocess.call(id_ns_cmd,
                                   shell=True,
                                   stdout=subprocess.PIPE,
@@ -405,9 +415,8 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - 0 on success, error code on failure.
         """
-        attach_ns_cmd = "nvme attach-ns " + self.ctrl + \
-                        " --namespace-id=" + str(ns_id) + \
-                        " --controllers=" + ctrl_id
+        attach_ns_cmd = f"{self.nvme_bin} attach-ns {self.ctrl} " + \
+            f"--namespace-id={str(ns_id)} --controllers={ctrl_id}"
         err = subprocess.call(attach_ns_cmd,
                               shell=True,
                               stdout=subprocess.PIPE,
@@ -429,9 +438,8 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - 0 on success, error code on failure.
         """
-        detach_ns_cmd = "nvme detach-ns " + self.ctrl + \
-                        " --namespace-id=" + str(nsid) + \
-                        " --controllers=" + ctrl_id
+        detach_ns_cmd = f"{self.nvme_bin} detach-ns {self.ctrl} " + \
+            f"--namespace-id={str(nsid)} --controllers={ctrl_id}"
         return subprocess.call(detach_ns_cmd,
                                shell=True,
                                stdout=subprocess.PIPE,
@@ -445,7 +453,8 @@ class TestNVMe(unittest.TestCase):
                 - 0 on success, 1 on failure.
         """
         # delete the namespace
-        delete_ns_cmd = "nvme delete-ns " + self.ctrl + " -n " + str(nsid)
+        delete_ns_cmd = f"{self.nvme_bin} delete-ns {self.ctrl} " + \
+            f"--namespace-id={str(nsid)}"
         err = subprocess.call(delete_ns_cmd,
                               shell=True,
                               stdout=subprocess.PIPE,
@@ -460,7 +469,8 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - 0 on success, error code on failure.
         """
-        smart_log_cmd = "nvme smart-log " + self.ctrl + " -n " + str(nsid)
+        smart_log_cmd = f"{self.nvme_bin} smart-log {self.ctrl} " + \
+            f"--namespace-id={str(nsid)}"
         print(smart_log_cmd)
         proc = subprocess.Popen(smart_log_cmd,
                                 shell=True,
@@ -480,9 +490,10 @@ class TestNVMe(unittest.TestCase):
               - 0 on success, error code on failure.
         """
         if not vendor:
-            id_ctrl_cmd = "nvme id-ctrl " + self.ctrl
+            id_ctrl_cmd = f"{self.nvme_bin} id-ctrl {self.ctrl}"
         else:
-            id_ctrl_cmd = "nvme id-ctrl --vendor-specific " + self.ctrl
+            id_ctrl_cmd = f"{self.nvme_bin} id-ctrl " +\
+                f"--vendor-specific {self.ctrl}"
         print(id_ctrl_cmd)
         proc = subprocess.Popen(id_ctrl_cmd,
                                 shell=True,
@@ -500,7 +511,7 @@ class TestNVMe(unittest.TestCase):
                 - 0 on success, error code on failure.
         """
         pattern = re.compile(r"^ Entry\[[ ]*[0-9]+\]")
-        error_log_cmd = "nvme error-log " + self.ctrl
+        error_log_cmd = f"{self.nvme_bin} error-log {self.ctrl}"
         proc = subprocess.Popen(error_log_cmd,
                                 shell=True,
                                 stdout=subprocess.PIPE,
@@ -547,7 +558,7 @@ class TestNVMe(unittest.TestCase):
             - Returns:
                 - value for key requested.
         """
-        id_ctrl = "nvme id-ctrl " + self.ctrl
+        id_ctrl = f"{self.nvme_bin} id-ctrl {self.ctrl}"
         print("\n" + id_ctrl)
         proc = subprocess.Popen(id_ctrl,
                                 shell=True,
index bf30e0a4b02804753e56666d62d0a3fbec2eef75..e12d8c09d0c4a6cb9d4c214a073b8d57ba5cd872 100644 (file)
@@ -77,10 +77,10 @@ class TestNVMeIO(TestNVMe):
             - Returns:
                 - return code for nvme write command.
         """
-        write_cmd = "nvme write " + self.ns1 + " --start-block=" + \
-                    str(self.start_block) + " --block-count=" + \
-                    str(self.block_count) + " --data-size=" + \
-                    str(self.data_size) + " --data=" + self.write_file
+        write_cmd = f"{self.nvme_bin} write {self.ns1} " + \
+            f"--start-block={str(self.start_block)} " + \
+            f"--block-count={str(self.block_count)} " + \
+            f"--data-size={str(self.data_size)} --data={self.write_file}"
         return self.exec_cmd(write_cmd)
 
     def nvme_read(self):
@@ -90,9 +90,9 @@ class TestNVMeIO(TestNVMe):
             - Returns:
                 - return code for nvme read command.
         """
-        read_cmd = "nvme read " + self.ns1 + " --start-block=" + \
-                   str(self.start_block) + " --block-count=" + \
-                   str(self.block_count) + " --data-size=" + \
-                   str(self.data_size) + " --data=" + self.read_file
+        read_cmd = f"{self.nvme_bin} read {self.ns1} " + \
+            f"--start-block={str(self.start_block)} " + \
+            f"--block-count={str(self.block_count)} " + \
+            f"--data-size={str(self.data_size)} --data={self.read_file}"
         print(read_cmd)
         return self.exec_cmd(read_cmd)
index 7c30828f51bfb3c061f21ed8b3482bb8478b8c31..44c8942bff8a883203719a9b2202137c1e366f50 100644 (file)
@@ -44,10 +44,10 @@ class TestNVMeVerify(TestNVMe):
             - Returns:
                 - return code for nvme verify command.
         """
-        verify_cmd = "nvme verify " + self.ctrl + \
-                     " --namespace-id=" + str(self.namespace) + \
-                     " --start-block=" + str(self.start_block) + \
-                     " --block-count=" + str(self.block_count)
+        verify_cmd = f"{self.nvme_bin} verify {self.ctrl} " + \
+            f"--namespace-id={str(self.namespace)} " + \
+            f"--start-block={str(self.start_block)} " + \
+            f"--block-count={str(self.block_count)}"
         return self.exec_cmd(verify_cmd)
 
     def test_verify(self):
index 1083d4623433afe758d2b5653dd68aeb74874540..8e0b9a05b45a9e0211dae3a261de5585b53ac2f5 100644 (file)
@@ -63,9 +63,9 @@ class TestNVMeUncor(TestNVMeIO):
             - Returns:
                 - return code of nvme write uncorrectable command.
         """
-        write_uncor_cmd = "nvme write-uncor " + self.ns1 + \
-                          " --start-block=" + str(self.start_block) + \
-                          " --block-count=" + str(self.block_count)
+        write_uncor_cmd = f"{self.nvme_bin} write-uncor {self.ns1} " + \
+            f"--start-block={str(self.start_block)} " + \
+            f"--block-count={str(self.block_count)}"
         return self.exec_cmd(write_uncor_cmd)
 
     def test_write_uncor(self):
index 3231e3dd9f90a465cc7cc9fb56c99f41afcfc381..75d568742710a8bdd2491f363e326ba1c81e9563 100644 (file)
@@ -71,9 +71,9 @@ class TestNVMeWriteZeros(TestNVMeIO):
             - Returns:
                 - return code for nvme write command.
         """
-        write_zeroes_cmd = "nvme write-zeroes " + self.ns1 + \
-                           " --start-block=" + str(self.start_block) + \
-                           " --block-count=" + str(self.block_count)
+        write_zeroes_cmd = f"{self.nvme_bin} write-zeroes {self.ns1} " + \
+            f"--start-block={str(self.start_block)} " + \
+            f"--block-count={str(self.block_count)}"
         return self.exec_cmd(write_zeroes_cmd)
 
     def validate_write_read(self):