2 # Run available iconv(1) tests.
3 # Copyright (C) 1998 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.
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
32 GCONV_PATH=$codir/iconvdata
35 # How the start the iconv(1) program.
36 ICONV="$codir/elf/ld.so --library-path $codir $codir/iconv/iconv_prog"
38 # We read the file named TESTS. All non-empty lines not starting with
39 # `#' are interpreted as commands.
41 while read from to subset targets; do
42 # Ignore empty and comment lines.
43 if test -z "$targets" || test "$from" = '#'; then continue; fi
46 $ICONV -f $from -t $t testdata/$from > $temp1 ||
47 { echo "*** conversion from $from to $t failed"; failed=1; }
48 if test -s testdata/$from..$t; then
49 cmp $temp1 testdata/$from..$t >& /dev/null ||
50 { echo "*** $from -> $t conversion failed"; failed=1; }
52 $ICONV -f $t -t $to -o $temp2 $temp1 ||
53 { echo "*** conversion from $t to $to failed"; failed=1; }
54 test -s $temp1 && cmp testdata/$from $temp2 >& /dev/null ||
55 { echo "*** $from -> t -> $to conversion failed"; failed=1; }
58 # Now test some bigger text, entirely in ASCII. If ASCII is no subset
59 # of the coded character set we test we convert the test to this
60 # coded character set. Otherwise we convert to all the TARGETS.
61 if test $subset = Y; then
62 $ICONV -f $from -t $t testdata/suntzus |
63 $ICONV -f $t -t $to > $temp1 ||
64 { echo "*** conversion $from->$t->$to of suntzus failed"; failed=1; }
65 cmp testdata/suntzus $temp1 ||
66 { echo "*** conversion $from->$t->$to of suntzus incorrect";
69 $ICONV -f ASCII -t $to testdata/suntzus |
70 $ICONV -f $to -f ASCII > $temp1 ||
71 { echo "*** conversion ASCII->$to->ASCII of suntzus failed";
73 cmp testdata/suntzus $temp1 ||
74 { echo "*** conversion ASCII->$to->ASCII of suntzus incorrect";
79 echo "$from -> $t -> $to ok"