diff options
-rwxr-xr-x | net/test/net_test.sh | 8 | ||||
-rwxr-xr-x | net/test/run_net_test.sh | 29 |
2 files changed, 32 insertions, 5 deletions
diff --git a/net/test/net_test.sh b/net/test/net_test.sh index 72c67a9..f4ca29f 100755 --- a/net/test/net_test.sh +++ b/net/test/net_test.sh @@ -152,7 +152,13 @@ fi echo -e "Running $net_test $net_test_args\n" $net_test $net_test_args +rv="$?" # Write exit code of net_test to a file so that the builder can use it # to signal failure if any tests fail. -echo $? >$net_test_exitcode +echo "${rv}" > "${net_test_exitcode}" + +# Additionally on UML make it the exit code of UML kernel binary itself. +if [[ -e '/proc/exitcode' ]]; then + echo "${rv}" > /proc/exitcode +fi diff --git a/net/test/run_net_test.sh b/net/test/run_net_test.sh index deed5cd..5648a06 100755 --- a/net/test/run_net_test.sh +++ b/net/test/run_net_test.sh @@ -282,8 +282,10 @@ if [ "$ARCH" == "um" ]; then # Get the absolute path to the test file that's being run. cmdline="$cmdline net_test=/host$SCRIPT_DIR/$test" - # Use UML's /proc/exitcode feature to communicate errors on test failure - cmdline="$cmdline net_test_exitcode=/proc/exitcode" + # We'd use UML's /proc/exitcode feature to communicate errors on test failure, + # if not for UML having a tendency to crash during shutdown, + # so instead use an extra serial line we'll redirect to an open fd... + cmdline="$cmdline net_test_exitcode=/dev/ttyS3" # Experience shows that we need at least 128 bits of entropy for the # kernel's crng init to complete (before it fully initializes stuff behaves @@ -307,11 +309,30 @@ if [ "$ARCH" == "um" ]; then blockdevice=ubdar fi + # Create a temp file for 'serial line 3' for return code. + SSL3="$(mktemp)" + exitcode=0 - $KERNEL_BINARY >&2 umid=net_test mem=512M \ - $blockdevice=$SCRIPT_DIR/$ROOTFS $netconfig $consolemode $cmdline \ + $KERNEL_BINARY >&2 3>"${SSL3}" umid=net_test mem=512M \ + $blockdevice=$SCRIPT_DIR/$ROOTFS $netconfig $consolemode ssl3=null,fd:3 $cmdline \ || exitcode=$? + if [[ "${exitcode}" == 134 && -s "${SSL3}" && "$(tr -d '\r' < "${SSL3}")" == 0 ]]; then + # Sometimes the tests all pass, but UML crashes during the shutdown process itself. + # As such we can't actually rely on the /proc/exitcode returned value. + echo "Warning: UML appears to have crashed after successfully executing the tests." 1>&2 + elif [[ "${exitcode}" != 0 ]]; then + echo "Warning: UML exited with ${exitcode} instead of zero." 1>&2 + fi + + if [[ -s "${SSL3}" ]]; then + exitcode="$(tr -d '\r' < "${SSL3}")" + echo "Info: retrieved exit code ${exitcode}." 1>&2 + fi + + rm -f "${SSL3}" + unset SSL3 + # UML is kind of crazy in how guest syscalls work. It requires host kernel # to not be in vsyscall=none mode. if [[ "${exitcode}" != '0' ]]; then |