Imported Upstream version 1.4.6
[platform/upstream/harfbuzz.git] / test / shaping / run-tests.sh
1 #!/bin/sh
2
3 test "x$srcdir" = x && srcdir=.
4 test "x$builddir" = x && builddir=.
5 test "x$top_builddir" = x && top_builddir=../..
6
7 hb_shape=$top_builddir/util/hb-shape$EXEEXT
8
9 fails=0
10
11 reference=false
12 if test "x$1" = x--reference; then
13         reference=true
14         shift
15 fi
16
17 if test $# = 0; then
18         set /dev/stdin
19 fi
20
21 for f in "$@"; do
22         $reference || echo "Running tests in $f"
23         while IFS=: read fontfile options unicodes glyphs_expected; do
24                 if echo "$fontfile" | grep -q '^#'; then
25                         $reference || echo "Skipping $fontfile:$unicodes"
26                         continue
27                 fi
28                 $reference || echo "Testing $fontfile:$unicodes"
29                 glyphs=`$srcdir/hb-unicode-encode "$unicodes" | $hb_shape $options "$srcdir/$fontfile"`
30                 if test $? != 0; then
31                         echo "hb-shape failed." >&2
32                         fails=$((fails+1))
33                         continue
34                 fi
35                 if $reference; then
36                         echo "$fontfile:$options:$unicodes:$glyphs"
37                         continue
38                 fi
39                 if ! test "x$glyphs" = "x$glyphs_expected"; then
40                         echo "Actual:   $glyphs" >&2
41                         echo "Expected: $glyphs_expected" >&2
42                         fails=$((fails+1))
43                 fi
44         done < "$f"
45 done
46
47 if test $fails != 0; then
48         $reference || echo "$fails tests failed."
49         exit 1
50 else
51         $reference || echo "All tests passed."
52 fi