diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
commit | cfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch) | |
tree | d0baf160cbee3195249d095f85e52d20c21acf02 /tests/ts/mount/fstab-all | |
parent | Initial commit. (diff) | |
download | util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip |
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/mount/fstab-all')
-rwxr-xr-x | tests/ts/mount/fstab-all | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/tests/ts/mount/fstab-all b/tests/ts/mount/fstab-all new file mode 100755 index 0000000..83e1b63 --- /dev/null +++ b/tests/ts/mount/fstab-all @@ -0,0 +1,156 @@ +#!/bin/bash + +# Copyright (C) 2019 Karel Zak <kzak@redhat.com> + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="all (fstab)" + +. "$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_check_prog "mkfs.ext4" + + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 + +ts_log "Create partitions" +$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF +o +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.ext4 ${TS_DEVICE}4 &> /dev/null + +udevadm settle + +# use the same top-level mountpoint for all sub-tests +MOUNTPOINT=$TS_MOUNTPOINT + +[ -d "${MOUNTPOINT}A" ] || mkdir -p ${MOUNTPOINT}A +[ -d "${MOUNTPOINT}B" ] || mkdir -p ${MOUNTPOINT}B +[ -d "${MOUNTPOINT}C" ] || mkdir -p ${MOUNTPOINT}C +[ -d "${MOUNTPOINT}D" ] || mkdir -p ${MOUNTPOINT}D + +# generic fstab +MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab" +rm -rf $MY_FSTAB +echo "${TS_DEVICE}1 ${MOUNTPOINT}A ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}2 ${MOUNTPOINT}B ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}3 ${MOUNTPOINT}C ext2 ro,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> $MY_FSTAB + + +ts_init_subtest "basic" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "filter-type" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}D +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "filter-notype" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "filter-option" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}C +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "override-option" +$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + + +ts_init_subtest "relative-path" +cd "$TS_OUTDIR" > /dev/null +$TS_CMD_MOUNT --all --fstab $(basename "$MY_FSTAB") >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +cd - > /dev/null +ts_finalize_subtest + + +ts_init_subtest "prefix" +MY_ROOT="$TS_OUTDIR/${TS_TESTNAME}-rootdir" +[ -d "${MY_ROOT}" ] || mkdir -p ${MY_ROOT} +# sub-test specific fstab +MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab" +rm -rf $MY_FSTAB +echo "${TS_DEVICE}1 /foo/A ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}2 /foo/B ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}3 /foo/C ext2 rw,defaults 0 0" >> $MY_FSTAB +echo "${TS_DEVICE}4 /foo/D ext4 rw,defaults 0 0" >> $MY_FSTAB +# mount all to prefix +$TS_CMD_MOUNT --all \ + --fstab $MY_FSTAB \ + --target-prefix $MY_ROOT \ + -o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG +[ $? == 0 ] || ts_log "mount failed" +udevadm settle +$TS_CMD_UMOUNT $MY_ROOT/foo/{A,B,C,D} +[ $? == 0 ] || ts_log "umount failed" +ts_finalize_subtest + +ts_finalize |