]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
tests: Create default ns on tearDown
authorDennis Maisenbacher <dennis.maisenbacher@wdc.com>
Fri, 25 Oct 2024 06:27:28 +0000 (06:27 +0000)
committerDaniel Wagner <wagi@monom.org>
Tue, 29 Oct 2024 06:37:41 +0000 (07:37 +0100)
After a test was run, the `tearDown` function is called and then creates
and attaches a single ns with the full NVM capacity.
This is done so the caller or the next test case receives a reasonably
formated drive.

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

index 65a43cfd3cbb8ff9ee152724e31fbde98a4a0b99..a13a9939f03c44e83f714708472f871256e3ca94 100644 (file)
@@ -70,6 +70,30 @@ class TestNVMe(unittest.TestCase):
         """ Post Section for TestNVMe. """
         if self.clear_log_dir is True:
             shutil.rmtree(self.log_dir, ignore_errors=True)
+        self.create_and_attach_default_ns()
+
+    def create_and_attach_default_ns(self):
+        """ Creates a default namespace with the full capacity of the ctrls NVM
+            - Args:
+                - None
+            - Returns:
+                - None
+        """
+        self.dps = 0
+        self.flbas = 0
+        (ds, ms) = self.get_lba_format_size()
+        ncap = int(self.get_ncap() / (ds+ms))
+        self.nsze = ncap
+        self.ncap = ncap
+        self.ctrl_id = self.get_ctrl_id()
+        self.delete_all_ns()
+        err = self.create_and_validate_ns(self.default_nsid,
+                                          self.nsze,
+                                          self.ncap,
+                                          self.flbas,
+                                          self.dps)
+        self.assertEqual(err, 0)
+        self.assertEqual(self.attach_ns(self.ctrl_id, self.default_nsid), 0)
 
     def validate_pci_device(self):
         """ Validate underlying device belongs to pci subsystem.