summaryrefslogtreecommitdiff
path: root/test/timed
blob: 3ff76ee7663c8a8d2aaabdc3e57d872a76e1f84c (plain)
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
#!/bin/bash

# Default to all .d direcories.
DIRS=$(find -type d -name '*.d' | sort)

CORES=$(awk '/cpu cores/ { print $4; exit }'  /proc/cpuinfo)

if ! echo $CORES | grep -q '^[1-9][0-9]\?$'; then
	echo "warning: could not determine number of cores, using 2"
	CORES=2
fi

HERE=$(basename $(pwd))
if [ "${HERE%.d}" != "$HERE" ]; then
	# In a test directory. Set DIR to . and pass any arguments to the local
	# gentests.
	DIRS=.
	ARGS="$@"
elif [ $# != 0 ]; then
	# Args on the command line, but not in .d. Assume they are test cases.
	DIRS=$(find "$@" -type d -name '*.d')
fi

GENTEST_LOG=`mktemp /tmp/gentest.XXXXXX`

for D in $DIRS; do
	cd $D
	echo ---- in $D
	./gentests $ARGS 2>> $GENTEST_LOG | xargs -n1 -P$CORES bash
	WORKING="$WORKING $D/working"
	cd $OLDPWD
done

echo ---- cases
find $WORKING -name '*.sh' -not -size 0 | wc -l

echo ---- failures
find $WORKING -name '*.diff' -not -size 0 | wc -l

if [ -s $GENTEST_LOG ]; then
	echo ---- errors
	cat $GENTEST_LOG
fi

rm $GENTEST_LOG