|
Packit |
6c4009 |
#!/bin/sh -f
|
|
Packit |
6c4009 |
# Run available iconv(1) tests.
|
|
Packit |
6c4009 |
# Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
# This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
# Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
# <http://www.gnu.org/licenses/>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
set -e
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
codir=$1
|
|
Packit |
6c4009 |
test_wrapper_env="$2"
|
|
Packit |
6c4009 |
run_program_env="$3"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# We use always the same temporary file.
|
|
Packit |
6c4009 |
temp1=$codir/iconvdata/iconv-test.xxx
|
|
Packit |
6c4009 |
temp2=$codir/iconvdata/iconv-test.yyy
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
trap "rm -f $temp1 $temp2" 1 2 3 15
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# We have to have some directories in the library path.
|
|
Packit |
6c4009 |
LIBPATH=$codir:$codir/iconvdata
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# How the start the iconv(1) program.
|
|
Packit |
6c4009 |
ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
|
|
Packit |
6c4009 |
$codir/iconv/iconv_prog'
|
|
Packit |
6c4009 |
ICONV="$test_wrapper_env $run_program_env $ICONV"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Which echo?
|
|
Packit |
6c4009 |
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
|
|
Packit |
6c4009 |
ac_n=-n ac_c= ac_t=
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
ac_n= ac_c='\c' ac_t=
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# We read the file named TESTS. All non-empty lines not starting with
|
|
Packit |
6c4009 |
# `#' are interpreted as commands.
|
|
Packit |
6c4009 |
failed=0
|
|
Packit |
6c4009 |
while read from to subset targets; do
|
|
Packit |
6c4009 |
# Ignore empty and comment lines.
|
|
Packit |
6c4009 |
if test -z "$subset" || test "$from" = '#'; then continue; fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Expand the variables now.
|
|
Packit |
6c4009 |
PROG=`eval echo $ICONV`
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if test -n "$targets"; then
|
|
Packit |
6c4009 |
for t in $targets; do
|
|
Packit |
6c4009 |
if test -f testdata/$from; then
|
|
Packit |
6c4009 |
echo $ac_n " test data: $from -> $t $ac_c"
|
|
Packit |
6c4009 |
$PROG -f $from -t $t testdata/$from < /dev/null > $temp1 ||
|
|
Packit |
6c4009 |
{ if test $? -gt 128; then exit 1; fi
|
|
Packit |
6c4009 |
echo "FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "OK$ac_c"
|
|
Packit |
6c4009 |
if test -s testdata/$from..$t; then
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "/OK$ac_c"
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
echo $ac_n " -> $from $ac_c"
|
|
Packit |
6c4009 |
$PROG -f $t -t $to -o $temp2 $temp1 < /dev/null ||
|
|
Packit |
6c4009 |
{ if test $? -gt 128; then exit 1; fi
|
|
Packit |
6c4009 |
echo "FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "OK$ac_c"
|
|
Packit |
6c4009 |
test -s $temp1 &&
|
|
Packit |
6c4009 |
LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "/OK"
|
|
Packit |
6c4009 |
rm -f $temp1 $temp2
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Now test some bigger text, entirely in ASCII. If ASCII is no subset
|
|
Packit |
6c4009 |
# of the coded character set we convert the text to this coded character
|
|
Packit |
6c4009 |
# set. Otherwise we convert to all the TARGETS.
|
|
Packit |
6c4009 |
if test $subset = Y; then
|
|
Packit |
6c4009 |
echo $ac_n " suntzu: $from -> $t -> $to $ac_c"
|
|
Packit |
6c4009 |
$PROG -f $from -t $t testdata/suntzus < /dev/null |
|
|
Packit |
6c4009 |
$PROG -f $t -t $to > $temp1 ||
|
|
Packit |
6c4009 |
{ if test $? -gt 128; then exit 1; fi
|
|
Packit |
6c4009 |
echo "FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "OK$ac_c"
|
|
Packit |
6c4009 |
LC_ALL=C cmp testdata/suntzus $temp1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "/OK"
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
rm -f $temp1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# And tests where iconv(1) has to handle charmaps.
|
|
Packit |
6c4009 |
if test "$t" = UTF8; then tc=UTF-8; else tc="$t"; fi
|
|
Packit |
6c4009 |
if test -f ../localedata/charmaps/$from &&
|
|
Packit |
6c4009 |
test -f ../localedata/charmaps/$tc &&
|
|
Packit |
6c4009 |
test -f testdata/$from &&
|
|
Packit |
6c4009 |
! grep '<U....><U....>' ../localedata/charmaps/$from > /dev/null; then
|
|
Packit |
6c4009 |
echo $ac_n "test charmap: $from -> $t $ac_c"
|
|
Packit |
6c4009 |
$PROG -f ../localedata/charmaps/$from -t ../localedata/charmaps/$tc \
|
|
Packit |
6c4009 |
testdata/$from < /dev/null > $temp1 ||
|
|
Packit |
6c4009 |
{ if test $? -gt 128; then exit 1; fi
|
|
Packit |
6c4009 |
echo "FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "OK$ac_c"
|
|
Packit |
6c4009 |
if test -s testdata/$from..$t; then
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/$from..$t > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "/OK$ac_c"
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
echo $ac_n " -> $from $ac_c"
|
|
Packit |
6c4009 |
$PROG -t ../localedata/charmaps/$from -f ../localedata/charmaps/$tc \
|
|
Packit |
6c4009 |
-o $temp2 $temp1 < /dev/null ||
|
|
Packit |
6c4009 |
{ if test $? -gt 128; then exit 1; fi
|
|
Packit |
6c4009 |
echo "FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "OK$ac_c"
|
|
Packit |
6c4009 |
test -s $temp1 &&
|
|
Packit |
6c4009 |
LC_ALL=C cmp testdata/$from $temp2 > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "/OK"
|
|
Packit |
6c4009 |
rm -f $temp1 $temp2
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
done
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if test "$subset" = N; then
|
|
Packit |
6c4009 |
echo $ac_n " suntzu: ASCII -> $to -> ASCII $ac_c"
|
|
Packit |
6c4009 |
$PROG -f ASCII -t $to testdata/suntzus < /dev/null |
|
|
Packit |
6c4009 |
$PROG -f $to -t ASCII > $temp1 ||
|
|
Packit |
6c4009 |
{ if test $? -gt 128; then exit 1; fi
|
|
Packit |
6c4009 |
echo "FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo $ac_n "OK$ac_c"
|
|
Packit |
6c4009 |
LC_ALL=C cmp testdata/suntzus $temp1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "/OK"
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
done < TESTS
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# We read the file named TESTS2. All non-empty lines not starting with
|
|
Packit |
6c4009 |
# `#' are interpreted as commands.
|
|
Packit |
6c4009 |
while read utf8 from filename; do
|
|
Packit |
6c4009 |
# Ignore empty and comment lines.
|
|
Packit |
6c4009 |
if test -z "$filename" || test "$utf8" = '#'; then continue; fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Expand the variables now.
|
|
Packit |
6c4009 |
PROG=`eval echo $ICONV`
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Test conversion to the endianness dependent encoding.
|
|
Packit |
6c4009 |
echo $ac_n "test encoder: $utf8 -> $from $ac_c"
|
|
Packit |
6c4009 |
$PROG -f $utf8 -t $from < testdata/${filename}..${utf8} > $temp1
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "OK"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Test conversion from the endianness dependent encoding.
|
|
Packit |
6c4009 |
echo $ac_n "test decoder: $from -> $utf8 $ac_c"
|
|
Packit |
6c4009 |
$PROG -f $from -t $utf8 < testdata/${filename}..${from}.BE > $temp1
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
$PROG -f $from -t $utf8 < testdata/${filename}..${from}.LE > $temp1
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/${filename}..${utf8} > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "OK"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Test byte swapping behaviour.
|
|
Packit |
6c4009 |
echo $ac_n "test non-BOM: ${from}BE -> ${from}LE $ac_c"
|
|
Packit |
6c4009 |
$PROG -f ${from}BE -t ${from}LE < testdata/${filename}..${from}.BE > $temp1
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/${filename}..${from}.LE > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "OK"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Test byte swapping behaviour.
|
|
Packit |
6c4009 |
echo $ac_n "test non-BOM: ${from}LE -> ${from}BE $ac_c"
|
|
Packit |
6c4009 |
$PROG -f ${from}LE -t ${from}BE < testdata/${filename}..${from}.LE > $temp1
|
|
Packit |
6c4009 |
LC_ALL=C cmp $temp1 testdata/${filename}..${from}.BE > /dev/null 2>&1 ||
|
|
Packit |
6c4009 |
{ echo "/FAILED"; failed=1; continue; }
|
|
Packit |
6c4009 |
echo "OK"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
done < TESTS2
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Check for crashes in decoders.
|
|
Packit |
6c4009 |
printf '\016\377\377\377\377\377\377\377' > $temp1
|
|
Packit |
6c4009 |
for from in $iconv_modules ; do
|
|
Packit |
6c4009 |
echo $ac_n "test decoder $from $ac_c"
|
|
Packit |
6c4009 |
PROG=`eval echo $ICONV`
|
|
Packit |
6c4009 |
if $PROG -f $from -t UTF8 < $temp1 >/dev/null 2>&1 ; then
|
|
Packit |
6c4009 |
: # fall through
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
status=$?
|
|
Packit |
6c4009 |
if test $status -gt 1 ; then
|
|
Packit |
6c4009 |
echo "/FAILED"
|
|
Packit |
6c4009 |
failed=1
|
|
Packit |
6c4009 |
continue
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
echo "OK"
|
|
Packit |
6c4009 |
done
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
exit $failed
|
|
Packit |
6c4009 |
# Local Variables:
|
|
Packit |
6c4009 |
# mode:shell-script
|
|
Packit |
6c4009 |
# End:
|