Skip to content

Commit 12578ab

Browse files
revised scripts and unit test
revised scripts and unit test
1 parent 6a1a4c5 commit 12578ab

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

providers/base/bin/watchdog_test.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,16 @@ def probe_watchdog_module(kernel_module):
123123
"""
124124
ret = None
125125
# probe watchdog kernel module if it's not exists
126-
ret = subprocess.run(
127-
shlex.split("modprobe {}".format(kernel_module))
128-
)
126+
ret = subprocess.run(shlex.split("modprobe {}".format(kernel_module)))
129127
time.sleep(2)
130128
try:
131129
yield
132130
except Exception as err:
133131
print(err)
134132
finally:
135133
if ret and ret.returncode == 0:
136-
subprocess.run(
137-
shlex.split("modprobe -r {}".format(kernel_module))
138-
)
134+
cmd = "modprobe -r {}".format(kernel_module)
135+
subprocess.run(shlex.split(cmd))
139136

140137

141138
def collect_hardware_watchdogs(watchdog_identity: str = "") -> dict:

providers/base/tests/test_watchdog_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ def test_probe_watchdog_module(self, mock_run, mock_sleep):
7676
mock_run.return_value = mock_result
7777
with probe_watchdog_module("kernel"):
7878
pass
79-
calls = [call(["modprobe", "kernel"]), call(["modprobe", "-r", "kernel"])]
79+
calls = [
80+
call(["modprobe", "kernel"]),
81+
call(["modprobe", "-r", "kernel"]),
82+
]
8083
mock_sleep.assert_called_with(2)
8184
mock_run.assert_has_calls(calls)
8285

0 commit comments

Comments
 (0)