S390: Move utf8-utf32-z9.c to multiarch folder and use s390_libc_ifunc_expr macro.
[glibc.git] / iconvdata / tst-table.sh
blob188aad98c8ecef0d4fb25684133cc6b90245f075
1 #!/bin/sh
2 # Copyright (C) 2000-2017 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4 # Contributed by Bruno Haible <haible@clisp.cons.org>, 2000.
7 # The GNU C Library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the 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 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with the GNU C Library; if not, see
19 # <http://www.gnu.org/licenses/>.
21 # Checks that the iconv() implementation (in both directions) for a
22 # stateless encoding agrees with the charmap table.
24 common_objpfx=$1
25 objpfx=$2
26 test_program_prefix=$3
27 charset=$4
28 charmap=$5
30 # sort is used on the build system.
31 LC_ALL=C
32 export LC_ALL
34 set -e
36 # Get the charmap.
37 ./tst-table-charmap.sh ${charmap:-$charset} \
38 < ../localedata/charmaps/${charmap:-$charset} \
39 > ${objpfx}tst-${charset}.charmap.table
40 # When the charset is GB18030, truncate this table because for this encoding,
41 # the tst-table-from and tst-table-to programs scan the Unicode BMP only.
42 if test ${charset} = GB18030; then
43 grep '0x....$' < ${objpfx}tst-${charset}.charmap.table \
44 > ${objpfx}tst-${charset}.truncated.table
45 mv ${objpfx}tst-${charset}.truncated.table ${objpfx}tst-${charset}.charmap.table
48 # Precomputed expexted differences between the charmap and iconv forward.
49 precomposed=${charset}.precomposed
51 # Precompute expected differences between the charmap and iconv backward.
52 if test ${charset} = EUC-TW; then
53 irreversible=${objpfx}tst-${charset}.irreversible
54 (grep '^0x8EA1' ${objpfx}tst-${charset}.charmap.table
55 cat ${charset}.irreversible
56 ) > ${irreversible}
57 else
58 irreversible=${charset}.irreversible
61 # iconv in one direction.
62 ${test_program_prefix} \
63 ${objpfx}tst-table-from ${charset} \
64 > ${objpfx}tst-${charset}.table
66 # iconv in the other direction.
67 ${test_program_prefix} \
68 ${objpfx}tst-table-to ${charset} | sort \
69 > ${objpfx}tst-${charset}.inverse.table
71 # Difference between the charmap and iconv backward.
72 diff ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table | \
73 grep '^[<>]' | sed -e 's,^. ,,' > ${objpfx}tst-${charset}.irreversible.table
75 # Check 1: charmap and iconv forward should be identical, except for
76 # precomposed characters.
77 if test -f ${precomposed}; then
78 cat ${objpfx}tst-${charset}.table ${precomposed} | sort | uniq -u \
79 > ${objpfx}tst-${charset}.tmp.table
80 cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.tmp.table ||
81 exit 1
82 else
83 cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table ||
84 exit 1
87 # Check 2: the difference between the charmap and iconv backward.
88 if test -f ${irreversible}; then
89 cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u \
90 > ${objpfx}tst-${charset}.tmp.table
91 cmp -s ${objpfx}tst-${charset}.tmp.table ${objpfx}tst-${charset}.inverse.table ||
92 exit 1
93 else
94 cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table ||
95 exit 1
98 exit 0