1#!/bin/sh
2# Test collation using xfrm-test.
3# Copyright (C) 1997-2022 Free Software Foundation, Inc.
4# This file is part of the GNU C Library.
5
6# The GNU C Library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2.1 of the License, or (at your option) any later version.
10
11# The GNU C Library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# Lesser General Public License for more details.
15
16# You should have received a copy of the GNU Lesser General Public
17# License along with the GNU C Library; if not, see
18# <https://www.gnu.org/licenses/>.
19
20set -e
21
22common_objpfx=$1; shift
23test_program_prefix_before_env=$1; shift
24run_program_env=$1; shift
25test_program_prefix_after_env=$1; shift
26lang=$*
27
28id=${PPID:-100}
29here=`pwd`
30
31# Run collation tests.
32status=0
33for l in $lang; do
34  here=0
35  # Locale name matches test filename (without in).
36  cns=$l
37  ${test_program_prefix_before_env} \
38   ${run_program_env} \
39   LC_ALL=$l ${test_program_prefix_after_env} \
40   ${common_objpfx}localedata/collate-test $id < $cns.in \
41   > ${common_objpfx}localedata/$cns.out || here=1
42  cmp -s $cns.in ${common_objpfx}localedata/$cns.out || here=1
43  if test $here -eq 0; then
44    echo "$l collate-test OK"
45  else
46    echo "$l collate-test FAIL"
47    diff -u $cns.in ${common_objpfx}localedata/$cns.out | sed 's/^/  /'
48    status=1
49  fi
50
51  ${test_program_prefix_before_env} \
52   ${run_program_env} \
53   LC_ALL=$l ${test_program_prefix_after_env} \
54   ${common_objpfx}localedata/xfrm-test $id < $cns.in \
55   > ${common_objpfx}localedata/$cns.xout || here=1
56  cmp -s $cns.in ${common_objpfx}localedata/$cns.xout || here=1
57  ${test_program_prefix_before_env} \
58   ${run_program_env} \
59   LC_ALL=$l ${test_program_prefix_after_env} \
60   ${common_objpfx}localedata/xfrm-test $id -nocache < $cns.in \
61   > ${common_objpfx}localedata/$cns.nocache.xout || here=1
62  cmp -s $cns.in ${common_objpfx}localedata/$cns.nocache.xout || here=1
63  if test $here -eq 0; then
64    echo "$l xfrm-test OK"
65  else
66    echo "$l xfrm-test FAIL"
67    diff -u $cns.in ${common_objpfx}localedata/$cns.xout | sed 's/^/  /'
68    diff -u $cns.in ${common_objpfx}localedata/$cns.nocache.xout | sed 's/^/  /'
69    status=1
70  fi
71done
72
73exit $status
74# Local Variables:
75#  mode:shell-script
76# End:
77