xref: /kvm-unit-tests/run_tests.sh (revision 9f1591165a262e3240dc10fdf3c73d81431ad0ea)
1#!/bin/bash
2
3verbose="no"
4
5if [ ! -f config.mak ]; then
6    echo "run ./configure && make first. See ./configure -h"
7    exit 1
8fi
9source config.mak
10source scripts/common.bash
11
12function usage()
13{
14cat <<EOF
15
16Usage: $0 [-g group] [-h] [-v]
17
18    -g: Only execute tests in the given group
19    -h: Output this help text
20    -v: Enables verbose mode
21
22Set the environment variable QEMU=/path/to/qemu-system-ARCH to
23specify the appropriate qemu binary for ARCH-run.
24
25EOF
26}
27
28RUNTIME_arch_run="./$TEST_DIR/run"
29source scripts/runtime.bash
30
31while getopts "g:hv" opt; do
32    case $opt in
33        g)
34            only_group=$OPTARG
35            ;;
36        h)
37            usage
38            exit
39            ;;
40        v)
41            verbose="yes"
42            ;;
43        *)
44            exit 2
45            ;;
46    esac
47done
48
49# RUNTIME_log_file will be configured later
50RUNTIME_log_stderr () { cat >> $RUNTIME_log_file; }
51RUNTIME_log_stdout () {
52    if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
53        ./scripts/pretty_print_stacks.py $1 >> $RUNTIME_log_file
54    else
55        cat >> $RUNTIME_log_file
56    fi
57}
58
59function run_task()
60{
61	local testname="$1"
62
63	RUNTIME_log_file="${unittest_log_dir}/${testname}.log"
64	run "$@"
65}
66
67: ${unittest_log_dir:=logs}
68config=$TEST_DIR/unittests.cfg
69
70rm -rf $unittest_log_dir.old
71[ -d $unittest_log_dir ] && mv $unittest_log_dir $unittest_log_dir.old
72mkdir $unittest_log_dir || exit 2
73
74echo "BUILD_HEAD=$(cat build-head)" > $unittest_log_dir/SUMMARY
75
76for_each_unittest $config run_task
77