From a7addca7bcd4aa912f1e31b47451e244e9219099 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 29 May 2025 14:30:57 -0700 Subject: [PATCH] [ci][github] Check QEMU process state before exiting This helps understand what the QEMU process is doing when test fails due to timeout --- scripts/unittest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/unittest.py b/scripts/unittest.py index c057353a..b7d9569d 100644 --- a/scripts/unittest.py +++ b/scripts/unittest.py @@ -32,6 +32,19 @@ def wait_for_output(fp: io.TextIOBase, predicate, timeout: float): def shutdown_little_kernel(p: subprocess.Popen): try: + ret = p.poll() + if ret: + print("LittleKernel already exited with code", ret) + return + status_path = "/proc/{}/status".format(p.pid) + if os.path.exists(status_path): + with open(status_path) as fp: + lines = fp.readlines() + state_line = [l for l in lines if "State:" in l] + if state_line: + print("LittleKernel process state after test:",state_line[0].rstrip()) + else: + print(status_path, "does not exists") p.stdin.write("poweroff\n") p.stdin.flush() p.wait(0.3)