Skip to content

Commit

Permalink
tests: Create default ns on tearDown
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MaisenbacherD committed Oct 28, 2024
1 parent be6b8dc commit ea72a95
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/nvme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ def tearDown(self):
""" 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.
Expand Down

0 comments on commit ea72a95

Please sign in to comment.