diff --git a/README.adoc b/README.adoc index c32b7fd..f09f09d 100644 --- a/README.adoc +++ b/README.adoc @@ -10184,7 +10184,7 @@ Testing that should be done for every functional patch. ===== Guest testing -Build for all stable archs and run basic fast tests: +Run all tests: .... ./build-all @@ -10199,6 +10199,15 @@ Sources: * link:build-all[] * link:test[] +Test just the kernel modules: + +.... +./test-kernel-modules +echo $? +.... + +Source: link:test-kernel-module[] + Test that the Internet works: .... diff --git a/common.py b/common.py index 146b1e1..61cff70 100644 --- a/common.py +++ b/common.py @@ -310,10 +310,19 @@ def run_cmd( del env[key] if show_cmd: print_cmd(cmd, cmd_file, extra_env=extra_env) + # Otherwise Ctrl + C gives: # - ugly Python stack trace for gem5 (QEMU takes over terminal and is fine). # - 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 + sigint_old = signal.getsignal(signal.SIGINT) signal.signal(signal.SIGINT, signal.SIG_IGN) + + # Otherwise BrokenPipeError when piping through | grep + # But if I do this, my terminal gets broken at the end. Why, why, why. + # https://stackoverflow.com/questions/14207708/ioerror-errno-32-broken-pipe-python + # Ignoring the exception is not enough as it prints a warning anyways. + #sigpipe_old = signal.getsignal(signal.SIGPIPE) + #signal.signal(signal.SIGPIPE, signal.SIG_DFL) # https://stackoverflow.com/questions/15535240/python-popen-write-to-stdout-and-log-file-simultaneously/52090802#52090802 with subprocess.Popen(cmd, stdout=stdout, stderr=stderr, env=env, **kwargs) as proc: if out_file is not None: @@ -327,7 +336,8 @@ def run_cmd( logfile.write(byte) else: break - signal.signal(signal.SIGINT, signal.SIG_DFL) + signal.signal(signal.SIGINT, sigint_old) + #signal.signal(signal.SIGPIPE, sigpipe_old) return proc.returncode def setup(parser, **extra_args): diff --git a/run b/run index 873a14a..c9cc0f6 100755 --- a/run +++ b/run @@ -105,9 +105,7 @@ def main(args, extra_args=None): raise_rootfs_not_found() common.raw_to_qcow2(prebuilt=args.prebuilt, reverse=True) if not os.path.exists(common.vmlinux): - # This would allow us to run the prebuilt QEMU Linux image. - # but TODO cannot convert Image to vmlinux on aarch64: - # run-detectors: unable to find an interpreter for + # This is to run gem5 from a prebuilt download. if not os.path.exists(common.linux_image): raise Exception('Linux kernel image not found. Did you compile it?\n' \ 'Tried: ' + common.vmlinux) @@ -305,11 +303,11 @@ def main(args, extra_args=None): if args.gem5: # We have to do some parsing here because gem5 exits with status 0 even when panic happens. # Grepping for '^panic: ' does not work because some errors don't show that message. - panic_msg = '--- BEGIN LIBC BACKTRACE ---$' + panic_msg = b'--- BEGIN LIBC BACKTRACE ---$' else: - panic_msg = 'Kernel panic - not syncing' + panic_msg = b'Kernel panic - not syncing' panic_re = re.compile(panic_msg) - with open(common.termout_file, 'r') as logfile: + with open(common.termout_file, 'br') as logfile: for line in logfile: if panic_re.search(line): common.log_error('simulation error detected by parsing logs') diff --git a/test b/test index e8e9eea..a9743c2 100755 --- a/test +++ b/test @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -eu ./bench-boot -t "${1:-1}" -./run -F '/test_all.sh;/poweroff.out' | grep -q lkmc_test_pass +./test-kernel-modules diff --git a/test-kernel-modules b/test-kernel-modules new file mode 100755 index 0000000..83a539a --- /dev/null +++ b/test-kernel-modules @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -eu +root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +getvar="${root_dir}/getvar" +termout_file="$("$getvar" termout_file)" +./run --eval-busybox '/test_all.sh;/poweroff.out' --kvm +grep -q lkmc_test_pass "$termout_file"