-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun_tests.sh
executable file
·84 lines (74 loc) · 1.92 KB
/
run_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
#!/bin/sh
if ! which ffs >/dev/null 2>&1
then
DEBUG="$(pwd)/target/debug"
[ -x "$DEBUG/ffs" ] || {
echo Couldn\'t find ffs on "$PATH" or in "$DEBUG". >&2
echo Are you in the root directory of the repo? >&2
exit 1
}
PATH="$DEBUG:$PATH"
fi
if ! which unpack >/dev/null 2>&1
then
DEBUG="$(pwd)/target/debug"
[ -x "$DEBUG/unpack" ] || {
echo Couldn\'t find unpack on "$PATH" or in "$DEBUG". >&2
echo Are you in the root directory of the repo? >&2
exit 1
}
PATH="$DEBUG:$PATH"
fi
if ! which pack >/dev/null 2>&1
then
DEBUG="$(pwd)/target/debug"
[ -x "$DEBUG/pack" ] || {
echo Couldn\'t find pack on "$PATH" or in "$DEBUG". >&2
echo Are you in the root directory of the repo? >&2
exit 1
}
PATH="$DEBUG:$PATH"
fi
TOTAL=0
FAILED=0
ERRORS=""
cd tests
LOG=$(mktemp -d)
TESTS="$(find . -name "$1*.sh")"
# spawn 'em all in parallel
for test in $TESTS
do
tname="$(basename ${test%*.sh})"
printf "========== STARTING TEST: $tname\n"
(RUST_LOG="ffs=debug,unpack=debug,pack=debug,fuser=debug"; export RUST_LOG; ./${test} >$LOG/$tname.out 2>$LOG/$tname.err; echo $?>$LOG/$tname.ec) &
: $((TOTAL += 1))
# don't slam 'em
if [ $((TOTAL % 4)) -eq 0 ]
then
wait %-
fi
done
wait
for test in $TESTS
do
tname="$(basename ${test%*.sh})"
if [ "$(cat $LOG/$tname.ec)" -eq 0 ]
then
printf "========== PASSED: $tname\n"
else
printf "========== FAILED: $tname (ec=$(cat $LOG/$tname.ec))\n"
: $((FAILED += 1))
fi
# just always capture output in the CI logs
if [ "$(cat $LOG/$tname.ec)" -ne 0 ] || [ "$CI" ]
then
printf "<<<<<<<<<< STDOUT\n"
cat $LOG/$tname.out
printf "<<<<<<<<<< STDERR\n"
cat $LOG/$tname.err
printf "\n"
fi
done
printf "$((TOTAL - FAILED))/$((TOTAL)) tests passed\n"
rm -r $LOG
[ $FAILED -eq 0 ] || exit 1