summaryrefslogtreecommitdiffstats
path: root/tests/ts/libmount/context
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtests/ts/libmount/context176
-rwxr-xr-xtests/ts/libmount/context-py166
-rwxr-xr-xtests/ts/libmount/context-utab133
-rwxr-xr-xtests/ts/libmount/context-utab-py138
4 files changed, 613 insertions, 0 deletions
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context
new file mode 100755
index 0000000..babeec9
--- /dev/null
+++ b/tests/ts/libmount/context
@@ -0,0 +1,176 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="context"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_UUIDGEN"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext3"
+ts_check_prog "mkfs.ext4"
+
+TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
+LABEL=libmount-test
+UUID=$($TS_CMD_UUIDGEN)
+
+MOUNTPOINT="$TS_MOUNTPOINT"
+[ -x $TESTPROG ] || ts_skip "test not compiled"
+
+ts_log "Init device"
+$TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=100
+DEVNAME=$(basename $TS_DEVICE)
+
+MOUNTINFO_ONLY=yes
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MOUNTINFO_ONLY=no
+fi
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+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
+
+# check local mtab of system mountinfo
+function is_mounted {
+ if [ "$MOUNTINFO_ONLY" = "yes" ]; then
+ ts_is_mounted "$1"
+ return $?
+ fi
+ grep -q "$1" $LIBMOUNT_MTAB && return 0
+ return 1
+}
+
+
+udevadm settle
+ts_device_has "TYPE" "ext4" $DEVICE || ts_die "Cannot find ext3 on $DEVICE"
+
+
+ts_init_subtest "mount-by-devname"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_run $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-devname"
+ts_run $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-by-label"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_run $TESTPROG --mount LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-mountpoint"
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-by-uuid"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_run $TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+sleep 1
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+sleep 1
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-flags"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_run $TESTPROG --mount -o ro,noexec,nosuid,strictatime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_run $TESTPROG --mount -o remount,rw $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-loopdev"
+mkdir -p $MOUNTPOINT &> /dev/null
+img=$(ts_image_init)
+mkfs.ext3 -F $img &> /dev/null
+udevadm settle
+
+ts_run $TESTPROG --mount -o loop $img $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $MOUNTPOINT || echo "$MOUNTPOINT not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $MOUNTPOINT && echo "$MOUNTPOINT still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+# deprecated (x-* mount option maintained in userspace (e.g. utab)
+ts_init_subtest "x-permanent"
+TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
+[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
+
+$TS_CMD_MOUNT -o x-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>> $TS_ERRLOG &&
+ echo "successfully mounted" >> $TS_OUTPUT
+ts_finalize_subtest
+
+$TS_CMD_UMOUNT $TS_NOEXIST
+rmdir $TS_NOEXIST
+
+
+# X-* comment
+ts_init_subtest "X-comment"
+TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
+[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
+
+$TS_CMD_MOUNT -o X-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>> $TS_ERRLOG &&
+ echo "successfully mounted" >> $TS_OUTPUT
+ts_finalize_subtest
+
+$TS_CMD_UMOUNT $TS_NOEXIST
+rmdir $TS_NOEXIST
+
+ts_log "...done."
+ts_finalize
diff --git a/tests/ts/libmount/context-py b/tests/ts/libmount/context-py
new file mode 100755
index 0000000..959d790
--- /dev/null
+++ b/tests/ts/libmount/context-py
@@ -0,0 +1,166 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="context-py"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_UUIDGEN"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext3"
+ts_check_prog "mkfs.ext4"
+
+ts_init_py libmount
+
+if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then
+ TS_KNOWN_FAIL="yes"
+fi
+
+TESTPROG="$TS_HELPER_PYLIBMOUNT_CONTEXT"
+[ -x $TESTPROG ] || ts_die "test script missing"
+
+PYDBG="$PYTHON -m pdb"
+LABEL=libmount-test
+UUID=$($TS_CMD_UUIDGEN)
+MOUNTPOINT="$TS_MOUNTPOINT"
+TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
+[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
+
+ts_log "Init device"
+$TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=100
+DEVNAME=$(basename $TS_DEVICE)
+
+MOUNTINFO_ONLY=yes
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MOUNTINFO_ONLY=no
+fi
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+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
+
+# check local mtab of system mountinfo
+function is_mounted {
+ if [ "$MOUNTINFO_ONLY" = "yes" ]; then
+ ts_is_mounted "$1"
+ return $?
+ fi
+ grep -q "\(^\| \)$1 " $LIBMOUNT_MTAB && return 0
+ return 1
+}
+
+
+udevadm settle
+ts_device_has "TYPE" "ext4" $DEVICE || ts_die "Cannot find ext3 on $DEVICE"
+
+
+ts_init_subtest "mount-by-devname"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-devname"
+$PYTHON $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-by-label"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-mountpoint"
+$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-by-uuid"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-flags"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount -o ro,noexec,nosuid,strictatime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT --kernel $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$PYTHON $TESTPROG --mount -o remount,rw $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT --kernel $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-loopdev"
+mkdir -p $MOUNTPOINT &> /dev/null
+img=$(ts_image_init)
+mkfs.ext3 -F $img &> /dev/null
+udevadm settle
+
+$PYTHON $TESTPROG --mount -o loop $img $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $MOUNTPOINT || echo "$MOUNTPOINT not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
+$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $MOUNTPOINT && echo "$MOUNTPOINT still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "x-mount.mkdir"
+$TS_CMD_MOUNT -o x-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>> $TS_ERRLOG &&
+ echo "successfully mounted" >> $TS_OUTPUT
+ts_finalize_subtest
+
+
+$TS_CMD_UMOUNT $TS_NOEXIST
+rmdir $TS_NOEXIST
+
+ts_log "...done."
+ts_finalize
diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab
new file mode 100755
index 0000000..47a6769
--- /dev/null
+++ b/tests/ts/libmount/context-utab
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="context (utab)"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+#ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_test_command "$TS_CMD_UUIDGEN"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext4"
+
+TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT"
+LABEL=libmount-test
+UUID=$($TS_CMD_UUIDGEN)
+MOUNTPOINT="$TS_MOUNTPOINT"
+
+[ -x $TESTPROG ] || ts_skip "test not compiled"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=257
+DEVNAME=$(basename $TS_DEVICE)
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+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
+
+udevadm settle
+
+ts_init_subtest "mount-by-devname"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_run $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted "$DEVICE" || \
+ echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-devname"
+ts_run $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted "$DEVICE" &&
+ echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-uhelper"
+mkdir -p $MOUNTPOINT &> /dev/null
+ts_run $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
+ echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount"
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then
+ $TS_CMD_WIPEFS -a $DEVICE &> /dev/null
+ #ts_log "Create filesystem [btrfs]"
+ mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
+ udevadm settle
+
+ $TS_CMD_MOUNT -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
+ btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
+ $TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null
+
+ udevadm settle
+
+ ts_init_subtest "mount-uhelper-subvol"
+ mkdir -p $MOUNTPOINT &> /dev/null
+ ts_run $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
+ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ ts_finalize_subtest
+
+ # Don't temporary write btrfs mount options to the test output,
+ # the options depend on kernel version (since 4.2 it contains
+ # subvol= and subvolid=).
+ #
+ #ts_log "All mount options (btrfs subvolume + utab) ---"
+ #$TS_CMD_FINDMNT --mtab --mountpoint $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+ #ts_log "---"
+
+ ts_init_subtest "umount-subvol"
+ ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ ts_finalize_subtest
+fi
+
+ts_log "...done."
+ts_finalize
diff --git a/tests/ts/libmount/context-utab-py b/tests/ts/libmount/context-utab-py
new file mode 100755
index 0000000..94c9e5b
--- /dev/null
+++ b/tests/ts/libmount/context-utab-py
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="context-py (utab)"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_test_command "$TS_CMD_UUIDGEN"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext4"
+
+ts_init_py libmount
+
+if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then
+ TS_KNOWN_FAIL="yes"
+fi
+
+TESTPROG="$TS_HELPER_PYLIBMOUNT_CONTEXT"
+[ -x $TESTPROG ] || ts_die "test script missing"
+
+LABEL=libmount-test
+UUID=$($TS_CMD_UUIDGEN)
+MOUNTPOINT="$TS_MOUNTPOINT"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=257
+DEVNAME=$(basename $TS_DEVICE)
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
+
+w
+q
+EOF
+
+DEVICE="${TS_DEVICE}1"
+
+udevadm settle
+
+grep -q " $DEVNAME\$" /proc/partitions
+if [ $? -ne 0 ]; then
+ ts_skip "no partition!"
+fi
+
+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
+
+udevadm settle
+
+ts_init_subtest "mount-by-devname"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted "$DEVICE" || \
+ echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount-by-devname"
+$PYTHON $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted "$DEVICE" &&
+ echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-uhelper"
+mkdir -p $MOUNTPOINT &> /dev/null
+$PYTHON $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
+ echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "umount"
+$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then
+ $TS_CMD_WIPEFS -a $DEVICE &> /dev/null
+ #ts_log "Create filesystem [btrfs]"
+ mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
+ udevadm settle
+
+ $TS_CMD_MOUNT -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
+ btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
+ $TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null
+
+ udevadm settle
+
+ ts_init_subtest "mount-uhelper-subvol"
+ mkdir -p $MOUNTPOINT &> /dev/null
+ $PYTHON $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
+ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ ts_finalize_subtest
+
+ # Don't temporary write btrfs mount options to the test output,
+ # the options depend on kernel version (since 4.2 it contains
+ # subvol= and subvolid=).
+ #
+ #ts_log "All mount options (btrfs subvolume + utab) ---"
+ #$TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+ #ts_log "---"
+
+ ts_init_subtest "umount-subvol"
+ $PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ grep -q $DEVICE $LIBMOUNT_UTAB && \
+ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ ts_finalize_subtest
+fi
+
+ts_log "...done."
+ts_finalize