version up to 1.0.5
[platform/upstream/fribidi.git] / test / run.tests
1 #! /bin/sh
2 # run.tests - Check that the algorithm does what it is supposed to
3 # Copyright (C) 1999,2000 Dov Grobgeld, and
4 # Copyright (C) 2001,2002 Behdad Esfahbod.
5
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public  
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10
11 # This library is distributed in the hope that it will be useful,  
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of   
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15
16 # You should have received a copy of the GNU Lesser General Public License  
17 # along with this library, in a file named COPYING; if not, write to the
18 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA
20
21 # For licensing issues, contact <fribidi.license@gmail.com>.
22
23 if test -z "$top_builddir"; then
24   top_builddir=..
25 fi
26
27 if test -z "$srcdir"; then
28   srcdir=`echo "$0" | sed 's,/[^/]*$,,'`
29 fi
30
31 test "${VERBOSE+set}" != "set" && VERBOSE=yes
32
33 # See how redirections should work.
34 if test -z "$VERBOSE"; then
35    exec > /dev/null 2>&1
36 fi
37
38 if ! test -f "$top_builddir/bin/fribidi$EXEEXT"; then
39   echo "run.tests: you must make fribidi first"
40   exit 1
41 fi
42
43 TEST () {
44   testcase="$1"
45   test="${testcase##*/}"
46   test="${test%.input}"
47   charset="${testcase#*_}"
48   charset="${charset%%_*}"
49   echo -n "=== $test === "
50   if ! "$top_builddir/bin/fribidi$EXEEXT" --charset "$charset" </dev/null >/dev/null 2>&1; then
51     echo " [Character set not supported]"
52     return 0
53   fi
54   "$top_builddir/bin/fribidi$EXEEXT" --test --charset "$charset" "$testcase" > "$test.output"
55
56   reference="${testcase%.input}.reference";
57   test -f "$reference" || reference="tests/${reference##*/}"
58   if diff -U 0 "$test.output" "$reference"; then
59     rm "$test.output"
60     echo " [Passed]"
61     return 0
62   else
63     echo " [Failed]"
64     return 1
65   fi
66 }
67
68 retval=0
69 for testcase in "$srcdir"/test_*.input; do
70   TEST "$testcase" || retval=1
71 done
72
73 exit $retval