aboutsummaryrefslogtreecommitdiff
path: root/tests/runtests.sh
blob: 0de79d8783531e3a3df57b70b494d78454159a8e (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
#!/bin/bash

echo -e "\033[95mRunning unit tests:\033[0m"

for i in bin/test_*
do
	if test -f $i
	then
		if $VALGRIND ./$i 2>> ./tests.log
		then
			echo $i PASS
		else
			echo "ERROR in test $i: here's ./tests.log"
			echo "------"
			tail ./tests.log
			exit 1
		fi
		if [ ! -z "$VALGRIND" ]
		then
			for log in `ls /tmp/valgrind-*.log`;
			do
				cmdstr=$(head -n 4 $log | tail -n 1)
				if [[ $cmdstr == *"$i"* ]]
				then
					tailstr=$(tail -n 1 $log)
					if [[ $tailstr == *"0 errors from 0 contexts"* ]]
					then
						echo -e "\033[92mVALGRIND GOOD\033[0m"
					else
						echo -e "\033[91mVALGRIND BAD\033[0m"
					fi
				fi
			done
		fi
	fi
done

echo ""