diff options
Diffstat (limited to 'tests/ts/libmount')
28 files changed, 1837 insertions, 0 deletions
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context new file mode 100755 index 0000000..70c779c --- /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.ext2" +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 ext2 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.ext2 -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..a6a0816 --- /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.ext2" +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 ext2 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.ext2 -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 diff --git a/tests/ts/libmount/debug b/tests/ts/libmount/debug new file mode 100755 index 0000000..5507d54 --- /dev/null +++ b/tests/ts/libmount/debug @@ -0,0 +1,30 @@ +#!/bin/bash + +# Copyright (C) 2014 Ondrej Oprala <ooprala@redhat.com + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="debugging" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_DEBUG" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +# CACHE | LOCKS +ts_init_subtest "set-from-code" +ts_run $TESTPROG 20 2>&1 | grep -o '0x.*' &> $TS_OUTPUT +ts_finalize_subtest + +# CACHE | LOCKS +ts_init_subtest "set-from-env-str" +LIBMOUNT_DEBUG=cache,locks ts_run $TESTPROG 2>&1 | grep -o '0x.*' &> $TS_OUTPUT +ts_finalize_subtest + +# CACHE | LOCKS +ts_init_subtest "set-from-env-int" +LIBMOUNT_DEBUG=20 ts_run $TESTPROG 2>&1 | grep -o '0x.*' &> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/files/fstab b/tests/ts/libmount/files/fstab new file mode 100644 index 0000000..a8f73bc --- /dev/null +++ b/tests/ts/libmount/files/fstab @@ -0,0 +1,14 @@ +UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1 +UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2 +UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +sysfs /sys sysfs defaults 0 0 +proc /proc proc defaults 0 0 +# this is comment +/dev/mapper/foo /home/foo ext4 noatime,defaults 0 0 + +foo.com:/mnt/share /mnt/remote nfs noauto +//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto + +/dev/foo /any/foo/ auto defaults 0 0 diff --git a/tests/ts/libmount/files/fstab.broken b/tests/ts/libmount/files/fstab.broken new file mode 100644 index 0000000..c79f026 --- /dev/null +++ b/tests/ts/libmount/files/fstab.broken @@ -0,0 +1,14 @@ +bug +UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1 +UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2 + UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +devpts /dev/pts devpts gid=5,mode=620 + sysfs /sys sysfs defaults 0 0 +this is broken line with unexpected number of fields +proc /proc proc defaults 0 0 +# this is comment +/dev/mapper/foo /home/foo ext4 noatime,defaults 1 + +foo.com:/mnt/share /mnt/remote nfs noauto +//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto diff --git a/tests/ts/libmount/files/fstab.comment b/tests/ts/libmount/files/fstab.comment new file mode 100644 index 0000000..656e663 --- /dev/null +++ b/tests/ts/libmount/files/fstab.comment @@ -0,0 +1,22 @@ +# + # this is a leading comment +# + +# this comments belongs to the first fs +UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1 +UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2 + +# 3rd fs comment + newline padding + +UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +sysfs /sys sysfs defaults 0 0 +proc /proc proc defaults 0 0 +# this is comment +/dev/mapper/foo /home/foo ext4 noatime,defaults 0 0 +foo.com:/mnt/share /mnt/remote nfs noauto +//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto +/dev/foo /any/foo/ auto defaults 0 0 + +#this is a trailing comment diff --git a/tests/ts/libmount/files/kernel_cmdline b/tests/ts/libmount/files/kernel_cmdline new file mode 100644 index 0000000..37a0c89 --- /dev/null +++ b/tests/ts/libmount/files/kernel_cmdline @@ -0,0 +1 @@ +rd.md=0 rd.lvm=0 rd.dm=0 KEYTABLE=us root=UUID=33230ae2-1093-4353-824c-f7ca09a2a882 rd.luks=0 SYSFONT=latarcyrheb-sun16 ro LANG=en_US.UTF-8 selinux=0 diff --git a/tests/ts/libmount/files/mountinfo b/tests/ts/libmount/files/mountinfo new file mode 100644 index 0000000..2b01740 --- /dev/null +++ b/tests/ts/libmount/files/mountinfo @@ -0,0 +1,33 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 +49 20 0:56 / /mnt/test/foo
bar rw,relatime shared:323 - tmpfs tmpfs rw diff --git a/tests/ts/libmount/files/mountinfo_mv b/tests/ts/libmount/files/mountinfo_mv new file mode 100644 index 0000000..3d55aff --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_mv @@ -0,0 +1,32 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/music rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/libmount/files/mountinfo_nosrc b/tests/ts/libmount/files/mountinfo_nosrc new file mode 100644 index 0000000..1ef7cf0 --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_nosrc @@ -0,0 +1,7 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 20 0:53 / /mnt/test rw,relatime shared:212 - tmpfs rw diff --git a/tests/ts/libmount/files/mountinfo_re b/tests/ts/libmount/files/mountinfo_re new file mode 100644 index 0000000..df379fa --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_re @@ -0,0 +1,32 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +41 20 253:0 / /home/kzak ro,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ ro,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/libmount/files/mountinfo_u b/tests/ts/libmount/files/mountinfo_u new file mode 100644 index 0000000..a3dde97 --- /dev/null +++ b/tests/ts/libmount/files/mountinfo_u @@ -0,0 +1,31 @@ +15 20 0:3 / /proc rw,relatime - proc /proc rw +16 20 0:15 / /sys rw,relatime - sysfs /sys rw +17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755 +18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw +20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered +21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 +22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset +24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns +25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu +26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct +27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory +28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices +29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer +30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls +31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio +32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw +38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw +39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw +40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered +42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw +43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw +44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500 +45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw +47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 diff --git a/tests/ts/libmount/files/mtab b/tests/ts/libmount/files/mtab new file mode 100644 index 0000000..93bc90e --- /dev/null +++ b/tests/ts/libmount/files/mtab @@ -0,0 +1,12 @@ +/dev/sda4 / ext3 rw,noatime 0 0 +proc /proc proc rw 0 0 +sysfs /sys sysfs rw 0 0 +devpts /dev/pts devpts rw,gid=5,mode=620 0 0 +tmpfs /dev/shm tmpfs rw 0 0 +/dev/sda6 /boot ext3 rw,noatime 0 0 +/dev/mapper/kzak-home /home/kzak ext4 rw,noatime 0 0 +none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0 +fusectl /sys/fs/fuse/connections fusectl rw 0 0 +gvfs-fuse-daemon /home/kzak/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,user=kzak 0 0 +sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0 +none /var/tmp/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011/\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011 overlay rw,relatime,lowerdir=lower,upperdir=upper,workdir=work 0 0 diff --git a/tests/ts/libmount/files/swaps b/tests/ts/libmount/files/swaps new file mode 100644 index 0000000..13ce933 --- /dev/null +++ b/tests/ts/libmount/files/swaps @@ -0,0 +1,4 @@ +Filename Type Size Used Priority +/dev/dm-2 partition 8151036 2283436 -2 +/some/swapfile file 111 111 0 +/some/swapfile2\040(deleted) file 111 111 0 diff --git a/tests/ts/libmount/lock b/tests/ts/libmount/lock new file mode 100755 index 0000000..7ba678b --- /dev/null +++ b/tests/ts/libmount/lock @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="lock" + +TS_OPTIONAL="yes" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_LOCK" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +# +# Be careful with number of processes. Don't forget that there is time limit +# when the mount waits on the mtab lock. If you define too much processes some +# of them will fail with timeout. +# +# Note: the original version (< 2.13) of util-linux is completely useless for +# this test (maximum for this old version is NLOOPS=10 and NPROCESSES=5 (2-way +# 2GHz machine)). It has terrible performance due a bad timeouts implementation +# in lock_mtab(). +# +NLOOPS=1000 +NPROCESSES=50 + + +> $TS_OUTPUT.debug +echo 0 > $TS_OUTPUT +SYNCTIME=$(( $(date +%s) + 5 )) + +for id in $(seq 0 $(( $NPROCESSES - 1 ))); do + ts_run $TESTPROG --lock --synctime $SYNCTIME $TS_OUTPUT $NLOOPS >> $TS_OUTPUT.debug 2>&1 & +done + +wait + +ts_finalize diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop new file mode 100755 index 0000000..6de00ee --- /dev/null +++ b/tests/ts/libmount/loop @@ -0,0 +1,143 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz> +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="losetup-loop" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" +ts_check_test_command "$TS_CMD_LOSETUP" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +function verify_mount_dev { + local dev=$1 + local mp=$2 + local dev_mounted=$($TS_CMD_FINDMNT -no SOURCE --mountpoint "$mp") + + if test "$dev" != "$dev_mounted" ; then + echo "Mounted incorrect device: have '$dev_mounted', want '$dev'" >&2 + return 1 + fi +} + +# +# file-* tests: Backing file is a regular file +# +BACKFILE=$(ts_image_init 10) + +mkfs.ext2 -F $BACKFILE &> /dev/null || ts_die "Cannot make ext2 on $BACKFILE" + +# All tests are separated by "udevadm settle" because loop device exists some time after +# "losetup -d". This device confuses some tests. And find-race-condition, tests, +# whether re-use of this device works. +udevadm settle + +ts_init_subtest "file" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "file-o-loop" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT -oloop "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "dev-loop" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE 2>> $TS_OUTPUT ) +$TS_CMD_MOUNT $LODEV "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "o-loop-val" +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) + $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG + verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG + $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG + udevadm settle + ts_log "Success" + ts_finalize_subtest +fi + +ts_init_subtest "reuse" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show "$BACKFILE" 2>> $TS_OUTPUT ) +$TS_CMD_MOUNT "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "conflict" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --offset=1000 "$BACKFILE" 2>> $TS_OUTPUT ) +$TS_CMD_MOUNT "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "o-loop-val-initialized" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT) +$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_init_subtest "o-loop-val-conflict" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +cp "$BACKFILE" "$BACKFILE"-2 +LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT) +$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ + | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>> $TS_ERRLOG +rm "$BACKFILE"-2 +udevadm settle +ts_log "Success" +ts_finalize_subtest + +ts_log "Success" +ts_finalize diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay new file mode 100755 index 0000000..62874a1 --- /dev/null +++ b/tests/ts/libmount/loop-overlay @@ -0,0 +1,65 @@ +#!/bin/bash + +# +# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz> +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="loop overlay" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LOSETUP" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" +ts_check_prog "dd" +ts_check_prog "stat" + +IMG=$(ts_image_init 5) + +mkfs.ext2 -F "$IMG" &> /dev/null || ts_die "Cannot make extn on $IMG" +OFFSET=$(stat -c %s "$IMG") + +dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null + +[ -d "$TS_MOUNTPOINT-1" ] || mkdir -p $TS_MOUNTPOINT-1 +[ -d "$TS_MOUNTPOINT-2" ] || mkdir -p $TS_MOUNTPOINT-2 + +echo "second should fail" >>$TS_OUTPUT +$TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "should succeed" >>$TS_OUTPUT +$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo "both should fail" >>$TS_OUTPUT +LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG") +$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \ + | sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT +$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT +$TS_CMD_LOSETUP --detach $LOOPDEV + +ts_log "Success" +ts_finalize diff --git a/tests/ts/libmount/optstr b/tests/ts/libmount/optstr new file mode 100755 index 0000000..03a1635 --- /dev/null +++ b/tests/ts/libmount/optstr @@ -0,0 +1,148 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="options string" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "append" +ts_run $TESTPROG --append "aaa,bbb=BBB,context=\"foo,bar,gogo\",ccc" "ddd" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "append-value" +ts_run $TESTPROG --append "aaa,bbb=BBB,ccc" "ddd" "DDD" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "append-empty-value" +ts_run $TESTPROG --append "aaa,bbb=BBB,ccc" "ddd" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "prepend" +ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "prepend-value" +ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" "DDD" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "prepend-empty-value" +ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-remove" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-small" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" "X" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-large" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" "XXX-YYY-ZZZ" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-empty" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "bbb" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "aaa" "XXX" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new-empty" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "aaa" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new-end" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "ccc" "XXX" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "set-new-end-empty" +ts_run $TESTPROG --set "aaa,bbb=BBB,ccc" "ccc" "" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "get" +ts_run $TESTPROG --get "aaa,bbb=BBB,ccc" "aaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "get-value" +ts_run $TESTPROG --get "aaa,bbb=BBB,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove" +ts_run $TESTPROG --remove "aaa,bbb=BBB,ccc" "aaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove-quoted" +ts_run $TESTPROG --remove "aaa,context=\"foo,bar,gogo\",bbb=BBB,ccc" "context" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove-value" +ts_run $TESTPROG --remove "aaa,bbb=BBB,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remove-empty-value" +ts_run $TESTPROG --remove "aaa,bbb=,ccc" "bbb" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "split" +ts_run $TESTPROG --split "aaa,bbb=BBB,ccc,x-bar,x-foo=foodata,user=kzak,noexec,nosuid,loop=/dev/loop0" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "flags" +ts_run $TESTPROG --flags "aaa,bbb=BBB,x-foo,ccc,user=kzak,nodev,noexec,nosuid,loop=/dev/loop0" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-linux" +# Use kernel mount options man (--linux), add noatime, remove noexec and nosuid, +# and keep unknown(e.g. user=kzak) +ts_run $TESTPROG --apply --linux "user=kzak,noexec,nosuid" 0x400 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user" +# Use userspace options map (--user), add user and nofail, remove loop, +# and keep unknown (e.g. noexec, nosuid) +ts_run $TESTPROG --apply --user "noexec,nosuid,loop=/dev/looop0" 0x408 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user-small-x" +# Use userspace options map (--user), remove X-* and loop=, keep unknown 'something' and +# keep by flags specified x-* +ts_run $TESTPROG --apply --user \ + "something,loop=/dev/looop0,x-gvfs-hide,x-gdu.hide,x-canary,X-foo" 0x00002000 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user-large-X" +# Use userspace options map (--user), remove x-* and loop=, keep unknown 'something' and +# keep by flags specified X-* +ts_run $TESTPROG --apply --user \ + "something,loop=/dev/looop0,x-gvfs-hide,x-gdu.hide,x-canary,X-foo,X-bar" 0x00020000 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "apply-user-Xx" +# Use userspace options map (--user), remove loop=, keep unknown 'something' and +# keep by flags specified X-* and x-*, add by flag specified nofail +ts_run $TESTPROG --apply --user \ + "something,loop=/dev/looop0,x-gvfs-hide,x-gdu.hide,x-canary,X-foo,X-bar" 0x00022400 &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fix" +ts_run $TESTPROG --fix "uid=root,gid=root" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "deduplicate" +ts_run $TESTPROG --dedup bbb,ccc,AAA,xxx,AAA=a,AAA=bbb,ddd,AAA=ccc,fff=eee AAA &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "deduplicate-empty" +ts_run $TESTPROG --dedup bbb,ccc,AAA,xxx,AAA=a,AAA=bbb,ddd,AAA=,fff=eee AAA &> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabdiff b/tests/ts/libmount/tabdiff new file mode 100755 index 0000000..344daae --- /dev/null +++ b/tests/ts/libmount/tabdiff @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright (C) 2011 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="table diffs" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_TABDIFF" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "mount" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo_u $TS_SELF/files/mountinfo &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "umount" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo $TS_SELF/files/mountinfo_u &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "remount" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo $TS_SELF/files/mountinfo_re &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "move" +ts_run $TESTPROG --diff $TS_SELF/files/mountinfo $TS_SELF/files/mountinfo_mv &> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles new file mode 100755 index 0000000..716fed8 --- /dev/null +++ b/tests/ts/libmount/tabfiles @@ -0,0 +1,85 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab files" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_TAB" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "parse-fstab" +ts_run $TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-full" +ts_run $TESTPROG --parse "$TS_SELF/files/fstab.comment" --comments &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mtab" +ts_run $TESTPROG --parse "$TS_SELF/files/mtab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-broken" +ts_run $TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT +sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mountinfo" +ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mountinfo-nosrc" +ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo_nosrc" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-swaps" +ts_run $TESTPROG --parse "$TS_SELF/files/swaps" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "copy" +ts_run $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-source" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target2" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target3" +ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-pair" +ts_run $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-fs" +ts_run $TESTPROG --find-fs "$TS_SELF/files/mountinfo" /home/kzak &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles-py b/tests/ts/libmount/tabfiles-py new file mode 100755 index 0000000..9754afe --- /dev/null +++ b/tests/ts/libmount/tabfiles-py @@ -0,0 +1,75 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab files-py" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_init_py libmount + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +PYDBG="$PYTHON -m pdb" +TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB" +[ -x $TESTPROG ] || ts_die "test script missing" + +ts_init_subtest "parse-fstab" +$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-full" +$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab.comment" --comments &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mtab" +$PYTHON $TESTPROG --parse "$TS_SELF/files/mtab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-fstab-broken" +$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT +sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "parse-mountinfo" +$PYTHON $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "copy" +$PYTHON $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-source" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target2" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-target3" +$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "find-pair" +$PYTHON $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags new file mode 100755 index 0000000..c5452cf --- /dev/null +++ b/tests/ts/libmount/tabfiles-tags @@ -0,0 +1,86 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tags" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_skip_nonroot + +if [ "$TS_ENABLE_ASAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_LIBMOUNT_TAB" + +[ -x $TESTPROG ] || ts_skip "test not compiled" +ts_check_prog "mkfs.ext2" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 +LABEL="testLibmount" +UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9" + +# +# Create filesystem +# +mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE" +ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE" +ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE" + +FSTAB="$TS_OUTDIR/fstab" + +# +# Label in fstab +# +echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB +ts_udevadm_settle "$TS_DEVICE" "LABEL" "UUID" + +ts_init_subtest "fstab-label2uuid" +ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label2dev" +ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add more enties for the same device +# +echo "UUID=$UUID /mnt/mountpoint2 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-uuid" +# has to return /mnt/mountpoint2 +ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label" +# has to return /mnt/mountpoint +ts_run $TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "fstab-dev2label" +# has to return /mnt/mountpoint +ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add devname +# +echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-dev" +# has to return /mnt/mountpoint3 +ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +sed -i -e 's/source: .*//g' $TS_OUTPUT # devname is generated, remove it +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/tabfiles-tags-py b/tests/ts/libmount/tabfiles-tags-py new file mode 100755 index 0000000..171f189 --- /dev/null +++ b/tests/ts/libmount/tabfiles-tags-py @@ -0,0 +1,90 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tags-py" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_init_py libmount + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB" +[ -x $TESTPROG ] || ts_die "test script missing" + +ts_check_prog "mkfs.ext2" + +PYDBG="$PYTHON -m pdb" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 +LABEL="testLibmount" +UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9" + +# +# Create filesystem +# +mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE" +ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE" +ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE" + +FSTAB="$TS_OUTDIR/fstab" + +# +# Label in fstab +# +echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" + +ts_init_subtest "fstab-label2uuid" +$PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label2dev" +$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add more enties for the same device +# +echo "UUID=$UUID /mnt/mountpoint2 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-uuid" +# has to return /mnt/mountpoint2 +$PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "fstab-label" +# has to return /mnt/mountpoint +$PYTHON $TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "fstab-dev2label" +# has to return /mnt/mountpoint +$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + +# +# Add devname +# +echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB + +ts_init_subtest "fstab-dev" +# has to return /mnt/mountpoint3 +$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +sed -i -e 's/source: .*//g' $TS_OUTPUT # devname is generated, remove it +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libmount/update b/tests/ts/libmount/update new file mode 100755 index 0000000..abc1547 --- /dev/null +++ b/tests/ts/libmount/update @@ -0,0 +1,112 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab update" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +# IMPORTANT notes: +# +# - the $TS_OUTPUT variable is between ts_init_subtest and ts_finalize_subtest +# redefined to subtest specific namespace -- it means that $TS_OUTPUT is a +# different file within a subtest. +# +# - all this test uses global $TS_OUTPUT.{mtab,mountinfo} + +export LIBMOUNT_MTAB=$TS_OUTPUT.mtab +rm -f $LIBMOUNT_MTAB +> $LIBMOUNT_MTAB + + +# +# Traditional /etc/mtab +# +has_mtab=$( ts_has_mtab_support ) +if [ "$has_mtab" == "yes" ]; then + + ts_init_subtest "mtab-mount" + ts_run $TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec" + ts_run $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "gg=G,ffff=f,ro,noatime" + ts_run $TESTPROG --add /dev/sda2 /mnt/bar ext3 "rw,noatime" + ts_run $TESTPROG --add /dev/sda1 /mnt/gogo ext3 "rw,noatime,nosuid" + ts_run $TESTPROG --add none /proc proc defaults + cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside + ts_finalize_subtest # checks the mtab + + ts_init_subtest "mtab-move" + ts_run $TESTPROG --move /mnt/foo /mnt/newfoo + ts_run $TESTPROG --move /mnt/bar /mnt/newbar + cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside + ts_finalize_subtest # checks the mtab + + ts_init_subtest "mtab-remount" + ts_run $TESTPROG --remount /mnt/newfoo "ro,noatime" + ts_run $TESTPROG --remount /mnt/bar "rw,atime,nosuid" + cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside + ts_finalize_subtest # checks the mtab + + ts_init_subtest "mtab-umount" + ts_run $TESTPROG --remove /mnt/bar + ts_run $TESTPROG --remove /mnt/gogo + ts_run $TESTPROG --remove /proc + cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside + ts_finalize_subtest # checks the mtab +fi + +# +# utab +# +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 "utab-mount" +ts_run $TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec" +ts_run $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "ro,user" +ts_run $TESTPROG --add /dev/sda2 /mnt/xyz ext3 "rw,loop=/dev/loop0,uhelper=hal" +ts_run $TESTPROG --add none /proc proc "rw,user" +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "utab-move" +ts_run $TESTPROG --move /mnt/bar /mnt/newbar +ts_run $TESTPROG --move /mnt/xyz /mnt/newxyz +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "utab-remount" +ts_run $TESTPROG --remount /mnt/newbar "ro,noatime" +ts_run $TESTPROG --remount /mnt/newxyz "rw,user" +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "utab-umount" +ts_run $TESTPROG --remove /mnt/newbar +ts_run $TESTPROG --remove /proc +cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +# +# fstab - replace +# +export LIBMOUNT_FSTAB=$TS_OUTPUT.fstab +rm -f $LIBMOUNT_FSTAB +cp "$TS_SELF/files/fstab.comment" $LIBMOUNT_FSTAB + +ts_init_subtest "fstab-replace" +ts_run $TESTPROG --replace "LABEL=foo" "/mnt/foo" +cp $LIBMOUNT_FSTAB $TS_OUTPUT # save the fstab aside +ts_finalize_subtest #checks the fstab + +ts_finalize diff --git a/tests/ts/libmount/update-py b/tests/ts/libmount/update-py new file mode 100755 index 0000000..e4bba9c --- /dev/null +++ b/tests/ts/libmount/update-py @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="tab update-py" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_init_py libmount +ts_skip_nonroot + +if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then + TS_KNOWN_FAIL="yes" +fi + +TESTPROG="$TS_HELPER_PYLIBMOUNT_UPDATE" +[ -x $TESTPROG ] || ts_die "test script missing" + +# +# fstab - replace +# +export LIBMOUNT_FSTAB=$TS_OUTPUT.fstab +rm -f $LIBMOUNT_FSTAB +cp "$TS_SELF/files/fstab.comment" $LIBMOUNT_FSTAB + +ts_init_subtest "fstab-replace" +$PYTHON $TESTPROG --replace "LABEL=foo" "/mnt/foo" >/dev/null 2>&1 +cp $LIBMOUNT_FSTAB $TS_OUTPUT # save the fstab aside +ts_finalize_subtest #checks the fstab + +ts_finalize diff --git a/tests/ts/libmount/utils b/tests/ts/libmount/utils new file mode 100755 index 0000000..ad25e8f --- /dev/null +++ b/tests/ts/libmount/utils @@ -0,0 +1,84 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="utils" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_UTILS" + +[ -x $TESTPROG ] || ts_skip "test not compiled" + +ts_init_subtest "match-fstype" +ts_run $TESTPROG --match-fstype ext3 "ext2,ext3,cifs" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-fstype-neg" +ts_run $TESTPROG --match-fstype cifs "ext2,ext3,nocifs" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-fstype-neg2" +ts_run $TESTPROG --match-fstype cifs "noext2,ext3,cifs" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ccc" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-list" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ccc,aaa,ddd" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-neg" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "noxxx" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-neg-list" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ddd,noaaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "match-options-neg-list2" +ts_run $TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "noxxx,ccc,aaa" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "starts-with" +ts_run $TESTPROG --starts-with "AAAbbbCCC" "AAA" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "ends-with" +ts_run $TESTPROG --ends-with "AAAbbbCCC" "CCC" &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "mountpoint" +if [ -d /proc ]; then + ts_run $TESTPROG --mountpoint /proc &> $TS_OUTPUT + ts_finalize_subtest +else + ts_skip_subtest "no /proc" +fi + +ts_init_subtest "mountpoint-subdir" +if [ -d /proc/sys/kernel ]; then + ts_run $TESTPROG --mountpoint /proc/sys/kernel &> $TS_OUTPUT + ts_finalize_subtest +else + ts_skip_subtest "no /proc" +fi + +ts_init_subtest "mountpoint-root" +ts_run $TESTPROG --mountpoint / &> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "kernel-cmdline" +export LIBMOUNT_KERNEL_CMDLINE="$TS_SELF/files/kernel_cmdline" +ts_run $TESTPROG --kernel-cmdline selinux= >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline selinux >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline ro >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline ro= >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --kernel-cmdline root= >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize |