aboutsummaryrefslogtreecommitdiff
path: root/tests/runtests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runtests.sh')
-rwxr-xr-xtests/runtests.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/runtests.sh b/tests/runtests.sh
new file mode 100755
index 0000000..0de79d8
--- /dev/null
+++ b/tests/runtests.sh
@@ -0,0 +1,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 ""