3
# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
5
TS_TOPDIR="$(dirname $0)/../.."
8
. $TS_TOPDIR/functions.sh
12
TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
15
MOUNTPOINT="$TS_MOUNTPOINT"
19
[ -x $TESTPROG ] || ts_skip "test not compiled"
21
modprobe --dry-run --quiet scsi_debug
22
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
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"
32
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
33
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot found device"
35
DEVICE="/dev/${DEVNAME}"
37
ts_log "Create partitions"
38
$TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 <<EOF
48
DEVICE="/dev/${DEVNAME}1"
52
ts_log "Create filesystem"
53
mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
57
export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
61
ts_init_subtest "mount-by-devname"
62
mkdir -p $MOUNTPOINT &> /dev/null
63
$TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
65
grep -q $DEVICE $LIBMOUNT_MTAB || \
66
echo "(by device) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
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
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
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
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
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