Skip to content

Commit 7baebb9

Browse files
MaisenbacherDigaw
authored andcommitted
tests: Refactor prints
Remove unused prints and add some informative prints. Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent 94924df commit 7baebb9

11 files changed

+20
-43
lines changed

tests/nvme_copy_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class TestNVMeCopy(TestNVMe):
3434
def setUp(self):
3535
""" Pre Section for TestNVMeCopy """
3636
super().setUp()
37-
print("\nSetting up test...")
3837
self.ocfs = self.get_ocfs()
3938
self.host_behavior_data = None
4039
cross_namespace_copy = self.ocfs & 0xc
@@ -78,7 +77,6 @@ def setUp(self):
7877

7978
def tearDown(self):
8079
""" Post Section for TestNVMeCopy """
81-
print("Tearing down test...")
8280
if self.host_behavior_data:
8381
# restore saved host behavior support data
8482
set_features_cmd = f"{self.nvme_bin} set-feature {self.ctrl} " + \
@@ -117,12 +115,10 @@ def copy(self, sdlba, blocks, slbs, **kwargs):
117115
if "sopts" in kwargs:
118116
copy_cmd += f" --sopts={kwargs['sopts']}"
119117
# run and assert success
120-
print("Running command:", copy_cmd)
121118
self.assertEqual(self.exec_cmd(copy_cmd), 0)
122119

123120
def test_copy(self):
124121
""" Testcase main """
125-
print("Running test...")
126122
self.copy(0, 1, 2, descriptor_format=0)
127123
self.copy(0, 1, 2, descriptor_format=1)
128124
self.copy(0, 1, 2, descriptor_format=2, snsids=self.ns1_nsid)

tests/nvme_create_max_ns_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,21 @@ def test_attach_detach_ns(self):
8282
""" Testcase main """
8383
print(f"##### Testing max_ns: {self.max_ns}")
8484
for nsid in range(1, self.max_ns + 1):
85-
print("##### Creating " + str(nsid))
85+
print(f"##### Creating {nsid}")
8686
err = self.create_and_validate_ns(nsid,
8787
self.nsze,
8888
self.ncap,
8989
self.flbas,
9090
self.dps)
9191
self.assertEqual(err, 0)
92-
print("##### Attaching " + str(nsid))
92+
print(f"##### Attaching {nsid}")
9393
self.assertEqual(self.attach_ns(self.ctrl_id, nsid), 0)
94-
print("##### Running IOs in " + str(nsid))
94+
print(f"##### Running IOs in {nsid}")
9595
self.run_ns_io(nsid, 9, 1)
9696

9797
for nsid in range(1, self.max_ns + 1):
98-
print("##### Detaching " + str(nsid))
98+
print(f"##### Detaching {nsid}")
9999
self.assertEqual(self.detach_ns(self.ctrl_id, nsid), 0)
100-
print("#### Deleting " + str(nsid))
100+
print(f"#### Deleting {nsid}")
101101
self.assertEqual(self.delete_and_validate_ns(nsid), 0)
102102
self.nvme_reset_ctrl()

tests/nvme_flush_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def nvme_flush(self):
5555
"""
5656
flush_cmd = f"{self.nvme_bin} flush {self.ctrl} " + \
5757
f"--namespace-id={str(self.default_nsid)}"
58-
print(flush_cmd)
5958
return self.exec_cmd(flush_cmd)
6059

6160
def test_nvme_flush(self):

tests/nvme_format_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def test_format_ns(self):
122122
# extract the supported format information.
123123
self.attach_detach_primary_ns()
124124

125+
print("##### Testing lba formats:")
125126
# iterate through all supported format
126127
for flbas, lba_format in enumerate(self.lba_format_list):
127128
ds = lba_format['ds']

tests/nvme_fw_log_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,12 @@ def get_fw_log(self):
5757
- Returns:
5858
- 0 on success, error code on failure.
5959
"""
60-
err = 0
6160
fw_log_cmd = f"{self.nvme_bin} fw-log {self.ctrl}"
6261
proc = subprocess.Popen(fw_log_cmd,
6362
shell=True,
6463
stdout=subprocess.PIPE,
6564
encoding='utf-8')
66-
fw_log_output = proc.communicate()[0]
67-
print("\n" + fw_log_output + "\n")
68-
err = proc.wait()
69-
return err
65+
return proc.wait()
7066

7167
def test_fw_log(self):
7268
""" Testcase main """

tests/nvme_get_features_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ def get_mandatory_features(self, feature_id):
8888
shell=True,
8989
stdout=subprocess.PIPE,
9090
encoding='utf-8')
91-
feature_output = proc.communicate()[0]
92-
print(feature_output)
9391
self.assertEqual(proc.wait(), 0)
9492
else:
9593
get_feat_cmd = f"{self.nvme_bin} get-feature {self.ctrl} " + \
@@ -100,8 +98,6 @@ def get_mandatory_features(self, feature_id):
10098
shell=True,
10199
stdout=subprocess.PIPE,
102100
encoding='utf-8')
103-
feature_output = proc.communicate()[0]
104-
print(feature_output)
105101
self.assertEqual(proc.wait(), 0)
106102

107103
def test_get_mandatory_features(self):

