]>
Commit | Line | Data |
---|---|---|
480bc727 UD |
1 | #! /bin/sh -f |
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. | |
6 | # | |
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. | |
11 | # | |
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. | |
16 | # | |
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. | |
21 | ||
22 | codir=$1 | |
23 | ||
24 | # We use always the same temporary file. | |
25 | temp1=$codir/iconvdata/iconv-test.xxx | |
26 | temp2=$codir/iconvdata/iconv-test.yyy | |
27 | ||
28 | trap "rm -f $temp1 $temp2" 1 2 3 15 | |
29 | ||
30 | # We must tell the iconv(1) program where the modules we want to use can | |
31 | # be found. | |
32 | GCONV_PATH=$codir/iconvdata | |
33 | export GCONV_PATH | |
34 | ||
298f2566 UD |
35 | # We have to have some directories in the library path. |
36 | LIBPATH=$codir:$codir/iconvdata | |
37 | ||
480bc727 | 38 | # How the start the iconv(1) program. |
b0a01055 | 39 | ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \ |
310930c1 | 40 | $codir/iconv/iconv_prog' |
480bc727 UD |
41 | |
42 | # We read the file named TESTS. All non-empty lines not starting with | |
43 | # `#' are interpreted as commands. | |
5aa8ff62 UD |
44 | failed=0 |
45 | while read from to subset targets; do | |
480bc727 UD |
46 | # Ignore empty and comment lines. |
47 | if test -z "$targets" || test "$from" = '#'; then continue; fi | |
48 | ||
310930c1 UD |
49 | # Expand the variables now. |
50 | PROG=`eval echo $ICONV` | |
51 | ||
480bc727 | 52 | for t in $targets; do |
310930c1 | 53 | $PROG -f $from -t $t testdata/$from > $temp1 || |
af3878df | 54 | { echo "*** conversion from $from to $t failed"; failed=1; continue; } |
f1fa8b68 | 55 | if test -s testdata/$from..$t; then |
af3878df UD |
56 | cmp $temp1 testdata/$from..$t > /dev/null 2>&1 || |
57 | { echo "*** $from -> $t conversion failed"; failed=1; continue; } | |
f1fa8b68 | 58 | fi |
310930c1 | 59 | $PROG -f $t -t $to -o $temp2 $temp1 || |
af3878df UD |
60 | { echo "*** conversion from $t to $to failed"; failed=1; continue; } |
61 | test -s $temp1 && cmp testdata/$from $temp2 > /dev/null 2>&1 || | |
62 | { echo "*** $from -> t -> $to conversion failed"; failed=1; continue; } | |
8619129f UD |
63 | rm -f $temp1 $temp2 |
64 | ||
5aa8ff62 UD |
65 | # Now test some bigger text, entirely in ASCII. If ASCII is no subset |
66 | # of the coded character set we test we convert the test to this | |
67 | # coded character set. Otherwise we convert to all the TARGETS. | |
68 | if test $subset = Y; then | |
310930c1 UD |
69 | $PROG -f $from -t $t testdata/suntzus | |
70 | $PROG -f $t -t $to > $temp1 || | |
af3878df UD |
71 | { echo "*** conversion $from->$t->$to of suntzus failed"; failed=1; |
72 | continue; } | |
5aa8ff62 UD |
73 | cmp testdata/suntzus $temp1 || |
74 | { echo "*** conversion $from->$t->$to of suntzus incorrect"; | |
af3878df | 75 | failed=1; continue; } |
5aa8ff62 | 76 | else |
310930c1 UD |
77 | $PROG -f ASCII -t $to testdata/suntzus | |
78 | $PROG -f $to -t ASCII > $temp1 || | |
5aa8ff62 | 79 | { echo "*** conversion ASCII->$to->ASCII of suntzus failed"; |
af3878df | 80 | failed=1; continue; } |
5aa8ff62 UD |
81 | cmp testdata/suntzus $temp1 || |
82 | { echo "*** conversion ASCII->$to->ASCII of suntzus incorrect"; | |
af3878df | 83 | failed=1; continue; } |
5aa8ff62 | 84 | fi |
8619129f | 85 | rm -f $temp1 |
480bc727 UD |
86 | # All tests ok. |
87 | echo "$from -> $t -> $to ok" | |
480bc727 UD |
88 | done |
89 | done < TESTS | |
90 | ||
5aa8ff62 | 91 | exit $failed |
480bc727 UD |
92 | # Local Variables: |
93 | # mode:shell-script | |
94 | # End: |