Skip to content

Commit be5f03c

Browse files
committed
contest: vm: try to catch kmemleaks
Check if VM has kmemleak support and dump its output after each test. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e2c20b4 commit be5f03c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

contest/remote/lib/vm.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def __init__(self, config, vm_name=""):
9292
self.cfg_boot_to = int(config.get('vm', 'boot_timeout'))
9393

9494
self.filter_data = None
95+
self.has_kmemleak = None
9596
self.log_out = ""
9697
self.log_err = ""
9798

@@ -223,6 +224,11 @@ def start(self, cwd=None):
223224
self.cmd("PS1='xx__-> '")
224225
self.drain_to_prompt()
225226

227+
off = len(self.log_out)
228+
self.cmd("ls /sys/kernel/debug/")
229+
self.drain_to_prompt()
230+
self.has_kmemleak = "kmemleak" in self.log_out[off:]
231+
226232
self._set_env()
227233

228234
def stop(self):
@@ -278,7 +284,10 @@ def _read_pipe_nonblock(self, pipe):
278284
return read_some, output
279285
read_some = True
280286
output = decode_and_filter(buf)
281-
if output.find("] RIP: ") != -1 or output.find("] Call Trace:") != -1 or output.find('] ref_tracker: ') != -1:
287+
if output.find("] RIP: ") != -1 or \
288+
output.find("] Call Trace:") != -1 or \
289+
output.find('] ref_tracker: ') != -1 or \
290+
output.find('unreferenced object 0x') != -1:
282291
self.fail_state = "oops"
283292
except BlockingIOError:
284293
pass
@@ -425,6 +434,13 @@ def extract_crash(self, out_path):
425434
self.fail_state = ""
426435
return finger_prints
427436

437+
def check_health(self):
438+
if self.fail_state:
439+
return
440+
if self.has_kmemleak:
441+
self.cmd("echo scan > /sys/kernel/debug/kmemleak && cat /sys/kernel/debug/kmemleak")
442+
self.drain_to_prompt()
443+
428444
def bash_prev_retcode(self):
429445
self.cmd("echo $?")
430446
stdout, stderr = self.drain_to_prompt()

contest/remote/vmksft-p.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def _vm_thread(config, results_path, thr_id, hard_stop, in_queue, out_queue):
162162
if indicators["fail"]:
163163
result = 'fail'
164164

165+
vm.check_health()
166+
165167
crashes = None
166168
if vm.fail_state == 'oops':
167169
print(f"INFO: thr-{thr_id} test crashed kernel:", prog)

0 commit comments

Comments
 (0)