Initial import to Tizen
[profile/ivi/sphinxbase.git] / test / unit / testfuncs.sh.in
1 # Utility functions and parameters for regression tests
2
3 # Predefined directories you may need
4 # Stupid broken CMU Facilities autoconf doesn't do @abs_top_srcdir@
5 builddir=../"@top_builddir@"
6 sourcedir=../"@top_srcdir@"
7 tests=$sourcedir/test
8
9 # Automatically report failures on exit
10 failures=""
11 trap "report_failures" 0
12
13 run_program() {
14     program="$1"
15     shift
16     $builddir/libtool --mode=execute "$builddir/src/$program/$program" $@
17 }
18
19 pass() {
20     title="$1"
21     echo "$title PASSED"
22 }
23
24 fail() {
25     title="$1"
26     echo "$title FAILED"
27     failures="$failures,$title"
28 }
29
30 assert() {
31     title="$1"
32     shift
33     if $@ >/dev/null 2>&1; then
34         pass "$title"
35     else
36         fail "$title"
37     fi
38 }
39
40 compare_table() {
41     title="$1"
42     shift
43     if perl "$tests/compare_table.pl" $@ | grep SUCCESS >/dev/null 2>&1; then
44         pass "$title"
45     else
46         fail "$title"
47     fi 
48 }
49
50 report_failures() {
51     if test x"$failures" = x; then
52         echo "All sub-tests passed"
53         exit 0
54     else
55         echo "Sub-tests failed:$failures" | sed -e 's/,/\n/g'
56         exit 1
57     fi
58 }