Skip to content

Commit b2238da

Browse files
committed
Split test kernel modules to a separate script.
Notice that Python sucks and does SIGPIPE annoyances, for now work around by grepping the output file... Fix the exit status read check with 'b', it broke down occasionally with: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 1832: invalid start byte
1 parent 72d18a7 commit b2238da

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

README.adoc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10184,7 +10184,7 @@ Testing that should be done for every functional patch.
1018410184

1018510185
===== Guest testing
1018610186

10187-
Build for all stable archs and run basic fast tests:
10187+
Run all tests:
1018810188

1018910189
....
1019010190
./build-all
@@ -10199,6 +10199,15 @@ Sources:
1019910199
* link:build-all[]
1020010200
* link:test[]
1020110201

10202+
Test just the kernel modules:
10203+
10204+
....
10205+
./test-kernel-modules
10206+
echo $?
10207+
....
10208+
10209+
Source: link:test-kernel-module[]
10210+
1020210211
Test that the Internet works:
1020310212

1020410213
....

common.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,19 @@ def run_cmd(
310310
del env[key]
311311
if show_cmd:
312312
print_cmd(cmd, cmd_file, extra_env=extra_env)
313+
313314
# Otherwise Ctrl + C gives:
314315
# - ugly Python stack trace for gem5 (QEMU takes over terminal and is fine).
315316
# - kills Python, and that then kills GDB: https://stackoverflow.com/questions/19807134/does-python-always-raise-an-exception-if-you-do-ctrlc-when-a-subprocess-is-exec
317+
sigint_old = signal.getsignal(signal.SIGINT)
316318
signal.signal(signal.SIGINT, signal.SIG_IGN)
319+
320+
# Otherwise BrokenPipeError when piping through | grep
321+
# But if I do this, my terminal gets broken at the end. Why, why, why.
322+
# https://stackoverflow.com/questions/14207708/ioerror-errno-32-broken-pipe-python
323+
# Ignoring the exception is not enough as it prints a warning anyways.
324+
#sigpipe_old = signal.getsignal(signal.SIGPIPE)
325+
#signal.signal(signal.SIGPIPE, signal.SIG_DFL)
317326
# https://stackoverflow.com/questions/15535240/python-popen-write-to-stdout-and-log-file-simultaneously/52090802#52090802
318327
with subprocess.Popen(cmd, stdout=stdout, stderr=stderr, env=env, **kwargs) as proc:
319328
if out_file is not None:
@@ -327,7 +336,8 @@ def run_cmd(
327336
logfile.write(byte)
328337
else:
329338
break
330-
signal.signal(signal.SIGINT, signal.SIG_DFL)
339+
signal.signal(signal.SIGINT, sigint_old)
340+
#signal.signal(signal.SIGPIPE, sigpipe_old)
331341
return proc.returncode
332342

333343
def setup(parser, **extra_args):

run

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ def main(args, extra_args=None):
105105
raise_rootfs_not_found()
106106
common.raw_to_qcow2(prebuilt=args.prebuilt, reverse=True)
107107
if not os.path.exists(common.vmlinux):
108-
# This would allow us to run the prebuilt QEMU Linux image.
109-
# but TODO cannot convert Image to vmlinux on aarch64:
110-
# run-detectors: unable to find an interpreter for
108+
# This is to run gem5 from a prebuilt download.
111109
if not os.path.exists(common.linux_image):
112110
raise Exception('Linux kernel image not found. Did you compile it?\n' \
113111
'Tried: ' + common.vmlinux)
@@ -305,11 +303,11 @@ def main(args, extra_args=None):
305303
if args.gem5:
306304
# We have to do some parsing here because gem5 exits with status 0 even when panic happens.
307305
# Grepping for '^panic: ' does not work because some errors don't show that message.
308-
panic_msg = '--- BEGIN LIBC BACKTRACE ---$'
306+
panic_msg = b'--- BEGIN LIBC BACKTRACE ---$'
309307
else:
310-
panic_msg = 'Kernel panic - not syncing'
308+
panic_msg = b'Kernel panic - not syncing'
311309
panic_re = re.compile(panic_msg)
312-
with open(common.termout_file, 'r') as logfile:
310+
with open(common.termout_file, 'br') as logfile:
313311
for line in logfile:
314312
if panic_re.search(line):
315313
common.log_error('simulation error detected by parsing logs')

test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22
set -eu
33
./bench-boot -t "${1:-1}"
4-
./run -F '/test_all.sh;/poweroff.out' | grep -q lkmc_test_pass
4+
./test-kernel-modules

test-kernel-modules

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
4+
getvar="${root_dir}/getvar"
5+
termout_file="$("$getvar" termout_file)"
6+
./run --eval-busybox '/test_all.sh;/poweroff.out' --kvm
7+
grep -q lkmc_test_pass "$termout_file"

0 commit comments

Comments
 (0)