]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme_test: Add supp_check_id_ctrl wrapper for support check
authorArunpandian J <apj.arun@samsung.com>
Fri, 25 Mar 2022 03:23:54 +0000 (08:53 +0530)
committerArunpandian J <apj.arun@samsung.com>
Fri, 25 Mar 2022 03:23:54 +0000 (08:53 +0530)
added supp_check_id_ctrl wrapper to check support
based on passed key value to make it generic.

Signed-off-by: Arunpandian J <apj.arun@samsung.com>
tests/nvme_test.py

index 5a5971ee03fddc61c37eb3f7bc5f817c5175d5af..11c89fe46b16286451581ec5fd0e9bb1edd21733 100644 (file)
@@ -478,3 +478,26 @@ class TestNVMe(object):
                                   encoding='utf-8')
         run_io_result = run_io.communicate()[1]
         assert_equal(run_io_result, None)
+
+    def supp_check_id_ctrl(self, key):
+        """ Wrapper for support check.
+            - Args:
+                - key : search key.
+            - Returns:
+                - value for key requested.
+        """
+        id_ctrl = "nvme id-ctrl " + self.ctrl
+        print("\n" + id_ctrl)
+        proc = subprocess.Popen(id_ctrl,
+                                shell=True,
+                                stdout=subprocess.PIPE,
+                                encoding='utf-8')
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : nvme Identify controller Data \
+                     structure failed")
+        for line in proc.stdout:
+            if key in line:
+                key = line.replace(",", "", 1)
+        print(key)
+        val = (key.split(':'))[1].strip()
+        return int(val, 16)