-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-all.sh
executable file
·82 lines (74 loc) · 1.99 KB
/
test-all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# Usage: [NAME=VAUE ...] ./test-all.sh [OPTIONS-PASSED-TO-TESTS]
#
# Environment variables:
# - LOG: Path to the log file. ${SCRIPT_DIR}/test-all.log is the default.
#
# - SKIP_PAPI: set to non-empty string (e.g. 'y') to skip tests that use PAPI.
# - FAIL_FAST: set to non-empty string (e.g. 'y') to fail immediately if a test
# failed.
#
# Examples:
# ```sh
# #### pass `--prefix /opt/ovis` to all test scripts, and stop the batch test
# #### immediately if a test failed
# $ LOG=test.log FAIL_FAST=y ./test-all.sh --prefix /opt/ovis
# ```
SCRIPT_DIR=$( dirname $0 )
LOG=${LOG:-${SCRIPT_DIR}/test-all.log}
echo "LOG: ${LOG}"
source ${SCRIPT_DIR}/test-list.sh
# This defines DIRECT_TEST_LIST, CONT_TEST_LIST, PAPI_CONT_TEST_LIST
[[ -z "${SKIP_PAPI}" ]] && {
LIST=( ${PAPI_CONT_TEST_LIST[*]} ${CONT_TEST_LIST[*]} )
} || {
LIST=( ${CONT_TEST_LIST[*]} )
}
[[ -z "${FAIL_FAST}" ]] || set -e
{ # printing in this subshell will be logged
declare -A RCS
for T in ${LIST[*]}; do
echo "======== ${T} ========"
CMD="./${T} $@"
echo ${CMD}
${CMD}
RC=$?
RCS["$T"]=${RC}
echo "EXIT_CODE: ${RC}"
sleep 10 # allow some clean-up break between tests
echo "----------------------------------------------"
done
for T in ${INSIDE_CONT_TEST_LIST[*]}; do
echo "======== ${T} ========"
CMD="./run_inside_cont_test.py --suite ${T} $@"
echo ${CMD}
${CMD}
RC=$?
RCS["$T"]=${RC}
echo "EXIT_CODE: ${RC}"
sleep 10 # allow some clean-up break between tests
echo "----------------------------------------------"
done
export RED='\033[01;31m'
export GREEN='\033[01;32m'
export RESET='\033[0m'
echo "==== Summary ===="
N=${#RCS[*]}
PASSED=0
FAILED=0
for K in "${!RCS[@]}"; do
V=${RCS["$K"]}
if (( $V == 0 )); then
PASSED=$((PASSED+1))
V="${GREEN}PASSED${RESET}"
else
FAILED=$((FAILED+1))
V="${RED}FAILED${RESET}"
fi
echo -e "${K}: ${V}"
done
echo "------------------------------------------"
echo -e "Total tests passed: ${PASSED}/${N}"
echo "------------------------------------------"
} 2>&1 | tee ${LOG}