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.
8 # The GNU C Library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # The GNU C Library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with the GNU C Library; if not, write to the Free
20 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 # We use always the same temporary file.
26 temp1
=$codir/iconvdata
/iconv-test.xxx
27 temp2
=$codir/iconvdata
/iconv-test.yyy
29 trap "rm -f $temp1 $temp2" 1 2 3 15
31 # We must tell the iconv(1) program where the modules we want to use can
33 GCONV_PATH
=$codir/iconvdata
36 # We have to have some directories in the library path.
37 LIBPATH
=$codir:$codir/iconvdata
39 # How the start the iconv(1) program.
40 ICONV
='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
41 $codir/iconv/iconv_prog'
44 if (echo "testing\c"; echo 1,2,3) |
grep c
>/dev
/null
; then
50 # We read the file named TESTS. All non-empty lines not starting with
51 # `#' are interpreted as commands.
53 while read from to subset targets
; do
54 # Ignore empty and comment lines.
55 if test -z "$subset" ||
test "$from" = '#'; then continue; fi
57 # Expand the variables now.
58 PROG
=`eval echo $ICONV`
60 if test -n "$targets"; then
62 if test -f testdata
/$from; then
63 echo $ac_n " test data: $from -> $t $ac_c"
64 $PROG -f $from -t $t testdata
/$from > $temp1 ||
65 { if test $?
-gt 128; then exit 1; fi
66 echo "FAILED"; failed
=1; continue; }
68 if test -s testdata
/$from..
$t; then
69 cmp $temp1 testdata
/$from..
$t > /dev
/null
2>&1 ||
70 { echo "/FAILED"; failed
=1; continue; }
73 echo $ac_n " -> $from $ac_c"
74 $PROG -f $t -t $to -o $temp2 $temp1 ||
75 { if test $?
-gt 128; then exit 1; fi
76 echo "FAILED"; failed
=1; continue; }
78 test -s $temp1 && cmp testdata
/$from $temp2 > /dev
/null
2>&1 ||
79 { echo "/FAILED"; failed
=1; continue; }
84 # Now test some bigger text, entirely in ASCII. If ASCII is no subset
85 # of the coded character set we convert the text to this coded character
86 # set. Otherwise we convert to all the TARGETS.
87 if test $subset = Y
; then
88 echo $ac_n " suntzu: $from -> $t -> $to $ac_c"
89 $PROG -f $from -t $t testdata
/suntzus |
90 $PROG -f $t -t $to > $temp1 ||
91 { if test $?
-gt 128; then exit 1; fi
92 echo "FAILED"; failed
=1; continue; }
94 cmp testdata
/suntzus
$temp1 ||
95 { echo "/FAILED"; failed
=1; continue; }
100 # And tests where iconv(1) has to handle charmaps.
101 if test "$t" = UTF8
; then tc
=UTF-8
; else tc
="$t"; fi
102 if test -f ..
/localedata
/charmaps
/$from &&
103 test -f ..
/localedata
/charmaps
/$tc &&
104 test -f testdata
/$from; then
105 echo $ac_n "test charmap: $from -> $t $ac_c"
106 $PROG -f ..
/localedata
/charmaps
/$from -t ..
/localedata
/charmaps
/$tc \
107 testdata
/$from > $temp1 ||
108 { if test $?
-gt 128; then exit 1; fi
109 echo "FAILED"; failed
=1; continue; }
111 if test -s testdata
/$from..
$t; then
112 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 \
119 { if test $?
-gt 128; then exit 1; fi
120 echo "FAILED"; failed
=1; continue; }
122 test -s $temp1 && cmp testdata
/$from $temp2 > /dev
/null
2>&1 ||
123 { echo "/FAILED"; failed
=1; continue; }
130 if test "$subset" != Y
; then
131 echo $ac_n " suntzu: ASCII -> $to -> ASCII $ac_c"
132 $PROG -f ASCII
-t $to testdata
/suntzus |
133 $PROG -f $to -t ASCII
> $temp1 ||
134 { if test $?
-gt 128; then exit 1; fi
135 echo "FAILED"; failed
=1; continue; }
137 cmp testdata
/suntzus
$temp1 ||
138 { echo "/FAILED"; failed
=1; continue; }
143 # We read the file named TESTS2. All non-empty lines not starting with
144 # `#' are interpreted as commands.
145 while read utf8 from filename
; do
146 # Ignore empty and comment lines.
147 if test -z "$filename" ||
test "$utf8" = '#'; then continue; fi
149 # Expand the variables now.
150 PROG
=`eval echo $ICONV`
152 # Test conversion to the endianness dependent encoding.
153 echo $ac_n "test encoder: $utf8 -> $from $ac_c"
154 $PROG -f $utf8 -t $from < testdata
/${filename}..
${utf8} > $temp1
155 cmp $temp1 testdata
/${filename}..
${from}.BE
> /dev
/null
2>&1 ||
156 cmp $temp1 testdata
/${filename}..
${from}.LE
> /dev
/null
2>&1 ||
157 { echo "/FAILED"; failed
=1; continue; }
160 # Test conversion from the endianness dependent encoding.
161 echo $ac_n "test decoder: $from -> $utf8 $ac_c"
162 $PROG -f $from -t $utf8 < testdata
/${filename}..
${from}.BE
> $temp1
163 cmp $temp1 testdata
/${filename}..
${utf8} > /dev
/null
2>&1 ||
164 { echo "/FAILED"; failed
=1; continue; }
165 $PROG -f $from -t $utf8 < testdata
/${filename}..
${from}.LE
> $temp1
166 cmp $temp1 testdata
/${filename}..
${utf8} > /dev
/null
2>&1 ||
167 { echo "/FAILED"; failed
=1; continue; }
170 # Test byte swapping behaviour.
171 echo $ac_n "test non-BOM: ${from}BE -> ${from}LE $ac_c"
172 $PROG -f ${from}BE -t ${from}LE < testdata/${filename}..${from}.BE
> $temp1
173 cmp $temp1 testdata
/${filename}..
${from}.LE
> /dev
/null
2>&1 ||
174 { echo "/FAILED"; failed
=1; continue; }
177 # Test byte swapping behaviour.
178 echo $ac_n "test non-BOM: ${from}LE -> ${from}BE $ac_c"
179 $PROG -f ${from}LE -t ${from}BE < testdata/${filename}..${from}.LE
> $temp1
180 cmp $temp1 testdata
/${filename}..
${from}.BE
> /dev
/null
2>&1 ||
181 { echo "/FAILED"; failed
=1; continue; }