elf: Add a way to check if tunable is set (BZ 27069)
[glibc.git] / elf / tst-ldconfig-p.sh
blob981e3a451a932cdd1cdbe02af12c3e7b338ac9ca
1 #!/bin/sh
2 # Test that ldconfig -p prints something useful.
3 # Copyright (C) 2023 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 # Check that the newly built ldconfig -p can dump the system
21 # /etc/ld.so.cache file. This should always work even if the ABIs are
22 # not compatible, except in a cross-endian build (that presumably
23 # involves emulation when running ldconfig).
25 common_objpfx=$1
26 sysconfdir=$2
27 test_wrapper_env=$3
28 run_program_env=$4
30 if ! test -r "${sysconfdir}/ld.so.cache"; then
31 echo "warning: ${sysconfdir}/ld.so.cache does not exist, test skipped"
32 exit 77
35 testout="${common_objpfx}elf/tst-ldconfig-p.out"
36 # Truncate file.
37 : > "$testout"
39 ${test_wrapper_env} \
40 ${run_program_env} \
41 ${common_objpfx}elf/ldconfig -p \
42 $testroot/lib >>"$testout" 2>>"$testout"
43 status=$?
44 echo "info: ldconfig exit status: $status" >>"$testout"
46 errors=0
47 case $status in
48 (0)
49 if head -n 1 "$testout" | \
50 grep -q "libs found in cache \`${sysconfdir}/ld.so.cache'\$" ; then
51 echo "info: initial string found" >>"$testout"
52 else
53 echo "error: initial string not found" >>"$testout"
54 errors=1
56 if grep -q "^ libc\.so\..* => " "$testout"; then
57 echo "info: libc.so.* string found" >>"$testout"
58 else
59 echo "error: libc.so.* string not found" >>"$testout"
60 errors=1
63 (1)
64 if head -n 1 "$testout" | \
65 grep -q ": Cache file has wrong endianness\.$" ; then
66 echo "info: cache file has wrong endianness" >> "$testout"
67 else
68 echo "error: unexpected ldconfig error message" >> "$testout"
69 errors=1
72 (*)
73 echo "error: unexpected exit status" >> "$testout"
74 errors=1
76 esac
78 exit $errors