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

« back to all changes in this revision

Viewing changes to tests/ts/libmount/context

  • 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"
 
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
#set -x
 
18
 
 
19
[ -x $TESTPROG ] || ts_skip "test not compiled"
 
20
 
 
21
modprobe --dry-run --quiet scsi_debug
 
22
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
 
23
 
 
24
ts_log "Init device"
 
25
umount $MOUNTPOINT &> /dev/null
 
26
rmmod scsi_debug &> /dev/null
 
27
modprobe scsi_debug dev_size_mb=100
 
28
[ "$?" == 0 ] || ts_die "Cannot init device"
 
29
 
 
30
sleep 3
 
31
 
 
32
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
 
33
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot found device"
 
34
 
 
35
DEVICE="/dev/${DEVNAME}"
 
36
 
 
37
ts_log "Create partitions"
 
38
$TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 <<EOF
 
39
n
 
40
p
 
41
1
 
42
 
 
43
 
 
44
w
 
45
q
 
46
EOF
 
47
 
 
48
DEVICE="/dev/${DEVNAME}1"
 
49
 
 
50
sleep 3
 
51
 
 
52
ts_log "Create filesystem"
 
53
mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
 
54
 
 
55
ts_log "Do tests..."
 
56
 
 
57
export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
 
58
> $LIBMOUNT_MTAB
 
59
 
 
60
 
 
61
ts_init_subtest "mount-by-devname"
 
62
mkdir -p $MOUNTPOINT &>  /dev/null
 
63
$TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
64
 
 
65
grep -q $DEVICE $LIBMOUNT_MTAB || \
 
66
        echo "(by device) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
67
ts_finalize_subtest
 
68
 
 
69
ts_init_subtest "umount-by-devname"
 
70
$TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1
 
71
grep -q $DEVICE $LIBMOUNT_MTAB &&
 
72
        echo "umount (device) failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
73
ts_finalize_subtest
 
74
 
 
75
#exit 1
 
76
 
 
77
ts_init_subtest "mount-by-label"
 
78
mkdir -p $MOUNTPOINT &>  /dev/null
 
79
$TESTPROG --mount LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
80
grep -q $DEVICE $LIBMOUNT_MTAB || \
 
81
        echo "(by label) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
82
ts_finalize_subtest
 
83
 
 
84
 
 
85
ts_init_subtest "umount-by-mountpoint"
 
86
$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
87
grep -q $DEVICE $LIBMOUNT_MTAB && \
 
88
        echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
89
ts_finalize_subtest
 
90
 
 
91
 
 
92
ts_init_subtest "mount-by-uuid"
 
93
mkdir -p $MOUNTPOINT &> /dev/null
 
94
$TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
95
grep -q $DEVICE $LIBMOUNT_MTAB || \
 
96
        echo "(by uuid) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
97
$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
98
grep -q $DEVICE $LIBMOUNT_MTAB &&
 
99
        echo "umount failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
100
ts_finalize_subtest
 
101
 
 
102
 
 
103
ts_init_subtest "mount-flags"
 
104
mkdir -p $MOUNTPOINT &> /dev/null
 
105
$TESTPROG --mount -o ro,noexec,nosuid,strictatime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
106
$TS_CMD_FINDMNT --kernel $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>&1
 
107
grep -q $DEVICE $LIBMOUNT_MTAB || \
 
108
        echo "cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
109
$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
 
110
grep -q $DEVICE $LIBMOUNT_MTAB &&
 
111
        echo "umount failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
 
112
ts_finalize_subtest
 
113
 
 
114
 
 
115
ts_log "...done."
 
116
rmmod scsi_debug
 
117
ts_finalize