]> git.ipfire.org Git - thirdparty/glibc.git/blame - iconvdata/run-iconv-test.sh
Update.
[thirdparty/glibc.git] / iconvdata / run-iconv-test.sh
CommitLineData
480bc727
UD
1#! /bin/sh -f
2# Run available iconv(1) tests.
822078f6 3# Copyright (C) 1998, 1999 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#
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
22codir=$1
23
24# We use always the same temporary file.
25temp1=$codir/iconvdata/iconv-test.xxx
26temp2=$codir/iconvdata/iconv-test.yyy
27
28trap "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.
32GCONV_PATH=$codir/iconvdata
33export GCONV_PATH
34
298f2566
UD
35# We have to have some directories in the library path.
36LIBPATH=$codir:$codir/iconvdata
37
480bc727 38# How the start the iconv(1) program.
b0a01055 39ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
310930c1 40 $codir/iconv/iconv_prog'
480bc727 41
822078f6
UD
42# Which echo?
43if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
44 ac_n=-n ac_c= ac_t=
45else
46 ac_n= ac_c='\c' ac_t=
47fi
48
480bc727
UD
49# We read the file named TESTS. All non-empty lines not starting with
50# `#' are interpreted as commands.
5aa8ff62
UD
51failed=0
52while read from to subset targets; do
480bc727
UD
53 # Ignore empty and comment lines.
54 if test -z "$targets" || test "$from" = '#'; then continue; fi
55
310930c1
UD
56 # Expand the variables now.
57 PROG=`eval echo $ICONV`
58
480bc727 59 for t in $targets; do
056e0358 60 echo $ac_n "test data: $from -> $t $ac_c"
310930c1 61 $PROG -f $from -t $t testdata/$from > $temp1 ||
056e0358 62 { echo "FAILED"; failed=1; continue; }
822078f6 63 echo $ac_n "OK$ac_c"
f1fa8b68 64 if test -s testdata/$from..$t; then
af3878df 65 cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
822078f6
UD
66 { echo "/FAILED"; failed=1; continue; }
67 echo $ac_n "/OK$ac_c"
f1fa8b68 68 fi
822078f6 69 echo $ac_n " -> $from $ac_c"
310930c1 70 $PROG -f $t -t $to -o $temp2 $temp1 ||
056e0358 71 { echo "FAILED"; failed=1; continue; }
822078f6 72 echo $ac_n "OK$ac_c"
af3878df 73 test -s $temp1 && cmp testdata/$from $temp2 > /dev/null 2>&1 ||
056e0358 74 { echo "/FAILED"; failed=1; continue; }
822078f6 75 echo "/OK"
8619129f
UD
76 rm -f $temp1 $temp2
77
5aa8ff62
UD
78 # Now test some bigger text, entirely in ASCII. If ASCII is no subset
79 # of the coded character set we test we convert the test to this
80 # coded character set. Otherwise we convert to all the TARGETS.
81 if test $subset = Y; then
056e0358 82 echo $ac_n " suntzu: $from -> $t -> $to $ac_c"
310930c1
UD
83 $PROG -f $from -t $t testdata/suntzus |
84 $PROG -f $t -t $to > $temp1 ||
822078f6 85 { echo "FAILED"; failed=1;
af3878df 86 continue; }
822078f6 87 echo $ac_n "OK$ac_c"
5aa8ff62 88 cmp testdata/suntzus $temp1 ||
822078f6 89 { echo "/FAILED";
af3878df 90 failed=1; continue; }
5aa8ff62 91 else
056e0358 92 echo $ac_n " suntzu: $from -> ASCII -> $to $ac_c"
310930c1
UD
93 $PROG -f ASCII -t $to testdata/suntzus |
94 $PROG -f $to -t ASCII > $temp1 ||
822078f6 95 { echo "FAILED";
af3878df 96 failed=1; continue; }
822078f6 97 echo $ac_n "OK$ac_c"
056e0358 98 cmp testdata/suntzus $temp1 ||
822078f6 99 { echo "/FAILED";
af3878df 100 failed=1; continue; }
5aa8ff62 101 fi
822078f6 102 echo "/OK"
8619129f 103 rm -f $temp1
480bc727
UD
104 done
105done < TESTS
106
5aa8ff62 107exit $failed
480bc727
UD
108# Local Variables:
109# mode:shell-script
110# End: