~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/df/no-mtab-status.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
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.
 
4
 
 
5
# Copyright (C) 2012 Free Software Foundation, Inc.
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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/>.
 
19
 
 
20
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
21
print_ver_ df
 
22
 
 
23
df || skip_ "df fails"
 
24
 
 
25
# Simulate "mtab" failure.
 
26
cat > k.c <<'EOF' || framework_failure_
 
27
#include <stdio.h>
 
28
#include <errno.h>
 
29
#include <mntent.h>
 
30
 
 
31
struct mntent *getmntent (FILE *fp)
 
32
{
 
33
  /* Prove that LD_PRELOAD works. */
 
34
  static int done = 0;
 
35
  if (!done)
 
36
    {
 
37
      fclose (fopen ("x", "w"));
 
38
      ++done;
 
39
    }
 
40
  /* Now simulate the failure. */
 
41
  errno = ENOENT;
 
42
  return NULL;
 
43
}
 
44
EOF
 
45
 
 
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"
 
49
 
 
50
# Test if LD_PRELOAD works:
 
51
LD_PRELOAD=./k.so df
 
52
test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
 
53
 
 
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
 
60
 
 
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
 
67
 
 
68
LD_PRELOAD=./k.so df -a && fail=1
 
69
LD_PRELOAD=./k.so df -a '.' && fail=1
 
70
 
 
71
LD_PRELOAD=./k.so df -l && fail=1
 
72
LD_PRELOAD=./k.so df -l '.' && fail=1
 
73
 
 
74
LD_PRELOAD=./k.so df -t hello && fail=1
 
75
LD_PRELOAD=./k.so df -t hello '.' && fail=1
 
76
 
 
77
LD_PRELOAD=./k.so df -x hello && fail=1
 
78
LD_PRELOAD=./k.so df -x hello '.' && fail=1
 
79
 
 
80
Exit $fail