Blame locale/tst-locale-locpath.sh

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