* sysdeps/m68k/fpu/libm-test-ulps: Update.
[glibc.git] / iconvdata / run-iconv-test.sh
blob0d307a3d95d5606b92a05af7f4e112463dcb1c3f
1 #! /bin/sh -f
2 # Run available iconv(1) tests.
3 # Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5 # Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
7 # The GNU C Library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Library General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # The GNU C Library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Library General Public License for more details.
17 # You should have received a copy of the GNU Library General Public
18 # License along with the GNU C Library; see the file COPYING.LIB. If not,
19 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 # Boston, MA 02111-1307, USA.
22 codir=$1
24 # We use always the same temporary file.
25 temp1=$codir/iconvdata/iconv-test.xxx
26 temp2=$codir/iconvdata/iconv-test.yyy
28 trap "rm -f $temp1 $temp2" 1 2 3 15
30 # We must tell the iconv(1) program where the modules we want to use can
31 # be found.
32 GCONV_PATH=$codir/iconvdata
33 export GCONV_PATH
35 # We have to have some directories in the library path.
36 LIBPATH=$codir:$codir/iconvdata
38 # How the start the iconv(1) program.
39 ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
40 $codir/iconv/iconv_prog'
42 # Which echo?
43 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
44 ac_n=-n ac_c= ac_t=
45 else
46 ac_n= ac_c='\c' ac_t=
49 # We read the file named TESTS. All non-empty lines not starting with
50 # `#' are interpreted as commands.
51 failed=0
52 while read from to subset targets; do
53 # Ignore empty and comment lines.
54 if test -z "$subset" || test "$from" = '#'; then continue; fi
56 # Expand the variables now.
57 PROG=`eval echo $ICONV`
59 if test -n "$targets"; then
60 for t in $targets; do
61 if test -f testdata/$from; then
62 echo $ac_n " test data: $from -> $t $ac_c"
63 $PROG -f $from -t $t testdata/$from > $temp1 ||
64 { if test $? -gt 128; then exit 1; fi
65 echo "FAILED"; failed=1; continue; }
66 echo $ac_n "OK$ac_c"
67 if test -s testdata/$from..$t; then
68 cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
69 { echo "/FAILED"; failed=1; continue; }
70 echo $ac_n "/OK$ac_c"
72 echo $ac_n " -> $from $ac_c"
73 $PROG -f $t -t $to -o $temp2 $temp1 ||
74 { if test $? -gt 128; then exit 1; fi
75 echo "FAILED"; failed=1; continue; }
76 echo $ac_n "OK$ac_c"
77 test -s $temp1 && cmp testdata/$from $temp2 > /dev/null 2>&1 ||
78 { echo "/FAILED"; failed=1; continue; }
79 echo "/OK"
80 rm -f $temp1 $temp2
83 # Now test some bigger text, entirely in ASCII. If ASCII is no subset
84 # of the coded character set we convert the text to this coded character
85 # set. Otherwise we convert to all the TARGETS.
86 if test $subset = Y; then
87 echo $ac_n " suntzu: $from -> $t -> $to $ac_c"
88 $PROG -f $from -t $t testdata/suntzus |
89 $PROG -f $t -t $to > $temp1 ||
90 { if test $? -gt 128; then exit 1; fi
91 echo "FAILED"; failed=1; continue; }
92 echo $ac_n "OK$ac_c"
93 cmp testdata/suntzus $temp1 ||
94 { echo "/FAILED"; failed=1; continue; }
95 echo "/OK"
97 rm -f $temp1
99 # And tests where iconv(1) has to handle charmaps.
100 if test "$t" = UTF8; then tc=UTF-8; else tc="$t"; fi
101 if test -f ../localedata/charmaps/$from &&
102 test -f ../localedata/charmaps/$tc &&
103 test -f testdata/$from; then
104 echo $ac_n "test charmap: $from -> $t $ac_c"
105 $PROG -f ../localedata/charmaps/$from -t ../localedata/charmaps/$tc \
106 testdata/$from > $temp1 ||
107 { if test $? -gt 128; then exit 1; fi
108 echo "FAILED"; failed=1; continue; }
109 echo $ac_n "OK$ac_c"
110 if test -s testdata/$from..$t; then
111 cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
112 { echo "/FAILED"; failed=1; continue; }
113 echo $ac_n "/OK$ac_c"
115 echo $ac_n " -> $from $ac_c"
116 $PROG -t ../localedata/charmaps/$from -f ../localedata/charmaps/$tc \
117 -o $temp2 $temp1 ||
118 { if test $? -gt 128; then exit 1; fi
119 echo "FAILED"; failed=1; continue; }
120 echo $ac_n "OK$ac_c"
121 test -s $temp1 && cmp testdata/$from $temp2 > /dev/null 2>&1 ||
122 { echo "/FAILED"; failed=1; continue; }
123 echo "/OK"
124 rm -f $temp1 $temp2
126 done
129 if test "$subset" != Y; then
130 echo $ac_n " suntzu: ASCII -> $to -> ASCII $ac_c"
131 $PROG -f ASCII -t $to testdata/suntzus |
132 $PROG -f $to -t ASCII > $temp1 ||
133 { if test $? -gt 128; then exit 1; fi
134 echo "FAILED"; failed=1; continue; }
135 echo $ac_n "OK$ac_c"
136 cmp testdata/suntzus $temp1 ||
137 { echo "/FAILED"; failed=1; continue; }
138 echo "/OK"
140 done < TESTS
142 # We read the file named TESTS2. All non-empty lines not starting with
143 # `#' are interpreted as commands.
144 while read utf8 from filename; do
145 # Ignore empty and comment lines.
146 if test -z "$filename" || test "$utf8" = '#'; then continue; fi
148 # Expand the variables now.
149 PROG=`eval echo $ICONV`
151 # Test conversion to the endianness dependent encoding.
152 echo $ac_n "test encoder: $utf8 -> $from $ac_c"
153 $PROG -f $utf8 -t $from < testdata/${filename}..${utf8} > $temp1
154 cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
155 cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
156 { echo "/FAILED"; failed=1; continue; }
157 echo "OK"
159 # Test conversion from the endianness dependent encoding.
160 echo $ac_n "test decoder: $from -> $utf8 $ac_c"
161 $PROG -f $from -t $utf8 < testdata/${filename}..${from}.BE > $temp1
162 cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
163 { echo "/FAILED"; failed=1; continue; }
164 $PROG -f $from -t $utf8 < testdata/${filename}..${from}.LE > $temp1
165 cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
166 { echo "/FAILED"; failed=1; continue; }
167 echo "OK"
169 # Test byte swapping behaviour.
170 echo $ac_n "test non-BOM: ${from}BE -> ${from}LE $ac_c"
171 $PROG -f ${from}BE -t ${from}LE < testdata/${filename}..${from}.BE > $temp1
172 cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
173 { echo "/FAILED"; failed=1; continue; }
174 echo "OK"
176 # Test byte swapping behaviour.
177 echo $ac_n "test non-BOM: ${from}LE -> ${from}BE $ac_c"
178 $PROG -f ${from}LE -t ${from}BE < testdata/${filename}..${from}.LE > $temp1
179 cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
180 { echo "/FAILED"; failed=1; continue; }
181 echo "OK"
183 done < TESTS2
185 exit $failed
186 # Local Variables:
187 # mode:shell-script
188 # End: