Define write_profiling functions only in profile library [BZ #31756]
[glibc.git] / locale / tst-locale-locpath.sh
blob527732953db51859a4a3033598598edff2c19856
1 #!/bin/sh
2 # Test that locale prints LOCPATH on failure.
3 # Copyright (C) 2019-2024 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
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.
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.
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/>.
20 set -ex
22 common_objpfx=$1
23 test_wrapper_env=$2
24 run_program_env=$3
26 LIBPATH="$common_objpfx"
28 testroot="${common_objpfx}locale/tst-locale-locpath-directory"
29 cleanup () {
30 rm -rf "$testroot"
32 trap cleanup 0
34 rm -rf "$testroot"
35 mkdir -p $testroot
37 ${test_wrapper_env} \
38 ${run_program_env} LANG= LC_ALL=invalid-locale LOCPATH=does-not-exist \
39 ${common_objpfx}elf/ld.so --library-path "$LIBPATH" \
40 "${common_objpfx}locale/locale" \
41 > "$testroot/stdout" 2> "$testroot/stderr"
43 echo "* standard error"
44 cat "$testroot/stderr"
45 echo "* standard output"
46 cat "$testroot/stdout"
48 cat > "$testroot/stderr-expected" <<EOF
49 ${common_objpfx}locale/locale: Cannot set LC_CTYPE to default locale: No such file or directory
50 ${common_objpfx}locale/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
51 ${common_objpfx}locale/locale: Cannot set LC_ALL to default locale: No such file or directory
52 warning: The LOCPATH variable is set to "does-not-exist"
53 EOF
55 cat > "$testroot/stdout-expected" <<EOF
56 LANG=
57 LC_CTYPE="invalid-locale"
58 LC_NUMERIC="invalid-locale"
59 LC_TIME="invalid-locale"
60 LC_COLLATE="invalid-locale"
61 LC_MONETARY="invalid-locale"
62 LC_MESSAGES="invalid-locale"
63 LC_PAPER="invalid-locale"
64 LC_NAME="invalid-locale"
65 LC_ADDRESS="invalid-locale"
66 LC_TELEPHONE="invalid-locale"
67 LC_MEASUREMENT="invalid-locale"
68 LC_IDENTIFICATION="invalid-locale"
69 LC_ALL=invalid-locale
70 EOF
72 errors=0
73 if ! cmp -s "$testroot/stderr-expected" "$testroot/stderr" ; then
74 echo "error: standard error not correct"
75 errors=1
77 if ! cmp -s "$testroot/stdout-expected" "$testroot/stdout" ; then
78 echo "error: standard output not correct"
79 errors=1
81 exit $errors