]> err.no Git - util-linux/commitdiff
tests: add basic libmount tests for mounting
authorKarel Zak <kzak@redhat.com>
Mon, 22 Nov 2010 22:15:00 +0000 (23:15 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:46 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/commands.sh.in
tests/expected/libmount/mount [new file with mode: 0644]
tests/ts/libmount/mount [new file with mode: 0755]
tests/ts/libmount/update

index d39dcb9804bb92caa7b1833f707049be52478b53..9e56810626f78cd5d0a8d70d3ea6093015d6dcb3 100644 (file)
@@ -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 (file)
index 0000000..5e268a3
--- /dev/null
@@ -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 (executable)
index 0000000..75fcd0a
--- /dev/null
@@ -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
index 92c92b081ae05ba9a769a93dad79ffe594931a9c..b895ba05accf7f41a279713cdac04e130d54a19d 100755 (executable)
@@ -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