Skip to content

Commit 3ab40b9

Browse files
committed
tests: log all cmds input/output
Add Python's logger framework and log all commands input/output, in order to be able to debug failures. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 5b171b3 commit 3ab40b9

5 files changed

Lines changed: 85 additions & 26 deletions

File tree

tests/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"controller" : "/dev/nvme0",
33
"ns1": "/dev/nvme0n1",
4-
"log_dir": "nvmetests/"
4+
"log_dir": "nvmetests",
5+
"log_level": "DEBUG"
56
}

tests/nvme_copy_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
1717
"""
1818

19+
import logging
1920
import subprocess
2021

2122
from nvme_test import TestNVMe
2223

24+
logger = logging.getLogger(__name__)
25+
2326

2427
class TestNVMeCopy(TestNVMe):
2528

@@ -41,6 +44,7 @@ def setUp(self):
4144
# get host behavior support data
4245
get_features_cmd = f"{self.nvme_bin} get-feature {self.ctrl} " + \
4346
"--feature-id=0x16 --data-len=512 --raw-binary"
47+
logger.debug(get_features_cmd)
4448
proc = subprocess.Popen(get_features_cmd,
4549
shell=True,
4650
stdout=subprocess.PIPE,
@@ -65,13 +69,15 @@ def setUp(self):
6569
proc.communicate(input=data)
6670
self.assertEqual(proc.returncode, 0, "Failed to enable cross-namespace copy formats")
6771
get_ns_id_cmd = f"{self.nvme_bin} get-ns-id {self.ns1}"
72+
logger.debug(get_ns_id_cmd)
6873
proc = subprocess.Popen(get_ns_id_cmd,
6974
shell=True,
7075
stdout=subprocess.PIPE,
7176
encoding='utf-8')
7277
err = proc.wait()
7378
self.assertEqual(err, 0, "ERROR : nvme get-ns-id failed")
7479
output = proc.stdout.read()
80+
logger.debug(output)
7581
self.ns1_nsid = int(output.strip().split(':')[-1])
7682
self.setup_log_dir(self.__class__.__name__)
7783

@@ -81,6 +87,7 @@ def tearDown(self):
8187
# restore saved host behavior support data
8288
set_features_cmd = f"{self.nvme_bin} set-feature {self.ctrl} " + \
8389
"--feature-id=0x16 --data-len=512"
90+
logger.debug(set_features_cmd)
8491
proc = subprocess.Popen(set_features_cmd,
8592
shell=True,
8693
stdout=subprocess.PIPE,

tests/nvme_format_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@
3838
"""
3939

4040
import json
41+
import logging
4142
import math
4243
import subprocess
4344

4445
from nvme_test import TestNVMe
4546

47+
logger = logging.getLogger(__name__)
48+
4649

4750
class TestNVMeFormatCmd(TestNVMe):
4851

@@ -107,13 +110,16 @@ def attach_detach_primary_ns(self):
107110
# read lbaf information
108111
id_ns_cmd = f"{self.nvme_bin} id-ns {self.ctrl} " + \
109112
f"--namespace-id={self.default_nsid} --output-format=json"
113+
logger.debug(id_ns_cmd)
110114
proc = subprocess.Popen(id_ns_cmd,
111115
shell=True,
112116
stdout=subprocess.PIPE,
113117
encoding='utf-8')
114118
err = proc.wait()
115119
self.assertEqual(err, 0, "ERROR : nvme id-ns failed")
116-
json_output = json.loads(proc.stdout.read())
120+
output = proc.stdout.read()
121+
logger.debug(output)
122+
json_output = json.loads(output)
117123
self.lba_format_list = json_output['lbafs']
118124
self.assertTrue(len(self.lba_format_list) > 0,
119125
"ERROR : nvme id-ns could not find any lba formats")

tests/nvme_get_features_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@
3434
9. 0Bh M Asynchronous Event Configuration.
3535
"""
3636

37+
import logging
3738
import subprocess
3839

3940
from nvme_test import TestNVMe
4041

42+
logger = logging.getLogger(__name__)
43+
4144

4245
class TestNVMeGetMandatoryFeatures(TestNVMe):
4346

@@ -59,11 +62,14 @@ def setUp(self):
5962
device = self.ctrl.split('/')[-1]
6063
get_vector_list_cmd = "grep " + device + "q /proc/interrupts |" \
6164
" cut -d : -f 1 | tr -d ' ' | tr '\n' ' '"
65+
logger.debug(get_vector_list_cmd)
6266
proc = subprocess.Popen(get_vector_list_cmd,
6367
shell=True,
6468
stdout=subprocess.PIPE,
6569
encoding='utf-8')
66-
self.vector_list_len = len(proc.stdout.read().strip().split(" "))
70+
output = proc.stdout.read()
71+
logger.debug(output)
72+
self.vector_list_len = len(output.strip().split(" "))
6773

6874
def tearDown(self):
6975
""" Post Section for TestNVMeGetMandatoryFeatures

0 commit comments

Comments
 (0)