summaryrefslogtreecommitdiffstats
path: root/tests/ts/libmount/context
diff options
context:
space:
mode:
authorKarel Zak2010-11-23 13:06:46 +0100
committerKarel Zak2011-01-03 12:28:46 +0100
commit64a2331f6d03fd483820ddacd8c62336b2e7df5c (patch)
tree355d0c8008875d636949f509a25f0f593e4193c9 /tests/ts/libmount/context
parentlibmount: add new debug messages, fix umount return code (diff)
downloadkernel-qcow2-util-linux-64a2331f6d03fd483820ddacd8c62336b2e7df5c.tar.gz
kernel-qcow2-util-linux-64a2331f6d03fd483820ddacd8c62336b2e7df5c.tar.xz
kernel-qcow2-util-linux-64a2331f6d03fd483820ddacd8c62336b2e7df5c.zip
tests: improve libmount context mount and umount test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/ts/libmount/context')
-rwxr-xr-xtests/ts/libmount/context111
1 files changed, 111 insertions, 0 deletions
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context
new file mode 100755
index 000000000..66e2dab02
--- /dev/null
+++ b/tests/ts/libmount/context
@@ -0,0 +1,111 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="context"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
+LABEL=libmount-test
+UUID=$(uuidgen)
+MOUNTPOINT="$TS_MOUNTPOINT"
+
+modprobe --dry-run --quiet scsi_debug
+[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
+
+ts_log "Init device"
+rmmod scsi_debug &> /dev/null
+modprobe scsi_debug dev_size_mb=100
+[ "$?" == 0 ] || ts_die "Cannot init device"
+
+sleep 3
+
+DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
+[ "x${DEVNAME}" == "x" ] && ts_die "Cannot found device"
+
+DEVICE="/dev/${DEVNAME}"
+
+ts_log "Create partitions"
+$TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 <<EOF
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="/dev/${DEVNAME}1"
+
+sleep 3
+
+ts_log "Create filesystem"
+mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
+
+ts_log "Do tests..."
+
+export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
+> $LIBMOUNT_MTAB
+
+
+ts_init_subtest "mount-by-devname"
+mkdir -p $MOUNTPOINT &> /dev/null
+$TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "(by device) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-devname"
+$TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB &&
+ echo "umount (device) failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-by-label"
+mkdir -p $MOUNTPOINT &> /dev/null
+$TESTPROG --mount LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "(by label) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-mountpoint"
+$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-by-uuid"
+mkdir -p $MOUNTPOINT &> /dev/null
+$TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "(by uuid) cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB &&
+ echo "umount failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-flags"
+mkdir -p $MOUNTPOINT &> /dev/null
+$TESTPROG --mount -o ro,noexec,nosuid,strictatime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
+$TS_CMD_FINDMNT --kernel $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "cannot found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_MTAB &&
+ echo "umount failed: found $DEVICE in $LIBMOUNT_MTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_log "...done."
+rmmod scsi_debug
+ts_finalize