Add 16922 to list of bugs fixed.
[glibc.git] / iconvdata / run-iconv-test.sh
blobe23f60d4425b84f3410bf5ce5154887ba735a649
1 #! /bin/sh -f
2 # Run available iconv(1) tests.
3 # Copyright (C) 1998-2014 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 Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the 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 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with the GNU C Library; if not, see
19 # <http://www.gnu.org/licenses/>.
21 set -e
23 codir=$1
24 test_wrapper="$2"
26 # We use always the same temporary file.
27 temp1=$codir/iconvdata/iconv-test.xxx
28 temp2=$codir/iconvdata/iconv-test.yyy
30 trap "rm -f $temp1 $temp2" 1 2 3 15
32 # We must tell the iconv(1) program where the modules we want to use can
33 # be found.
34 GCONV_PATH=$codir/iconvdata
35 export GCONV_PATH
37 # We have to have some directories in the library path.
38 LIBPATH=$codir:$codir/iconvdata
40 # How the start the iconv(1) program.
41 ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
42 $codir/iconv/iconv_prog'
43 ICONV="$test_wrapper $ICONV"
45 # Which echo?
46 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
47 ac_n=-n ac_c= ac_t=
48 else
49 ac_n= ac_c='\c' ac_t=
52 # We read the file named TESTS. All non-empty lines not starting with
53 # `#' are interpreted as commands.
54 failed=0
55 while read from to subset targets; do
56 # Ignore empty and comment lines.
57 if test -z "$subset" || test "$from" = '#'; then continue; fi
59 # Expand the variables now.
60 PROG=`eval echo $ICONV`
62 if test -n "$targets"; then
63 for t in $targets; do
64 if test -f testdata/$from; then
65 echo $ac_n " test data: $from -> $t $ac_c"
66 $PROG -f $from -t $t testdata/$from < /dev/null > $temp1 ||
67 { if test $? -gt 128; then exit 1; fi
68 echo "FAILED"; failed=1; continue; }
69 echo $ac_n "OK$ac_c"
70 if test -s testdata/$from..$t; then
71 LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
72 { echo "/FAILED"; failed=1; continue; }
73 echo $ac_n "/OK$ac_c"
75 echo $ac_n " -> $from $ac_c"
76 $PROG -f $t -t $to -o $temp2 $temp1 < /dev/null ||
77 { if test $? -gt 128; then exit 1; fi
78 echo "FAILED"; failed=1; continue; }
79 echo $ac_n "OK$ac_c"
80 test -s $temp1 &&
81 LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 ||
82 { echo "/FAILED"; failed=1; continue; }
83 echo "/OK"
84 rm -f $temp1 $temp2
87 # Now test some bigger text, entirely in ASCII. If ASCII is no subset
88 # of the coded character set we convert the text to this coded character
89 # set. Otherwise we convert to all the TARGETS.
90 if test $subset = Y; then
91 echo $ac_n " suntzu: $from -> $t -> $to $ac_c"
92 $PROG -f $from -t $t testdata/suntzus < /dev/null |
93 $PROG -f $t -t $to > $temp1 ||
94 { if test $? -gt 128; then exit 1; fi
95 echo "FAILED"; failed=1; continue; }
96 echo $ac_n "OK$ac_c"
97 LC_ALL=C cmp testdata/suntzus $temp1 ||
98 { echo "/FAILED"; failed=1; continue; }
99 echo "/OK"
101 rm -f $temp1
103 # And tests where iconv(1) has to handle charmaps.
104 if test "$t" = UTF8; then tc=UTF-8; else tc="$t"; fi
105 if test -f ../localedata/charmaps/$from &&
106 test -f ../localedata/charmaps/$tc &&
107 test -f testdata/$from &&
108 ! grep '<U....><U....>' ../localedata/charmaps/$from > /dev/null; then
109 echo $ac_n "test charmap: $from -> $t $ac_c"
110 $PROG -f ../localedata/charmaps/$from -t ../localedata/charmaps/$tc \
111 testdata/$from < /dev/null > $temp1 ||
112 { if test $? -gt 128; then exit 1; fi
113 echo "FAILED"; failed=1; continue; }
114 echo $ac_n "OK$ac_c"
115 if test -s testdata/$from..$t; then
116 LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
117 { echo "/FAILED"; failed=1; continue; }
118 echo $ac_n "/OK$ac_c"
120 echo $ac_n " -> $from $ac_c"
121 $PROG -t ../localedata/charmaps/$from -f ../localedata/charmaps/$tc \
122 -o $temp2 $temp1 < /dev/null ||
123 { if test $? -gt 128; then exit 1; fi
124 echo "FAILED"; failed=1; continue; }
125 echo $ac_n "OK$ac_c"
126 test -s $temp1 &&
127 LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 ||
128 { echo "/FAILED"; failed=1; continue; }
129 echo "/OK"
130 rm -f $temp1 $temp2
132 done
135 if test "$subset" = N; then
136 echo $ac_n " suntzu: ASCII -> $to -> ASCII $ac_c"
137 $PROG -f ASCII -t $to testdata/suntzus < /dev/null |
138 $PROG -f $to -t ASCII > $temp1 ||
139 { if test $? -gt 128; then exit 1; fi
140 echo "FAILED"; failed=1; continue; }
141 echo $ac_n "OK$ac_c"
142 LC_ALL=C cmp testdata/suntzus $temp1 ||
143 { echo "/FAILED"; failed=1; continue; }
144 echo "/OK"
146 done < TESTS
148 # We read the file named TESTS2. All non-empty lines not starting with
149 # `#' are interpreted as commands.
150 while read utf8 from filename; do
151 # Ignore empty and comment lines.
152 if test -z "$filename" || test "$utf8" = '#'; then continue; fi
154 # Expand the variables now.
155 PROG=`eval echo $ICONV`
157 # Test conversion to the endianness dependent encoding.
158 echo $ac_n "test encoder: $utf8 -> $from $ac_c"
159 $PROG -f $utf8 -t $from < testdata/${filename}..${utf8} > $temp1
160 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
161 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
162 { echo "/FAILED"; failed=1; continue; }
163 echo "OK"
165 # Test conversion from the endianness dependent encoding.
166 echo $ac_n "test decoder: $from -> $utf8 $ac_c"
167 $PROG -f $from -t $utf8 < testdata/${filename}..${from}.BE > $temp1
168 LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
169 { echo "/FAILED"; failed=1; continue; }
170 $PROG -f $from -t $utf8 < testdata/${filename}..${from}.LE > $temp1
171 LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
172 { echo "/FAILED"; failed=1; continue; }
173 echo "OK"
175 # Test byte swapping behaviour.
176 echo $ac_n "test non-BOM: ${from}BE -> ${from}LE $ac_c"
177 $PROG -f ${from}BE -t ${from}LE < testdata/${filename}..${from}.BE > $temp1
178 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
179 { echo "/FAILED"; failed=1; continue; }
180 echo "OK"
182 # Test byte swapping behaviour.
183 echo $ac_n "test non-BOM: ${from}LE -> ${from}BE $ac_c"
184 $PROG -f ${from}LE -t ${from}BE < testdata/${filename}..${from}.LE > $temp1
185 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
186 { echo "/FAILED"; failed=1; continue; }
187 echo "OK"
189 done < TESTS2
191 exit $failed
192 # Local Variables:
193 # mode:shell-script
194 # End: