summaryrefslogtreecommitdiff
path: root/server/tools/test
blob: 922040db29030bb38046c800c6195eaf619d90e9 (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
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

TEST=`echo -n $1 | cut -d'.' -f1`
UPPER=`echo $TEST | tr 'a-z.' 'A-Z_'`
OUTPUT=test_$TEST
DEFINE=TEST_$UPPER

SCRIPTDIR=`dirname $0`

INFILE=$1
shift
OBJFILES=""
for f in $TEST_DEPS
do
    of=`basename $f | cut -d'.' -f1`.o;
    OBJFILES="$OBJFILES $of"
done

COMMON_FLAGS="-DHAVE_CONFIG_H -I$SCRIPTDIR -O0 -g -D$DEFINE $TEST_LIBS $TEST_CFLAGS"
CLEAN="rm -f $OBJFILES"
PRECOMPILE="g++ -c $TEST_DEPS $COMMON_FLAGS"
COMPILE="g++ -fprofile-arcs -ftest-coverage -fno-elide-constructors -Wall -Werror $COMMON_FLAGS -o $OUTPUT $INFILE $OBJFILES"

echo -e "\033[0;2mTesting $TEST:"
echo Testing $TEST: > $OUTPUT.log

echo -n "* Compiling $TEST test"
echo Compiling $TEST test: > $OUTPUT.log

echo ${CLEAN} >> $OUTPUT.log
${CLEAN} >> ${OUTPUT}.log 2>&1
echo ${PRECOMPILE} >> $OUTPUT.log
${PRECOMPILE} >> ${OUTPUT}.log 2>&1
echo ${COMPILE} >> $OUTPUT.log

if ${COMPILE} >> ${OUTPUT}.log 2>&1; then
	echo -e "\r\t\t\t\t\t\t[\033[1;32mSuccess\033[0;2m]"
	echo "[Success]" >> $OUTPUT.log

	echo -n "* Running   $TEST test"
	echo Running $TEST test: >> $OUTPUT.log
	if ./$OUTPUT >> $OUTPUT.log 2>&1; then
	        echo -e "\r\t\t\t\t\t\t[\033[1;32mSuccess\033[0;2m]"
		echo "[Success]" >> $OUTPUT.log
	else
		echo -e "\r\t\t\t\t\t\t[\033[1;31mFailure\033[0;2m]"
		echo "[Failure]" >> $OUTPUT.log
		rm -f $OUTPUT
	fi
else
	echo -e "\r\t\t\t\t\t\t[\033[1;31mFailure\033[0;2m]"
	echo "[Failure]" >> $OUTPUT.log
fi

echo