-
Notifications
You must be signed in to change notification settings - Fork 120
/
run_all_tests.sh
executable file
·118 lines (106 loc) · 2.85 KB
/
run_all_tests.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
if [ X$1 != X ]
then
CCTOOLS_PACKAGES_TEST=$1
fi
if [ ! -r config.mk ]; then
echo "Please run ./configure && make before executing the test script"
exit 1
fi
if [ -z "$CCTOOLS_PACKAGES_TEST" ]
then
CCTOOLS_PACKAGES_TEST=$(grep CCTOOLS_PACKAGES config.mk | cut -d = -f 2)
if [ -n "${CCTOOLS_DOCKER_GITHUB}" ]
then
if ! parrot/src/parrot_run /bin/ls > /dev/null 2>&1
then
echo "Skipping parrot tests inside docker build."
export PARROT_SKIP_TEST=yes
fi
fi
fi
if [ -z "$CCTOOLS_TEST_LOG" ]; then
CCTOOLS_TEST_LOG="./cctools.test.log"
fi
#absolute path?
if [ -z "$(echo $CCTOOLS_TEST_LOG | sed -n 's:^/.*$:x:p')" ]; then
CCTOOLS_TEST_LOG="$(pwd)/${CCTOOLS_TEST_LOG}"
fi
export CCTOOLS_TEST_LOG
export CCTOOLS_TEST_FAIL=${CCTOOLS_TEST_LOG%.log}.fail
export CCTOOLS_TEST_TMP=${CCTOOLS_TEST_LOG%.log}.tmp
echo "[$(date)] Testing on $(uname -a)." > "$CCTOOLS_TEST_LOG"
rm -f "${CCTOOLS_TEST_FAIL}"
# we need resource_monitor in the path.
PATH="$(pwd)/resource_monitor/src:$PATH"
export PATH
SUCCESS=0
FAILURE=0
SKIP=0
START_TIME=$(date +%s)
for package in ${CCTOOLS_PACKAGES_TEST}; do
if [ -d "${package}/test" ]; then
cd "./${package}/test"
for script in TR_*; do
if [ -x "$script" ]; then
printf "%-66s" "--- Testing ${package}/test/${script} ... "
TEST_START_TIME=$(date +%s)
(
"./${script}" check_needed
) >> "$CCTOOLS_TEST_LOG" 2>&1
result=$?
if [ "$result" -ne 0 ]; then
skip=1
else
skip=0
(
echo "======== ${script} PREPARE ========"
"./${script}" prepare
result=$?
if [ $result = 0 ]; then
echo "======== ${script} RUN ========"
"./${script}" run
result=$?
fi
echo "======== ${script} CLEAN ========"
"./${script}" clean
exit $result
) > "$CCTOOLS_TEST_TMP" 2>&1
result=$?
cat "$CCTOOLS_TEST_TMP" >> "$CCTOOLS_TEST_LOG"
if [ "$result" -ne 0 ]; then
cat "$CCTOOLS_TEST_TMP" >> "$CCTOOLS_TEST_FAIL"
fi
fi
TEST_STOP_TIME=$(date +%s)
TEST_ELAPSED=$(($TEST_STOP_TIME-$TEST_START_TIME))
if [ "$skip" -eq 1 ]; then
SKIP=$((SKIP+1))
echo "skipped ${TEST_ELAPSED}s"
echo "=== Test ${package}/test/${script}: skipped." >> $CCTOOLS_TEST_LOG
elif [ "$result" -eq 0 ]; then
SUCCESS=$((SUCCESS+1))
echo "success ${TEST_ELAPSED}s"
echo "=== Test ${package}/test/${script}: success." >> $CCTOOLS_TEST_LOG
else
FAILURE=$((FAILURE+1))
echo "failure ${TEST_ELAPSED}s"
echo "=== Test ${package}/test/${script}: failure." >> $CCTOOLS_TEST_LOG
fi
fi
done
cd ../..
fi
done
STOP_TIME=$(date +%s)
TOTAL=$((SUCCESS+FAILURE-SKIP))
ELAPSED=$((STOP_TIME-START_TIME))
echo ""
echo "Test Results: ${FAILURE} of ${TOTAL} tests failed (${SKIP} skipped) in ${ELAPSED} seconds."
echo ""
if [ "$FAILURE" -eq 0 ]; then
exit 0
else
exit 1
fi
# vim: set noexpandtab tabstop=4: