diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:42:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:42:50 +0000 |
commit | 8cb83eee5a58b1fad74c34094ce3afb9e430b5a4 (patch) | |
tree | a9b2e7baeca1be40eb734371e3c8b11b02294497 /tests/ts/mount/umount-alltargets | |
parent | Initial commit. (diff) | |
download | util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.tar.xz util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.zip |
Adding upstream version 2.33.1.upstream/2.33.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/mount/umount-alltargets')
-rwxr-xr-x | tests/ts/mount/umount-alltargets | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets new file mode 100755 index 0000000..69799de --- /dev/null +++ b/tests/ts/mount/umount-alltargets @@ -0,0 +1,124 @@ +#!/bin/bash + +# Copyright (C) 2013 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="umount-all-targets" + +. $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_FDISK" + +ts_skip_nonroot +ts_check_prog "mkfs.ext2" + +$TS_CMD_UMOUNT --help | grep -q all-targets +[ $? -eq 1 ] && ts_skip "all-targets unsupported" + +has_mtab=$( ts_has_mtab_support ) +if [ "$has_mtab" == "yes" ]; then + [ -L /etc/mtab ] || ts_skip "regular mtab" +fi + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 + +ts_log "Create partitions" +$TS_CMD_FDISK ${TS_DEVICE} &> /dev/null <<EOF +n +p +1 + ++10M +n +p +2 + ++10M +n +p +3 + ++10M +n +p + ++10M +w +q +EOF + +udevadm settle + +ts_log "Create filesystem A" +mkfs.ext2 ${TS_DEVICE}1 &> /dev/null +ts_log "Create filesystem B" +mkfs.ext2 ${TS_DEVICE}2 &> /dev/null +ts_log "Create filesystem C" +mkfs.ext2 ${TS_DEVICE}3 &> /dev/null +ts_log "Create filesystem D" +mkfs.ext2 ${TS_DEVICE}4 &> /dev/null + +udevadm settle + +function multi_mount() { + local DEV=$1 + local MNT=$2 + + ts_log "prepare: Mount dev to mnt1" + [ -d "${MNT}1" ] || mkdir -p ${MNT}1 + $TS_CMD_MOUNT $DEV ${MNT}1 >> $TS_OUTPUT 2>&1 + + ts_log "prepare: Mount dev to mnt2" + [ -d "${MNT}2" ] || mkdir -p ${MNT}2 + $TS_CMD_MOUNT $DEV ${MNT}2 >> $TS_OUTPUT 2>&1 + + ts_log "prepare: Mount /dev/xxx1 to mnt3" + [ -d "${MNT}3" ] || mkdir -p ${MNT}3 + $TS_CMD_MOUNT $DEV ${MNT}3 >> $TS_OUTPUT 2>&1 + + udevadm settle +} + +# use the same top-level mountpoint for all sub-tests +MOUNTPOINT=$TS_MOUNTPOINT + +# +# The same device mounted on more places, umount all by mountpoint name +# +ts_init_subtest "all-targets-mnt" +multi_mount ${TS_DEVICE}1 $MOUNTPOINT +$TS_CMD_UMOUNT --all-targets ${MOUNTPOINT}1 >> $TS_OUTPUT 2>&1 +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +# +# The same device mounted on more places, umount all by device name +# +ts_init_subtest "all-targets-dev" +multi_mount ${TS_DEVICE}1 $MOUNTPOINT +$TS_CMD_UMOUNT --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>&1 +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +# +# The same device mounted on more places, one of the mountpoints also contains +# sub-mounts. Umount all by one umount all by top-level device name. +# +ts_init_subtest "all-targets-recursive" +multi_mount ${TS_DEVICE}1 $MOUNTPOINT +[ -d "${MOUNTPOINT}1/subA" ] || mkdir -p ${MOUNTPOINT}1/subA +$TS_CMD_MOUNT ${TS_DEVICE}2 ${MOUNTPOINT}1/subA +[ -d "${MOUNTPOINT}1/subA/subAB" ] || mkdir -p ${MOUNTPOINT}1/subA/subAB +$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB +[ -d "${MOUNTPOINT}1/subB" ] || mkdir -p ${MOUNTPOINT}1/subB +$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB +$TS_CMD_UMOUNT --recursive --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>&1 +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +ts_log "Success" +ts_finalize |