summaryrefslogtreecommitdiffstats
path: root/tests/nvme_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/nvme_test.py')
-rw-r--r--tests/nvme_test.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/nvme_test.py b/tests/nvme_test.py
index d5eca18..0df3dac 100644
--- a/tests/nvme_test.py
+++ b/tests/nvme_test.py
@@ -39,7 +39,7 @@ from nvme_test_logger import TestNVMeLogger
class TestNVMe(unittest.TestCase):
"""
- Represents a testcase, each testcase shuold inherit this
+ Represents a testcase, each testcase should inherit this
class or appropriate subclass which is a child of this class.
Common utility functions used in various testcases.
@@ -58,11 +58,13 @@ class TestNVMe(unittest.TestCase):
self.ctrl = "XXX"
self.ns1 = "XXX"
self.test_log_dir = "XXX"
+ self.do_validate_pci_device = True
self.default_nsid = 0x1
self.config_file = 'tests/config.json'
self.load_config()
- self.validate_pci_device()
+ if self.do_validate_pci_device:
+ self.validate_pci_device()
def tearDown(self):
""" Post Section for TestNVMe. """
@@ -70,7 +72,7 @@ class TestNVMe(unittest.TestCase):
shutil.rmtree(self.log_dir, ignore_errors=True)
def validate_pci_device(self):
- """ Validate underlaying device belogs to pci subsystem.
+ """ Validate underlying device belongs to pci subsystem.
- Args:
- None
- Returns:
@@ -93,6 +95,7 @@ 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.clear_log_dir = False
if self.clear_log_dir is True:
@@ -162,7 +165,7 @@ class TestNVMe(unittest.TestCase):
return ctrl_id
def get_ns_list(self):
- """ Wrapper for extrating the namespace list.
+ """ Wrapper for extracting the namespace list.
- Args:
- None
- Returns:
@@ -181,7 +184,7 @@ class TestNVMe(unittest.TestCase):
return ns_list
def get_max_ns(self):
- """ Wrapper for extracting maximum number of namspaces supported.
+ """ Wrapper for extracting maximum number of namespaces supported.
- Args:
- None
- Returns:
@@ -228,6 +231,19 @@ class TestNVMe(unittest.TestCase):
print(ncap)
return int(ncap)
+ def get_ocfs(self):
+ """ Wrapper for extracting optional copy formats supported
+ - Args:
+ - None
+ - Returns:
+ - Optional Copy Formats Supported
+ """
+ pattern = re.compile(r'^ocfs\s*: 0x[0-9a-fA-F]+$')
+ output = subprocess.check_output(["nvme", "id-ctrl", self.ctrl], encoding='utf-8')
+ ocfs_line = next(line for line in output.splitlines() if pattern.match(line))
+ ocfs = ocfs_line.split(":")[1].strip()
+ return int(ocfs, 16)
+
def get_format(self):
""" Wrapper for extracting format.
- Args: