Blame locale/tst-locale-locpath.sh

Packit Service 864c92
#!/bin/sh
Packit Service 864c92
# Test that locale prints LOCPATH on failure.
Packit Service 864c92
# Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service 864c92
# This file is part of the GNU C Library.
Packit Service 864c92
Packit Service 864c92
# The GNU C Library is free software; you can redistribute it and/or
Packit Service 864c92
# modify it under the terms of the GNU Lesser General Public
Packit Service 864c92
# License as published by the Free Software Foundation; either
Packit Service 864c92
# version 2.1 of the License, or (at your option) any later version.
Packit Service 864c92
Packit Service 864c92
# The GNU C Library is distributed in the hope that it will be useful,
Packit Service 864c92
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 864c92
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 864c92
# Lesser General Public License for more details.
Packit Service 864c92
Packit Service 864c92
# You should have received a copy of the GNU Lesser General Public
Packit Service 864c92
# License along with the GNU C Library; if not, see
Packit Service 864c92
# <http://www.gnu.org/licenses/>.
Packit Service 864c92
Packit Service 864c92
set -ex
Packit Service 864c92
Packit Service 864c92
common_objpfx=$1
Packit Service 864c92
test_wrapper_env=$2
Packit Service 864c92
run_program_env=$3
Packit Service 864c92
Packit Service 864c92
LIBPATH="$common_objpfx"
Packit Service 864c92
Packit Service 864c92
testroot="${common_objpfx}locale/tst-locale-locpath-directory"
Packit Service 864c92
cleanup () {
Packit Service 864c92
    rm -rf "$testroot"
Packit Service 864c92
}
Packit Service 864c92
trap cleanup 0
Packit Service 864c92
Packit Service 864c92
rm -rf "$testroot"
Packit Service 864c92
mkdir -p $testroot
Packit Service 864c92
Packit Service 864c92
unset LANG
Packit Service 864c92
Packit Service 864c92
${test_wrapper_env} \
Packit Service 864c92
${run_program_env} LC_ALL=invalid-locale LOCPATH=does-not-exist \
Packit Service 864c92
${common_objpfx}elf/ld.so --library-path "$LIBPATH" \
Packit Service 864c92
  "${common_objpfx}locale/locale" \
Packit Service 864c92
  > "$testroot/stdout" 2> "$testroot/stderr"
Packit Service 864c92
Packit Service 864c92
echo "* standard error"
Packit Service 864c92
cat "$testroot/stderr"
Packit Service 864c92
echo "* standard output"
Packit Service 864c92
cat "$testroot/stdout"
Packit Service 864c92
Packit Service 864c92
cat > "$testroot/stderr-expected" <
Packit Service 864c92
${common_objpfx}locale/locale: Cannot set LC_CTYPE to default locale: No such file or directory
Packit Service 864c92
${common_objpfx}locale/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
Packit Service 864c92
${common_objpfx}locale/locale: Cannot set LC_ALL to default locale: No such file or directory
Packit Service 864c92
warning: The LOCPATH variable is set to "does-not-exist"
Packit Service 864c92
EOF
Packit Service 864c92
Packit Service 864c92
cat > "$testroot/stdout-expected" <
Packit Service 864c92
LANG=
Packit Service 864c92
LC_CTYPE="invalid-locale"
Packit Service 864c92
LC_NUMERIC="invalid-locale"
Packit Service 864c92
LC_TIME="invalid-locale"
Packit Service 864c92
LC_COLLATE="invalid-locale"
Packit Service 864c92
LC_MONETARY="invalid-locale"
Packit Service 864c92
LC_MESSAGES="invalid-locale"
Packit Service 864c92
LC_PAPER="invalid-locale"
Packit Service 864c92
LC_NAME="invalid-locale"
Packit Service 864c92
LC_ADDRESS="invalid-locale"
Packit Service 864c92
LC_TELEPHONE="invalid-locale"
Packit Service 864c92
LC_MEASUREMENT="invalid-locale"
Packit Service 864c92
LC_IDENTIFICATION="invalid-locale"
Packit Service 864c92
LC_ALL=invalid-locale
Packit Service 864c92
EOF
Packit Service 864c92
Packit Service 864c92
errors=0
Packit Service 864c92
if ! cmp -s "$testroot/stderr-expected" "$testroot/stderr" ; then
Packit Service 864c92
    echo "error: standard error not correct"
Packit Service 864c92
    errors=1
Packit Service 864c92
fi
Packit Service 864c92
if ! cmp -s "$testroot/stdout-expected" "$testroot/stdout" ; then
Packit Service 864c92
    echo "error: standard output not correct"
Packit Service 864c92
    errors=1
Packit Service 864c92
fi
Packit Service 864c92
exit $errors