]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Use tnvmcap register for creating namespace
authorNarasimhan V <sim@linux.vnet.ibm.com>
Thu, 12 Jul 2018 10:32:01 +0000 (16:02 +0530)
committerNarasimhan V <sim@linux.vnet.ibm.com>
Thu, 12 Jul 2018 11:44:16 +0000 (17:14 +0530)
Creating max ns by getting the total nvm capacity, and format.
Thus, the whole capacity is used in nvme_create_max_ns_test

Signed-off-by: Narasimhan V <sim@linux.vnet.ibm.com>
tests/nvme_create_max_ns_test.py
tests/nvme_test.py

index b1d803a0c61bea5cba2c764d80bbbe6b11c4af50..e097e59ad0b1fda66c2c8502e20ffd8885ec7d5e 100644 (file)
@@ -50,8 +50,8 @@ class TestNVMeCreateMaxNS(TestNVMe):
         TestNVMe.__init__(self)
         self.dps = 0
         self.flbas = 0
-        self.nsze = 0x1400000
-        self.ncap = 0x1400000
+        self.nsze = self.get_ncap() / self.get_format() / self.get_max_ns()
+        self.ncap = self.nsze
         self.setup_log_dir(self.__class__.__name__)
         self.max_ns = self.get_max_ns()
         self.ctrl_id = self.get_ctrl_id()
index c4541fdcf69542b114e240f486aba8cd2fbcdca4..94406b54a586cfbcebe2c1a5ed16827ab7de8a72 100644 (file)
@@ -204,6 +204,53 @@ class TestNVMe(object):
         print max_ns
         return int(max_ns)
 
+    @tools.nottest
+    def get_ncap(self):
+        """ Wrapper for extracting capacity.
+            - Args:
+                - None
+            - Returns:
+                - maximum number of namespaces supported.
+        """
+        pattern = re.compile("^tnvmcap[ ]+: [0-9]", re.IGNORECASE)
+        ncap = -1
+        ncap_cmd = "nvme id-ctrl " + self.ctrl
+        proc = subprocess.Popen(ncap_cmd,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading nvm capacity failed")
+
+        for line in proc.stdout:
+            if pattern.match(line):
+                ncap = line.split(":")[1].strip()
+                break
+        print ncap
+        return int(ncap)
+
+    @tools.nottest
+    def get_format(self):
+        """ Wrapper for extracting format.
+            - Args:
+                - None
+            - Returns:
+                - maximum format of namespace.
+        """
+        # defaulting to 4K
+        nvm_format = 4096
+        nvm_format_cmd = "nvme id-ns " + self.ctrl + " -n1"
+        proc = subprocess.Popen(nvm_format_cmd,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading nvm capacity failed")
+
+        for line in proc.stdout:
+            if "in use" in line:
+                nvm_format = 2 ** int(line.split(":")[3].split()[0])
+        print nvm_format
+        return int(nvm_format)
+
     @tools.nottest
     def delete_all_ns(self):
         """ Wrapper for deleting all the namespaces.