2
# Test df's behaviour when the mount list cannot be read.
3
# This test is skipped on systems that lack LD_PRELOAD support; that's fine.
5
# Copyright (C) 2012 Free Software Foundation, Inc.
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
23
df || skip_ "df fails"
25
# Simulate "mtab" failure.
26
cat > k.c <<'EOF' || framework_failure_
31
struct mntent *getmntent (FILE *fp)
33
/* Prove that LD_PRELOAD works. */
37
fclose (fopen ("x", "w"));
40
/* Now simulate the failure. */
46
# Then compile/link it:
47
$CC -shared -fPIC -ldl -O2 k.c -o k.so \
48
|| skip_ "getmntent hack does not work on this platform"
50
# Test if LD_PRELOAD works:
52
test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
54
# These tests are supposed to succeed:
55
LD_PRELOAD=./k.so df '.' || fail=1
56
LD_PRELOAD=./k.so df -i '.' || fail=1
57
LD_PRELOAD=./k.so df -T '.' || fail=1
58
LD_PRELOAD=./k.so df -Ti '.' || fail=1
59
LD_PRELOAD=./k.so df --total '.' || fail=1
61
# These tests are supposed to fail:
62
LD_PRELOAD=./k.so df && fail=1
63
LD_PRELOAD=./k.so df -i && fail=1
64
LD_PRELOAD=./k.so df -T && fail=1
65
LD_PRELOAD=./k.so df -Ti && fail=1
66
LD_PRELOAD=./k.so df --total && fail=1
68
LD_PRELOAD=./k.so df -a && fail=1
69
LD_PRELOAD=./k.so df -a '.' && fail=1
71
LD_PRELOAD=./k.so df -l && fail=1
72
LD_PRELOAD=./k.so df -l '.' && fail=1
74
LD_PRELOAD=./k.so df -t hello && fail=1
75
LD_PRELOAD=./k.so df -t hello '.' && fail=1
77
LD_PRELOAD=./k.so df -x hello && fail=1
78
LD_PRELOAD=./k.so df -x hello '.' && fail=1