tests/nvme_get_lba_status_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def get_lba_status(self):
5050
- Returns:
5151
- 0 on success, error code on failure.
5252
"""
53-
err = 0
5453
get_lba_status_cmd = f"{self.nvme_bin} get-lba-status {self.ctrl} " + \
5554
f"--namespace-id={str(self.ns1)} " + \
5655
f"--start-lba={str(self.start_lba)} " + \
@@ -61,10 +60,7 @@ def get_lba_status(self):
6160
shell=True,
6261
stdout=subprocess.PIPE,
6362
encoding='utf-8')
64-
get_lba_status_output = proc.communicate()[0]
65-
print("\n" + get_lba_status_output + "\n")
66-
err = proc.wait()
67-
return err
63+
return proc.wait()
6864

6965
def test_get_lba_status(self):
7066
""" Testcase main """

tests/nvme_id_ns_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,13 @@ def get_id_ns(self, nsid):
6060
- Returns:
6161
- 0 on success, error code on failure.
6262
"""
63-
err = 0
6463
id_ns_cmd = f"{self.nvme_bin} id-ns {self.ctrl} " + \
6564
f"--namespace-id={str(nsid)}"
6665
proc = subprocess.Popen(id_ns_cmd,
6766
shell=True,
6867
stdout=subprocess.PIPE,
6968
encoding='utf-8')
70-
id_ns_output = proc.communicate()[0]
71-
print(id_ns_output + "\n")
72-
err = proc.wait()
73-
return err
69+
return proc.wait()
7470

7571
def get_id_ns_all(self):
7672
"""

tests/nvme_lba_status_log_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ def get_lba_stat_log(self):
4545
- Returns:
4646
- 0 on success, error code on failure.
4747
"""
48-
err = 0
4948
lba_stat_log_cmd = f"{self.nvme_bin} lba-status-log {self.ctrl}"
5049
proc = subprocess.Popen(lba_stat_log_cmd,
5150
shell=True,
5251
stdout=subprocess.PIPE,
5352
encoding='utf-8')
54-
lba_stat_log_output = proc.communicate()[0]
55-
print("\n" + lba_stat_log_output + "\n")
56-
err = proc.wait()
57-
return err
53+
return proc.wait()
5854

5955
def test_lba_stat_log(self):
6056
""" Testcase main """

tests/nvme_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ def setUp(self):
6666
self.load_config()
6767
if self.do_validate_pci_device:
6868
self.validate_pci_device()
69+
print(f"\nsetup: ctrl: {self.ctrl}, ns1: {self.ns1}, default_nsid: {self.default_nsid}, flbas: {self.flbas}\n")
6970

7071
def tearDown(self):
7172
""" Post Section for TestNVMe. """
7273
if self.clear_log_dir is True:
7374
shutil.rmtree(self.log_dir, ignore_errors=True)
7475
self.create_and_attach_default_ns()
76+
print(f"\nteardown: ctrl: {self.ctrl}, ns1: {self.ns1}, default_nsid: {self.default_nsid}, flbas: {self.flbas}\n")
77+
78+
@classmethod
79+
def tearDownClass(cls):
80+
print("\n")
7581

7682
def create_and_attach_default_ns(self):
7783
""" Creates a default namespace with the full capacity of the ctrls NVM
@@ -104,8 +110,8 @@ def validate_pci_device(self):
104110
- None
105111
"""
106112
x1, x2, dev = self.ctrl.split('/')
107-
cmd = cmd = "find /sys/devices -name \\*" + dev + " | grep -i pci"
108-
err = subprocess.call(cmd, shell=True)
113+
cmd = "find /sys/devices -name \\*" + dev + " | grep -i pci"
114+
err = subprocess.call(cmd, shell=True, stdout=subprocess.DEVNULL)
109115
self.assertEqual(err, 0, "ERROR : Only NVMe PCI subsystem is supported")
110116

111117
def load_config(self):
@@ -452,15 +458,12 @@ def get_smart_log(self, nsid):
452458
"""
453459
smart_log_cmd = f"{self.nvme_bin} smart-log {self.ctrl} " + \
454460
f"--namespace-id={str(nsid)}"
455-
print(smart_log_cmd)
456461
proc = subprocess.Popen(smart_log_cmd,
457462
shell=True,
458463
stdout=subprocess.PIPE,
459464
encoding='utf-8')
460465
err = proc.wait()
461466
self.assertEqual(err, 0, "ERROR : nvme smart log failed")
462-
smart_log_output = proc.communicate()[0]
463-
print(f"{smart_log_output}")
464467
return err
465468

466469
def get_id_ctrl(self, vendor=False):
@@ -475,7 +478,6 @@ def get_id_ctrl(self, vendor=False):
475478
else:
476479
id_ctrl_cmd = f"{self.nvme_bin} id-ctrl " +\
477480
f"--vendor-specific {self.ctrl}"
478-
print(id_ctrl_cmd)
479481
proc = subprocess.Popen(id_ctrl_cmd,
480482
shell=True,
481483
stdout=subprocess.PIPE,
@@ -521,14 +523,14 @@ def run_ns_io(self, nsid, lbads, count=10):
521523
ns_path = self.ctrl + "n" + str(nsid)
522524
io_cmd = "dd if=" + ns_path + " of=/dev/null" + " bs=" + \
523525
str(block_size) + " count=" + str(count) + " > /dev/null 2>&1"
524-
print(io_cmd)
526+
print(f"Running io: {io_cmd}")
525527
run_io = subprocess.Popen(io_cmd, shell=True, stdout=subprocess.PIPE,
526528
encoding='utf-8')
527529
run_io_result = run_io.communicate()[1]
528530
self.assertEqual(run_io_result, None)
529531
io_cmd = "dd if=/dev/zero of=" + ns_path + " bs=" + \
530532
str(block_size) + " count=" + str(count) + " > /dev/null 2>&1"
531-
print(io_cmd)
533+
print(f"Running io: {io_cmd}")
532534
run_io = subprocess.Popen(io_cmd, shell=True, stdout=subprocess.PIPE,
533535
encoding='utf-8')
534536
run_io_result = run_io.communicate()[1]

0 commit comments

Comments
 (0)