diff options
Diffstat (limited to 'test/test-functions')
-rw-r--r-- | test/test-functions | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/test/test-functions b/test/test-functions index 5f95a8129e..d8b7109671 100644 --- a/test/test-functions +++ b/test/test-functions @@ -9,6 +9,7 @@ KERNEL_VER=${KERNEL_VER-$(uname -r)} KERNEL_MODS="/lib/modules/$KERNEL_VER/" QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}" NSPAWN_TIMEOUT="${NSPAWN_TIMEOUT:-infinity}" +TIMED_OUT= # will be 1 after run_* if *_TIMEOUT is set and test timed out FSTYPE="${FSTYPE:-ext3}" UNIFIED_CGROUP_HIERARCHY="${UNIFIED_CGROUP_HIERARCHY:-no}" @@ -46,6 +47,8 @@ function find_qemu_bin() { fi } +# Return 0 if QEMU did run (then you must check the result state/logs for actual +# success), or 1 if QEMU is not available. run_qemu() { if [ -f /etc/machine-id ]; then read MACHINE_ID < /etc/machine-id @@ -94,8 +97,15 @@ $KERNEL_APPEND \ if [[ "$QEMU_TIMEOUT" != "infinity" ]]; then QEMU_BIN="timeout --foreground $QEMU_TIMEOUT $QEMU_BIN" fi - ( set -x - $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" ) || return 1 + (set -x; $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND") + rc=$? + if [ "$rc" = 124 ] && [ "$QEMU_TIMEOUT" != "infinity" ]; then + derror "test timed out after $QEMU_TIMEOUT s" + TIMED_OUT=1 + else + [ "$rc" != 0 ] && derror "QEMU failed with exit code $rc" + fi + return 0 } run_nspawn() { @@ -106,8 +116,15 @@ run_nspawn() { _nspawn_cmd="env UNIFIED_CGROUP_HIERARCHY=$UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd" - set -x - $_nspawn_cmd + (set -x; $_nspawn_cmd) + rc=$? + if [ "$rc" = 124 ] && [ "$NSPAWN_TIMEOUT" != "infinity" ]; then + derror "test timed out after $NSPAWN_TIMEOUT s" + TIMED_OUT=1 + else + [ "$rc" != 0 ] && derror "nspawn failed with exit code $rc" + fi + return 0 } setup_basic_environment() { @@ -290,6 +307,7 @@ check_result_nspawn() { [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed ls -l $TESTDIR/journal/*/*.journal test -s $TESTDIR/failed && ret=$(($ret+1)) + [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) return $ret } |