Imported Upstream version 0.19.7
[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 <dov.grobgeld@gmail.com> and
22 # <fwpg@sharif.edu>.
23
24 if test -z "$top_builddir"; then
25   top_builddir=..
26 fi
27
28 if test -z "$srcdir"; then
29   srcdir=`echo "$0" | sed 's,/[^/]*$,,'`
30 fi
31
32 test "${VERBOSE+set}" != "set" && VERBOSE=yes
33
34 # See how redirections should work.
35 if test -z "$VERBOSE"; then
36    exec > /dev/null 2>&1
37 fi
38
39 if ! test -f "$top_builddir/bin/fribidi$EXEEXT"; then
40   echo "run.tests: you must make fribidi first"
41   exit 1
42 fi
43
44 TEST () {
45   testcase="$1"
46   test="${testcase##*/}"
47   test="${test%.input}"
48   charset="${testcase#*_}"
49   charset="${charset%%_*}"
50   echo -n "=== $test === "
51   if ! "$top_builddir/bin/fribidi$EXEEXT" --charset "$charset" </dev/null >/dev/null 2>&1; then
52     echo " [Character set not supported]"
53     return 0
54   fi
55   "$top_builddir/bin/fribidi$EXEEXT" --test --charset "$charset" "$testcase" > "$test.output"
56
57   reference="${testcase%.input}.reference";
58   test -f "$reference" || reference="tests/${reference##*/}"
59   if diff -U 0 "$test.output" "$reference"; then
60     rm "$test.output"
61     echo " [Passed]"
62     return 0
63   else
64     echo " [Failed]"
65     return 1
66   fi
67 }
68
69 retval=0
70 for testcase in "$srcdir"/test_*.input; do
71   TEST "$testcase" || retval=1
72 done
73
74 exit $retval