summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-11-22 23:15:00 +0100
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:46 +0100
commit40829d8589aee7805260f345f646512c6596e5a0 (patch)
tree182efe4cd822ecaa49c3499236574ceca107b1c7
parente548d51d552f2818064e218809a7ac00e89b6f39 (diff)
downloadutil-linux-old-40829d8589aee7805260f345f646512c6596e5a0.tar.gz
tests: add basic libmount tests for mounting
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--tests/commands.sh.in1
-rw-r--r--tests/expected/libmount/mount5
-rwxr-xr-xtests/ts/libmount/mount83
-rwxr-xr-xtests/ts/libmount/update4
4 files changed, 90 insertions, 3 deletions
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
index d39dcb98..9e568106 100644
--- a/tests/commands.sh.in
+++ b/tests/commands.sh.in
@@ -21,6 +21,7 @@ TS_HELPER_LIBMOUNT_TAB="$top_builddir/shlibs/mount/src/test_tab"
TS_HELPER_LIBMOUNT_UTILS="$top_builddir/shlibs/mount/src/test_utils"
TS_HELPER_LIBMOUNT_LOCK="$top_builddir/shlibs/mount/src/test_lock"
TS_HELPER_LIBMOUNT_UPDATE="$top_builddir/shlibs/mount/src/test_tab_update"
+TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/shlibs/mount/src/test_context"
# TODO: use partx
TS_HELPER_PARTITIONS="$top_builddir/shlibs/blkid/samples/partitions"
diff --git a/tests/expected/libmount/mount b/tests/expected/libmount/mount
new file mode 100644
index 00000000..5e268a31
--- /dev/null
+++ b/tests/expected/libmount/mount
@@ -0,0 +1,5 @@
+Init device
+Create partitions
+Create filesystem
+Do tests...
+...done.
diff --git a/tests/ts/libmount/mount b/tests/ts/libmount/mount
new file mode 100755
index 00000000..75fcd0a7
--- /dev/null
+++ b/tests/ts/libmount/mount
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="mount"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
+LABEL=libmount-test
+UUID=$(uuidgen)
+
+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 "by-devname"
+mkdir -p $TS_MOUNTPOINT &> /dev/null
+$TESTPROG --mount $DEVICE $TS_MOUNTPOINT &> $TS_OUTPUT
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "(by device) cannot found $DEVICE in $LIBMOUNT_MTAB" &> $TS_OUTPUT
+umount $TS_MOUNTPOINT
+ts_finalize_subtest
+
+
+ts_init_subtest "by-label"
+mkdir -p $TS_MOUNTPOINT &> /dev/null
+$TESTPROG --mount LABEL="$LABEL" $TS_MOUNTPOINT &> $TS_OUTPUT
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "(by label) cannot found $DEVICE in $LIBMOUNT_MTAB" &> $TS_OUTPUT
+umount $TS_MOUNTPOINT
+ts_finalize_subtest
+
+
+ts_init_subtest "by-uuid"
+mkdir -p $TS_MOUNTPOINT &> /dev/null
+$TESTPROG --mount UUID="$UUID" $TS_MOUNTPOINT &> $TS_OUTPUT
+grep -q $DEVICE $LIBMOUNT_MTAB || \
+ echo "(by uuid) cannot found $DEVICE in $LIBMOUNT_MTAB" &> $TS_OUTPUT
+umount $TS_MOUNTPOINT
+ts_finalize_subtest
+
+ts_log "...done."
+rmmod scsi_debug
+ts_finalize
diff --git a/tests/ts/libmount/update b/tests/ts/libmount/update
index 92c92b08..b895ba05 100755
--- a/tests/ts/libmount/update
+++ b/tests/ts/libmount/update
@@ -23,8 +23,6 @@ TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE"
# Traditional /etc/mtab
#
export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
-
-rm $LIBMOUNT_MTAB
> $LIBMOUNT_MTAB
ts_init_subtest "mtab-mount"
@@ -56,7 +54,7 @@ ts_finalize_subtest # checks the mtab
#
# utab
#
-rm $LIBMOUNT_MTAB
+rm -f $LIBMOUNT_MTAB
ln -s /proc/mounts $LIBMOUNT_MTAB
export LIBMOUNT_UTAB=$TS_OUTPUT.utab