~ubuntu-branches/ubuntu/quantal/util-linux/quantal

« back to all changes in this revision

Viewing changes to tests/ts/libmount/context-utab

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
 
4
 
 
5
TS_TOPDIR="$(dirname $0)/../.."
 
6
TS_DESC="context (utab)"
 
7
 
 
8
. $TS_TOPDIR/functions.sh
 
9
ts_init "$*"
 
10
ts_skip_nonroot
 
11
 
 
12
TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
 
13
LABEL=libmount-test
 
14
UUID=$(uuidgen)
 
15
MOUNTPOINT="$TS_MOUNTPOINT"
 
16
 
 
17
[ -x $TESTPROG ] || ts_skip "test not compiled"
 
18
 
 
19
modprobe --dry-run --quiet scsi_debug
 
20
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
 
21
 
 
22
ts_log "Init device"
 
23
rmmod scsi_debug &> /dev/null
 
24
modprobe scsi_debug dev_size_mb=260
 
25
[ "$?" == 0 ] || ts_die "Cannot init device"
 
26
 
 
27
sleep 3
 
28
 
 
29
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
 
30
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot found device"
 
31
 
 
32
DEVICE="/dev/${DEVNAME}"
 
33
 
 
34
ts_log "Create partitions"
 
35
$TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 <<EOF
 
36
n
 
37
p
 
38
1
 
39
 
 
40
 
 
41
w
 
42
q
 
43
EOF
 
44
 
 
45
DEVICE="/dev/${DEVNAME}1"
 
46
 
 
47
sleep 3
 
48
 
 
49
ts_log "Create filesystem"
 
50
mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
 
51
 
 
52
ts_log "Do tests..."
 
53
 
 
54
export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
 
55
rm -f $LIBMOUNT_MTAB
 
56
ln -s /proc/mounts $LIBMOUNT_MTAB
 
57
 
 
58
export LIBMOUNT_UTAB=$TS_OUTPUT.utab
 
59
rm -f $LIBMOUNT_UTAB
 
60
> $LIBMOUNT_UTAB
 
61
 
 
62
 
 
63
ts_init_subtest "mount-by-devname"
 
64
mkdir -p $MOUNTPOINT &>  /dev/null
 
65
$TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
66
grep -q $DEVICE /proc/mounts || \
 
67
        echo "(by device) cannot found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
 
68
ts_finalize_subtest
 
69
 
 
70
ts_init_subtest "umount-by-devname"
 
71
$TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1
 
72
grep -q $DEVICE /proc/mounts &&
 
73
        echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
 
74
ts_finalize_subtest
 
75
 
 
76
 
 
77
ts_init_subtest "mount-uhelper"
 
78
mkdir -p $MOUNTPOINT &>  /dev/null
 
79
$TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
80
grep -q $DEVICE $LIBMOUNT_UTAB || \
 
81
        echo "(by label) cannot found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
 
82
ts_finalize_subtest
 
83
 
 
84
ts_init_subtest "umount"
 
85
$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
86
grep -q $DEVICE $LIBMOUNT_UTAB && \
 
87
        echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
 
88
ts_finalize_subtest
 
89
 
 
90
if [ -x "/sbin/mkfs.btrfs" ]; then
 
91
        ts_log "Create filesystem [btrfs]"
 
92
        /sbin/mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
 
93
        mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
 
94
        /sbin/btrfsctl -S sub $MOUNTPOINT &> /dev/null
 
95
        umount $MOUNTPOINT &> /dev/null
 
96
 
 
97
        ts_init_subtest "mount-uhelper-subvol"
 
98
        mkdir -p $MOUNTPOINT &>  /dev/null
 
99
        $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE  $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
100
        grep -q $DEVICE $LIBMOUNT_UTAB || \
 
101
                echo "cannot found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
 
102
        ts_finalize_subtest
 
103
 
 
104
        ts_log "All mount options (btrfs subvolume + utab) ---"
 
105
        $TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1
 
106
        ts_log "---"
 
107
 
 
108
        ts_init_subtest "umount-subvol"
 
109
        $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
110
        grep -q $DEVICE $LIBMOUNT_UTAB && \
 
111
                echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
 
112
        ts_finalize_subtest
 
113
fi
 
114
 
 
115
ts_log "...done."
 
116
rmmod scsi_debug
 
117
ts_finalize