hurd: Fix getting signal thread stack layout for fork
[glibc.git] / iconvdata / run-iconv-test.sh
bloba4d9300f3b78c51aea1df5d88ea9bea1fdeccc6e
1 #!/bin/sh -f
2 # Run available iconv(1) tests.
3 # Copyright (C) 1998-2018 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_env="$2"
25 run_program_env="$3"
27 # We use always the same temporary file.
28 temp1=$codir/iconvdata/iconv-test.xxx
29 temp2=$codir/iconvdata/iconv-test.yyy
31 trap "rm -f $temp1 $temp2" 1 2 3 15
33 # We have to have some directories in the library path.
34 LIBPATH=$codir:$codir/iconvdata
36 # How the start the iconv(1) program.
37 ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
38 $codir/iconv/iconv_prog'
39 ICONV="$test_wrapper_env $run_program_env $ICONV"
41 # Which echo?
42 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
43 ac_n=-n ac_c= ac_t=
44 else
45 ac_n= ac_c='\c' ac_t=
48 # We read the file named TESTS. All non-empty lines not starting with
49 # `#' are interpreted as commands.
50 failed=0
51 while read from to subset targets; do
52 # Ignore empty and comment lines.
53 if test -z "$subset" || test "$from" = '#'; then continue; fi
55 # Expand the variables now.
56 PROG=`eval echo $ICONV`
58 if test -n "$targets"; then
59 for t in $targets; do
60 if test -f testdata/$from; then
61 echo $ac_n " test data: $from -> $t $ac_c"
62 $PROG -f $from -t $t testdata/$from < /dev/null > $temp1 ||
63 { if test $? -gt 128; then exit 1; fi
64 echo "FAILED"; failed=1; continue; }
65 echo $ac_n "OK$ac_c"
66 if test -s testdata/$from..$t; then
67 LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
68 { echo "/FAILED"; failed=1; continue; }
69 echo $ac_n "/OK$ac_c"
71 echo $ac_n " -> $from $ac_c"
72 $PROG -f $t -t $to -o $temp2 $temp1 < /dev/null ||
73 { if test $? -gt 128; then exit 1; fi
74 echo "FAILED"; failed=1; continue; }
75 echo $ac_n "OK$ac_c"
76 test -s $temp1 &&
77 LC_ALL=C 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 < /dev/null |
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 LC_ALL=C 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 &&
104 ! grep '<U....><U....>' ../localedata/charmaps/$from > /dev/null; then
105 echo $ac_n "test charmap: $from -> $t $ac_c"
106 $PROG -f ../localedata/charmaps/$from -t ../localedata/charmaps/$tc \
107 testdata/$from < /dev/null > $temp1 ||
108 { if test $? -gt 128; then exit 1; fi
109 echo "FAILED"; failed=1; continue; }
110 echo $ac_n "OK$ac_c"
111 if test -s testdata/$from..$t; then
112 LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
113 { echo "/FAILED"; failed=1; continue; }
114 echo $ac_n "/OK$ac_c"
116 echo $ac_n " -> $from $ac_c"
117 $PROG -t ../localedata/charmaps/$from -f ../localedata/charmaps/$tc \
118 -o $temp2 $temp1 < /dev/null ||
119 { if test $? -gt 128; then exit 1; fi
120 echo "FAILED"; failed=1; continue; }
121 echo $ac_n "OK$ac_c"
122 test -s $temp1 &&
123 LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 ||
124 { echo "/FAILED"; failed=1; continue; }
125 echo "/OK"
126 rm -f $temp1 $temp2
128 done
131 if test "$subset" = N; then
132 echo $ac_n " suntzu: ASCII -> $to -> ASCII $ac_c"
133 $PROG -f ASCII -t $to testdata/suntzus < /dev/null |
134 $PROG -f $to -t ASCII > $temp1 ||
135 { if test $? -gt 128; then exit 1; fi
136 echo "FAILED"; failed=1; continue; }
137 echo $ac_n "OK$ac_c"
138 LC_ALL=C cmp testdata/suntzus $temp1 ||
139 { echo "/FAILED"; failed=1; continue; }
140 echo "/OK"
142 done < TESTS
144 # We read the file named TESTS2. All non-empty lines not starting with
145 # `#' are interpreted as commands.
146 while read utf8 from filename; do
147 # Ignore empty and comment lines.
148 if test -z "$filename" || test "$utf8" = '#'; then continue; fi
150 # Expand the variables now.
151 PROG=`eval echo $ICONV`
153 # Test conversion to the endianness dependent encoding.
154 echo $ac_n "test encoder: $utf8 -> $from $ac_c"
155 $PROG -f $utf8 -t $from < testdata/${filename}..${utf8} > $temp1
156 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
157 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
158 { echo "/FAILED"; failed=1; continue; }
159 echo "OK"
161 # Test conversion from the endianness dependent encoding.
162 echo $ac_n "test decoder: $from -> $utf8 $ac_c"
163 $PROG -f $from -t $utf8 < testdata/${filename}..${from}.BE > $temp1
164 LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
165 { echo "/FAILED"; failed=1; continue; }
166 $PROG -f $from -t $utf8 < testdata/${filename}..${from}.LE > $temp1
167 LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
168 { echo "/FAILED"; failed=1; continue; }
169 echo "OK"
171 # Test byte swapping behaviour.
172 echo $ac_n "test non-BOM: ${from}BE -> ${from}LE $ac_c"
173 $PROG -f ${from}BE -t ${from}LE < testdata/${filename}..${from}.BE > $temp1
174 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
175 { echo "/FAILED"; failed=1; continue; }
176 echo "OK"
178 # Test byte swapping behaviour.
179 echo $ac_n "test non-BOM: ${from}LE -> ${from}BE $ac_c"
180 $PROG -f ${from}LE -t ${from}BE < testdata/${filename}..${from}.LE > $temp1
181 LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
182 { echo "/FAILED"; failed=1; continue; }
183 echo "OK"
185 done < TESTS2
187 # Check for crashes in decoders.
188 printf '\016\377\377\377\377\377\377\377' > $temp1
189 for from in $iconv_modules ; do
190 echo $ac_n "test decoder $from $ac_c"
191 PROG=`eval echo $ICONV`
192 if $PROG -f $from -t UTF8 < $temp1 >/dev/null 2>&1 ; then
193 : # fall through
194 else
195 status=$?
196 if test $status -gt 1 ; then
197 echo "/FAILED"
198 failed=1
199 continue
202 echo "OK"
203 done
205 exit $failed
206 # Local Variables:
207 # mode:shell-script
208 # End: