cleanup
[mala.git] / tests / test.sh
blobde4f35138da61addc9baaf25d4b1a23503d21804
1 #!/bin/sh
2 # Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
4 # This file is part of the MaLa extension Language.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, contact me.
18 arg0="$0"
19 srcdir=$(dirname "$arg0")
21 ulimit -St 1
22 valgrind=""
23 if [ "$VALGRINDFLAGS" = 'DISABLE' ]; then
24 echo "valgrind explicit disabled"
25 else
26 if [ "$(which valgrind)" ]; then
27 valgrind="$(which valgrind) --tool=addrcheck --leak-check=yes -q $VALGRINDFLAGS"
28 ulimit -St 10
29 else
30 echo "no valgrind found, go without it"
34 echo
35 echo ================ $0 ================
37 TESTCNT=0
38 SKIPCNT=0
39 FAILCNT=0
41 date >,testlog
43 function TEST()
45 cat >,cmp
46 echo -n "" >,out
47 echo -n "TEST $1: "
48 echo -en "\nTEST $* " >>,testlog
49 shift
50 if $valgrind $TESTBIN "$@" 2>&1 | tee ,tmp | grep -v 'DEBUG:' | cmp ,cmp - &>/dev/null; then
51 echo ".. OK"
52 echo ".. OK" >>,testlog
53 else
54 echo ".. FAILED";
55 echo ".. FAILED" >>,testlog
56 grep -v 'DEBUG:' <,tmp >,out
57 diff -ua ,cmp ,out >>,testlog
58 # grep 'DEBUG:\|==.*==' <,tmp >>,testlog
59 cat ,tmp >>,testlog
60 echo END >>,testlog
61 FAILCNT=$(($FAILCNT + 1))
63 TESTCNT=$(($TESTCNT + 1))
66 function PLANNED()
68 echo -n "PLANNED $1: "
69 echo -en "\nPLANNED $* " >>,testlog
70 echo ".. SKIPPED"
71 echo ".. SKIPPED" >>,testlog
72 SKIPCNT=$(($SKIPCNT + 1))
73 TESTCNT=$(($TESTCNT + 1))
76 function TESTSUMMARY()
78 rm ,cmp ,out ,tmp
79 if [ $FAILCNT = 0 ]; then
80 echo " ... PASSED $(($TESTCNT - $SKIPCNT)) TESTS, $SKIPCNT SKIPPED"
81 #rm ,testlog
82 else
83 echo " ... SUCCEDED $(($TESTCNT - $FAILCNT - $SKIPCNT)) TESTS"
84 echo " ... FAILED $FAILCNT TESTS"
85 echo " ... SKIPPED $SKIPCNT TESTS"
86 echo " see ',testlog' for details"
87 exit 1
91 echo
92 echo "string library tests:"
93 TESTBIN=./test-mala_strings
94 source $srcdir/mala_strings.test
96 echo
97 echo "basic startup tests:"
98 TESTBIN=./test-mala_stdmodule
99 source ../../../tests/basic_tests
101 echo
102 echo "plain engine/expansion tests:"
103 TESTBIN=./test-mala_stdmodule
104 source ../../../tests/expansion_tests
106 echo
107 echo "stdmodule tests:"
108 TESTBIN=./test-mala_stdmodule
109 source ../../../tests/stdmodule_tests
111 #echo
112 #echo "arithmodule tests:"
113 #TESTBIN=./test-mala_arithmodule
114 #source ../../../tests/arithmodule_tests
116 TESTSUMMARY
118 # arch-tag: f4d06a47-6e17-40de-bba8-17240ae3f435