-
Notifications
You must be signed in to change notification settings - Fork 38
/
regression-test-all.sh
executable file
·143 lines (123 loc) · 4.34 KB
/
regression-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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
export LANG=C # to ensure sort is not fucked up by stupid POSIX standards
if [ "$RUNNING_UNDER_TIME" != true ]; then
export RUNNING_UNDER_TIME=true
#echo "restarting with timing" >&2
exec time $0 "$@"
fi
case "$1" in
-use-git-at)
if [ -f git-at ] && [ `wc -l < git-at` -eq 2 -a `git log -1 --format=%at` -eq `tail -1 git-at` ]; then
echo -n "Repo unchanged; returning same status code as "
tail -1 git-at | xargs -I{} date -d @{} +%Y-%m-%d-%H:%M:%S
exit `head -1 git-at`
fi
shift
;;
esac
USAGE="USAGE: $0 [ -make ] [ -x BLANT_EXE ][ list of tests to run, defaults to regression-tests/*/*.sh ]"
# Bash Functions
die(){ (echo "$USAGE"; echo "FATAL ERROR: $@")>&2; exit 1; }
warn(){ (echo "WARNING: $@")>&2; }
not(){ if eval "$@"; then return 1; else return 0; fi; }
newlines(){ awk '{for(i=1; i<=NF;i++)print $i}' "$@"; }
parse(){ awk "BEGIN{print $@}" </dev/null; }
cpus() {
TMP=/tmp/cpus.$$
trap "/bin/rm -f $TMP; exit" 0 1 2 3 15
# Most Linux machines:
lscpu >$TMP 2>/dev/null && awk '/^CPU[(s)]*:/{cpus=$NF}END{if(cpus)print cpus; else exit 1}' $TMP && return
# MacOS:
(uname -a | egrep 'Darwin|arm64' >/dev/null) && sysctl -n hw.ncpu && return
# Cygwin:
case "`uname -a`" in
*CYGWIN*) grep -c '^processor[ ]*:' /proc/cpuinfo; return ;;
*) if [ -d /dev/cpu -a ! -f /dev/cpu/microcode ]; then
ls -F /dev/cpu | fgrep -c
return
fi
;;
esac
# Oops
echo "couldn't figure out number of CPUs" >&2; exit 1
}
BLANT_HOME=`/bin/pwd`
LIBWAYNE_HOME="$BLANT_HOME/libwayne"
PATH="$BLANT_HOME:$BLANT_HOME/scripts:$BLANT_HOME/libwayne/bin:$PATH"
export PATH BLANT_HOME LIBWAYNE_HOME
if [ ! -f libwayne/Makefile ]; then
echo "you need the submodule libwayne; trying to get it now" >&2
(git submodule init libwayne && git submodule update libwayne && cd libwayne && git checkout master && git pull) || die "failed to get libwayne"
[ -f libwayne/Makefile ] || die "Still can't find libwayne"
fi
EXE=$BLANT_HOME/blant
MAKE=false
while [ $# -gt -0 ]; do
case "$1" in
-make) MAKE=true; shift;;
-x) EXE="$2"; shift 2;;
-*) die "unknown option '$1";;
*) break;;
esac
done
[ -x "$EXE" -o "$MAKE" = true ] || die "Executable '$EXE' must exist or you must specify -make"
CORES=${CORES:=1} # cores =1 for now since I broke threading. :-(
#CORES=${CORES:=`cpus 2>/dev/null | awk '{c2=int($1/2); if(c2>0)print c2; else print 1}'`}
[ "$CORES" -gt 0 ] || die "can't figure out how many cores this machine has"
MAKE_CORES=1 # for BLANT, we don't want or need paralellism during make
WHAT=most
if $MAKE ; then
make pristine
WHAT=all
#WHAT='"DEBUG=1" all'
fi
export EIGHT=8
if [ "$CI" = true ]; then # continuous integration needs to run faster
echo '$CI'" variable is '$CI', so assuming we are doing continuous integration" >&2
unset EIGHT
export NO8=1
export PAUSE=0
else
: #echo '$CI'" = '$CI'; NOT doing continuous integration" >&2
fi
echo "Using $MAKE_CORES cores to make and $CORES cores for regression tests"
export EXE CORES MAKE_CORES
if [ "$NO8" != "" ]; then unset EIGHT; fi
make -j$MAKE_CORES $WHAT || die "failed to make"
# The gzip below is now done in the Makefile
#F=canon_maps/canon_map8.txt; [ -f $F ] && nice -19 gzip -9 $F &
[ -x "$EXE" ] || die "no executable '$EXE' exists to test!"
NUM_FAILS=0
STDBUF=''
if which stdbuf >/dev/null; then
STDBUF='stdbuf -oL -eL'
fi
if [ $# -eq 0 ]; then
set regression-tests/*/*.sh
fi
for r
do
REG_DIR=`dirname "$r"`
NEW_FAILS=0
export REG_DIR
echo --- running test $r ---
if eval time $STDBUF "$r"; then # force output and error to be line buffered
:
else
NEW_FAILS=$?
(( NUM_FAILS+=$NEW_FAILS ))
if echo "$r" | grep sanity; then
echo ""
echo "***********************************************************************************************"
echo "****** This test really needs to work... stopping early... please contact [email protected]"
echo "****** Please provide a screenshot of the above (or cut-and-paste into the message)"
echo "***********************************************************************************************"
echo ""
break
fi
fi
echo --- test $r incurred $NEW_FAILS failures, cumulative failures is $NUM_FAILS ---
done
echo Total number of failures: $NUM_FAILS
(echo $NUM_FAILS; git log -1 --format=%at) > git-at
exit $NUM_FAILS