summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-12-15 16:26:23 +0100
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:47 +0100
commit2676f3c9492c61ab65a8b490e72142a7ea1e869b (patch)
tree49a5b3d7480870890a77303b35eff821a51d19ae
parent87a07a4cc8592a937006c5cdb93739b185bdbd7c (diff)
downloadutil-linux-old-2676f3c9492c61ab65a8b490e72142a7ea1e869b.tar.gz
tests: add libmount utab tests
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--tests/expected/libmount/context-utab9
-rw-r--r--tests/expected/libmount/context-utab-mount-by-devname1
-rw-r--r--tests/expected/libmount/context-utab-mount-uhelper1
-rw-r--r--tests/expected/libmount/context-utab-mount-uhelper-subvol1
-rw-r--r--tests/expected/libmount/context-utab-umount1
-rw-r--r--tests/expected/libmount/context-utab-umount-by-devname1
-rw-r--r--tests/expected/libmount/context-utab-umount-subvol1
-rwxr-xr-xtests/ts/libmount/context-utab115
8 files changed, 130 insertions, 0 deletions
diff --git a/tests/expected/libmount/context-utab b/tests/expected/libmount/context-utab
new file mode 100644
index 00000000..cde2e3fb
--- /dev/null
+++ b/tests/expected/libmount/context-utab
@@ -0,0 +1,9 @@
+Init device
+Create partitions
+Create filesystem
+Do tests...
+Create filesystem [btrfs]
+All mount options (btrfs subvolume + utab) ---
+rw,relatime,ssd,uhelper=foo
+---
+...done.
diff --git a/tests/expected/libmount/context-utab-mount-by-devname b/tests/expected/libmount/context-utab-mount-by-devname
new file mode 100644
index 00000000..7504a7e8
--- /dev/null
+++ b/tests/expected/libmount/context-utab-mount-by-devname
@@ -0,0 +1 @@
+successfully mounted
diff --git a/tests/expected/libmount/context-utab-mount-uhelper b/tests/expected/libmount/context-utab-mount-uhelper
new file mode 100644
index 00000000..7504a7e8
--- /dev/null
+++ b/tests/expected/libmount/context-utab-mount-uhelper
@@ -0,0 +1 @@
+successfully mounted
diff --git a/tests/expected/libmount/context-utab-mount-uhelper-subvol b/tests/expected/libmount/context-utab-mount-uhelper-subvol
new file mode 100644
index 00000000..7504a7e8
--- /dev/null
+++ b/tests/expected/libmount/context-utab-mount-uhelper-subvol
@@ -0,0 +1 @@
+successfully mounted
diff --git a/tests/expected/libmount/context-utab-umount b/tests/expected/libmount/context-utab-umount
new file mode 100644
index 00000000..319236f1
--- /dev/null
+++ b/tests/expected/libmount/context-utab-umount
@@ -0,0 +1 @@
+successfully umounted
diff --git a/tests/expected/libmount/context-utab-umount-by-devname b/tests/expected/libmount/context-utab-umount-by-devname
new file mode 100644
index 00000000..319236f1
--- /dev/null
+++ b/tests/expected/libmount/context-utab-umount-by-devname
@@ -0,0 +1 @@
+successfully umounted
diff --git a/tests/expected/libmount/context-utab-umount-subvol b/tests/expected/libmount/context-utab-umount-subvol
new file mode 100644
index 00000000..319236f1
--- /dev/null
+++ b/tests/expected/libmount/context-utab-umount-subvol
@@ -0,0 +1 @@
+successfully umounted
diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab
new file mode 100755
index 00000000..db039d1f
--- /dev/null
+++ b/tests/ts/libmount/context-utab
@@ -0,0 +1,115 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="context (utab)"
+
+. $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=260
+[ "$?" == 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
+rm -f $LIBMOUNT_MTAB
+ln -s /proc/mounts $LIBMOUNT_MTAB
+
+export LIBMOUNT_UTAB=$TS_OUTPUT.utab
+rm -f $LIBMOUNT_UTAB
+> $LIBMOUNT_UTAB
+
+
+ts_init_subtest "mount-by-devname"
+mkdir -p $MOUNTPOINT &> /dev/null
+$TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE /proc/mounts || \
+ echo "(by device) cannot found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "umount-by-devname"
+$TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1
+grep -q $DEVICE /proc/mounts &&
+ echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-uhelper"
+mkdir -p $MOUNTPOINT &> /dev/null
+$TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_UTAB || \
+ echo "(by label) cannot found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "umount"
+$TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $LIBMOUNT_UTAB && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+if [ -x "/sbin/mkfs.btrfs" ]; then
+ ts_log "Create filesystem [btrfs]"
+ /sbin/mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
+ mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
+ /sbin/btrfsctl -S sub $MOUNTPOINT &> /dev/null
+ umount $MOUNTPOINT &> /dev/null
+
+ ts_init_subtest "mount-uhelper-subvol"
+ mkdir -p $MOUNTPOINT &> /dev/null
+ $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
+ grep -q $DEVICE $LIBMOUNT_UTAB || \
+ echo "cannot found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ ts_finalize_subtest
+
+ ts_log "All mount options (btrfs subvolume + utab) ---"
+ $TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1
+ ts_log "---"
+
+ ts_init_subtest "umount-subvol"
+ $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
+ grep -q $DEVICE $LIBMOUNT_UTAB && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
+ ts_finalize_subtest
+fi
+
+ts_log "...done."
+rmmod scsi_debug
+ts_finalize