]>
Commit | Line | Data |
---|---|---|
480bc727 UD |
1 | #! /bin/sh -f |
2 | # Run available iconv(1) tests. | |
0ecb606c | 3 | # Copyright (C) 1998-2002, 2005, 2006 Free Software Foundation, Inc. |
480bc727 UD |
4 | # This file is part of the GNU C Library. |
5 | # Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. | |
6 | # | |
41bdb6e2 | 7 | |
480bc727 | 8 | # The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
12 | ||
480bc727 UD |
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 | |
41bdb6e2 AJ |
16 | # Lesser General Public License for more details. |
17 | ||
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 | |
21 | # 02111-1307 USA. | |
480bc727 UD |
22 | |
23 | codir=$1 | |
24 | ||
25 | # We use always the same temporary file. | |
26 | temp1=$codir/iconvdata/iconv-test.xxx | |
27 | temp2=$codir/iconvdata/iconv-test.yyy | |
28 | ||
29 | trap "rm -f $temp1 $temp2" 1 2 3 15 | |
30 | ||
31 | # We must tell the iconv(1) program where the modules we want to use can | |
32 | # be found. | |
33 | GCONV_PATH=$codir/iconvdata | |
34 | export GCONV_PATH | |
35 | ||
298f2566 UD |
36 | # We have to have some directories in the library path. |
37 | LIBPATH=$codir:$codir/iconvdata | |
38 | ||
480bc727 | 39 | # How the start the iconv(1) program. |
b0a01055 | 40 | ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \ |
310930c1 | 41 | $codir/iconv/iconv_prog' |
480bc727 | 42 | |
822078f6 UD |
43 | # Which echo? |
44 | if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then | |
45 | ac_n=-n ac_c= ac_t= | |
46 | else | |
47 | ac_n= ac_c='\c' ac_t= | |
48 | fi | |
49 | ||
480bc727 UD |
50 | # We read the file named TESTS. All non-empty lines not starting with |
51 | # `#' are interpreted as commands. | |
5aa8ff62 UD |
52 | failed=0 |
53 | while read from to subset targets; do | |
480bc727 | 54 | # Ignore empty and comment lines. |
3b7caeac | 55 | if test -z "$subset" || test "$from" = '#'; then continue; fi |
480bc727 | 56 | |
310930c1 UD |
57 | # Expand the variables now. |
58 | PROG=`eval echo $ICONV` | |
59 | ||
3b7caeac UD |
60 | if test -n "$targets"; then |
61 | for t in $targets; do | |
62 | if test -f testdata/$from; then | |
93693c4d | 63 | echo $ac_n " test data: $from -> $t $ac_c" |
3b7caeac UD |
64 | $PROG -f $from -t $t testdata/$from > $temp1 || |
65 | { if test $? -gt 128; then exit 1; fi | |
93693c4d | 66 | echo "FAILED"; failed=1; continue; } |
3b7caeac UD |
67 | echo $ac_n "OK$ac_c" |
68 | if test -s testdata/$from..$t; then | |
0ecb606c | 69 | LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 || |
3b7caeac UD |
70 | { echo "/FAILED"; failed=1; continue; } |
71 | echo $ac_n "/OK$ac_c" | |
72 | fi | |
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 | |
93693c4d | 76 | echo "FAILED"; failed=1; continue; } |
3b7caeac | 77 | echo $ac_n "OK$ac_c" |
0ecb606c JJ |
78 | test -s $temp1 && |
79 | LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 || | |
3b7caeac UD |
80 | { echo "/FAILED"; failed=1; continue; } |
81 | echo "/OK" | |
82 | rm -f $temp1 $temp2 | |
83 | fi | |
84 | ||
85 | # Now test some bigger text, entirely in ASCII. If ASCII is no subset | |
86 | # of the coded character set we convert the text to this coded character | |
87 | # set. Otherwise we convert to all the TARGETS. | |
88 | if test $subset = Y; then | |
93693c4d | 89 | echo $ac_n " suntzu: $from -> $t -> $to $ac_c" |
3b7caeac UD |
90 | $PROG -f $from -t $t testdata/suntzus | |
91 | $PROG -f $t -t $to > $temp1 || | |
92 | { if test $? -gt 128; then exit 1; fi | |
93693c4d | 93 | echo "FAILED"; failed=1; continue; } |
3b7caeac | 94 | echo $ac_n "OK$ac_c" |
0ecb606c | 95 | LC_ALL=C cmp testdata/suntzus $temp1 || |
93693c4d | 96 | { echo "/FAILED"; failed=1; continue; } |
3b7caeac UD |
97 | echo "/OK" |
98 | fi | |
99 | rm -f $temp1 | |
93693c4d UD |
100 | |
101 | # And tests where iconv(1) has to handle charmaps. | |
102 | if test "$t" = UTF8; then tc=UTF-8; else tc="$t"; fi | |
103 | if test -f ../localedata/charmaps/$from && | |
104 | test -f ../localedata/charmaps/$tc && | |
faaa6f62 UD |
105 | test -f testdata/$from && |
106 | ! grep '<U....><U....>' ../localedata/charmaps/$from > /dev/null; then | |
93693c4d UD |
107 | echo $ac_n "test charmap: $from -> $t $ac_c" |
108 | $PROG -f ../localedata/charmaps/$from -t ../localedata/charmaps/$tc \ | |
109 | testdata/$from > $temp1 || | |
110 | { if test $? -gt 128; then exit 1; fi | |
111 | echo "FAILED"; failed=1; continue; } | |
112 | echo $ac_n "OK$ac_c" | |
113 | if test -s testdata/$from..$t; then | |
0ecb606c | 114 | LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 || |
93693c4d UD |
115 | { echo "/FAILED"; failed=1; continue; } |
116 | echo $ac_n "/OK$ac_c" | |
117 | fi | |
118 | echo $ac_n " -> $from $ac_c" | |
119 | $PROG -t ../localedata/charmaps/$from -f ../localedata/charmaps/$tc \ | |
120 | -o $temp2 $temp1 || | |
121 | { if test $? -gt 128; then exit 1; fi | |
122 | echo "FAILED"; failed=1; continue; } | |
123 | echo $ac_n "OK$ac_c" | |
0ecb606c JJ |
124 | test -s $temp1 && |
125 | LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 || | |
93693c4d UD |
126 | { echo "/FAILED"; failed=1; continue; } |
127 | echo "/OK" | |
128 | rm -f $temp1 $temp2 | |
129 | fi | |
3b7caeac UD |
130 | done |
131 | fi | |
132 | ||
0ecb606c | 133 | if test "$subset" == N; then |
b721a2c0 | 134 | echo $ac_n " suntzu: ASCII -> $to -> ASCII $ac_c" |
3b7caeac UD |
135 | $PROG -f ASCII -t $to testdata/suntzus | |
136 | $PROG -f $to -t ASCII > $temp1 || | |
813bb1f1 | 137 | { if test $? -gt 128; then exit 1; fi |
93693c4d | 138 | echo "FAILED"; failed=1; continue; } |
822078f6 | 139 | echo $ac_n "OK$ac_c" |
0ecb606c | 140 | LC_ALL=C cmp testdata/suntzus $temp1 || |
93693c4d | 141 | { echo "/FAILED"; failed=1; continue; } |
822078f6 | 142 | echo "/OK" |
3b7caeac | 143 | fi |
480bc727 UD |
144 | done < TESTS |
145 | ||
b721a2c0 UD |
146 | # We read the file named TESTS2. All non-empty lines not starting with |
147 | # `#' are interpreted as commands. | |
148 | while read utf8 from filename; do | |
149 | # Ignore empty and comment lines. | |
150 | if test -z "$filename" || test "$utf8" = '#'; then continue; fi | |
151 | ||
152 | # Expand the variables now. | |
153 | PROG=`eval echo $ICONV` | |
154 | ||
155 | # Test conversion to the endianness dependent encoding. | |
156 | echo $ac_n "test encoder: $utf8 -> $from $ac_c" | |
157 | $PROG -f $utf8 -t $from < testdata/${filename}..${utf8} > $temp1 | |
0ecb606c JJ |
158 | LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 || |
159 | LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 || | |
b721a2c0 UD |
160 | { echo "/FAILED"; failed=1; continue; } |
161 | echo "OK" | |
162 | ||
163 | # Test conversion from the endianness dependent encoding. | |
164 | echo $ac_n "test decoder: $from -> $utf8 $ac_c" | |
165 | $PROG -f $from -t $utf8 < testdata/${filename}..${from}.BE > $temp1 | |
0ecb606c | 166 | LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 || |
b721a2c0 UD |
167 | { echo "/FAILED"; failed=1; continue; } |
168 | $PROG -f $from -t $utf8 < testdata/${filename}..${from}.LE > $temp1 | |
0ecb606c | 169 | LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 || |
b721a2c0 UD |
170 | { echo "/FAILED"; failed=1; continue; } |
171 | echo "OK" | |
172 | ||
173 | # Test byte swapping behaviour. | |
174 | echo $ac_n "test non-BOM: ${from}BE -> ${from}LE $ac_c" | |
175 | $PROG -f ${from}BE -t ${from}LE < testdata/${filename}..${from}.BE > $temp1 | |
0ecb606c | 176 | LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 || |
b721a2c0 UD |
177 | { echo "/FAILED"; failed=1; continue; } |
178 | echo "OK" | |
179 | ||
180 | # Test byte swapping behaviour. | |
181 | echo $ac_n "test non-BOM: ${from}LE -> ${from}BE $ac_c" | |
182 | $PROG -f ${from}LE -t ${from}BE < testdata/${filename}..${from}.LE > $temp1 | |
0ecb606c | 183 | LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 || |
b721a2c0 UD |
184 | { echo "/FAILED"; failed=1; continue; } |
185 | echo "OK" | |
186 | ||
187 | done < TESTS2 | |
188 | ||
5aa8ff62 | 189 | exit $failed |
480bc727 UD |
190 | # Local Variables: |
191 | # mode:shell-script | |
192 | # End: |