Fix handling of failed tests
- Exclude more tests known to fail
- Return fail (non-zero) exit status if one or more test fails
Signed-off-by: Fuad Tabba <tabba@google.com>
diff --git a/Makefile b/Makefile
index bccca31..9279a00 100644
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,7 @@
KUT_ROOTFS_IMAGE := $(ROOT_DIR)/prebuilts/linux-aarch64/images/rootfs.ext4
# Exclude tests that require user interaction or are known to fail.
-KUT_EXCLUDE := "(.+migrat.+)|(pmu-event-introspection)"
+KUT_EXCLUDE := "(.+migrat.+)|(gicv2-.+)|(pmu-event-introspection)|(micro-bench)"
.PHONY: test
test: kvmunittests linux_image
diff --git a/aarch64-unit-tests/run_tests.sh b/aarch64-unit-tests/run_tests.sh
index 3d6090d..423b79f 100755
--- a/aarch64-unit-tests/run_tests.sh
+++ b/aarch64-unit-tests/run_tests.sh
@@ -19,14 +19,16 @@
VHE=1
NVHE=0
-function get_qemu_binary()
-{
- local qemu=${QEMU:-qemu-system-aarch64}
-
- if $qemu --help 2>/dev/null | grep -q 'QEMU'; then
- command -v "${qemu}"
- fi
-}
+exit_status=0
+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+test_dir=""
+log_dir=${LOG_DIR:-out/test/kvm-unit-tests}
+exclude_regex=""
+j=1
+linux=""
+rootfs=""
+verbose=${VERBOSE:-0}
+qemu=${QEMU:-qemu-system-aarch64}
function get_outcome()
{
@@ -56,35 +58,33 @@
exit 1
}
+function wait_free_job_slots()
+{
+ while (( $(jobs | wc -l) == j )); do
+ # Wait for enough jobs to finish
+ wait -n || exit_status=1
+ done
+}
+
+function wait_background_jobs()
+{
+ while (( $(jobs | wc -l) > 0 )); do
+ # Wait for background jobs
+ wait -n || exit_status=1
+ done
+}
+
function run_job()
{
- local job="$1"
- if [ -z "$job" ]; then
- return
- fi
-
- while (( $(jobs | wc -l) == j )); do
- # Wait for background jobs
- wait -n 2>/dev/null
- done
+ wait_free_job_slots
if [ "$j" = 1 ]; then
- bash -c "$@"
+ bash -c "$@" || exit_status=1
else
bash -c "$@" &
fi
}
-script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-test_dir=""
-log_dir=${LOG_DIR:-out/test/kvm-unit-tests}
-exclude_regex=""
-j=1
-linux=""
-rootfs=""
-verbose=${VERBOSE:-0}
-qemu=$(get_qemu_binary)
-
while getopts ":t:x:j:l:r:e:hv" opt; do
case "${opt}" in
t)
@@ -171,4 +171,7 @@
run_job "${script_dir}/run_emu.sh ${test} ${linux} ${rootfs} ${qemu} ${VHE} ${log_dir}/logs/vhe/${test_name}.log \"${test_name} (vhe)\" &> >(tail -1)"
run_job "${script_dir}/run_emu.sh ${test} ${linux} ${rootfs} ${qemu} ${NVHE} ${log_dir}/logs/nvhe/${test_name}.log \"${test_name} (nvhe)\" &> >(tail -1)"
done
-wait
+
+wait_background_jobs
+
+exit $exit_status