]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
overlay: test parsing of lowerdir+,datadir+ mount options
authorAmir Goldstein <amir73il@gmail.com>
Mon, 4 Dec 2023 18:58:59 +0000 (20:58 +0200)
committerZorro Lang <zlang@kernel.org>
Fri, 15 Dec 2023 17:57:16 +0000 (01:57 +0800)
Fork test overlay/083 to test parsing of lowerdir+,datadir+ mount options.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/overlay/086 [new file with mode: 0755]
tests/overlay/086.out [new file with mode: 0644]

diff --git a/tests/overlay/086 b/tests/overlay/086
new file mode 100755 (executable)
index 0000000..b596051
--- /dev/null
@@ -0,0 +1,81 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2023 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 086
+#
+# Test lowerdir+,datadir+ mount option restrictions.
+#
+
+. ./common/preamble
+_begin_fstest auto quick mount
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+_supported_fs overlay
+
+# _overlay_check_* helpers do not handle special chars well
+_require_scratch_nocheck
+_require_scratch_overlay_lowerdir_add_layers
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# Create lowerdirs with special characters
+lowerdir_spaces="$OVL_BASE_SCRATCH_MNT/lower1 with  spaces"
+lowerdir_colons="$OVL_BASE_SCRATCH_MNT/lower2:with::colons"
+lowerdir_colons_esc="$OVL_BASE_SCRATCH_MNT/lower2\:with\:\:colons"
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
+mkdir -p "$lowerdir_spaces" "$lowerdir_colons"
+
+# _overlay_mount_* helpers do not handle lowerdir+,datadir+, so execute mount directly.
+
+# check illegal combinations and order of lowerdir,lowerdir+,datadir+
+$MOUNT_PROG -t overlay none $SCRATCH_MNT \
+       -o"lowerdir=$lowerdir,lowerdir+=$lowerdir_colons" \
+       2>> $seqres.full && \
+       echo "ERROR: invalid combination of lowerdir and lowerdir+ mount options"
+
+$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+
+$MOUNT_PROG -t overlay none $SCRATCH_MNT \
+       -o"lowerdir=$lowerdir,datadir+=$lowerdir_colons" \
+       -o redirect_dir=follow,metacopy=on 2>> $seqres.full && \
+       echo "ERROR: invalid combination of lowerdir and datadir+ mount options"
+
+$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+
+$MOUNT_PROG -t overlay none $SCRATCH_MNT \
+       -o"datadir+=$lowerdir,lowerdir+=$lowerdir_colons" \
+       -o redirect_dir=follow,metacopy=on 2>> $seqres.full && \
+       echo "ERROR: invalid order of lowerdir+ and datadir+ mount options"
+
+$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+
+# mount is expected to fail with escaped colons.
+$MOUNT_PROG -t overlay none $SCRATCH_MNT \
+       -o"lowerdir+=$lowerdir_colons_esc" \
+       2>> $seqres.full && \
+       echo "ERROR: incorrect parsing of escaped colons in lowerdir+ mount option"
+
+$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
+
+# mount is expected to succeed without escaped colons.
+$MOUNT_PROG -t overlay ovl_esc_test $SCRATCH_MNT \
+       -o"lowerdir+=$lowerdir_colons,datadir+=$lowerdir_spaces" \
+       -o redirect_dir=follow,metacopy=on \
+       2>&1 | tee -a $seqres.full
+
+# if spaces are not escaped when showing mount options,
+# mount command will not show the word 'spaces' after the spaces
+$MOUNT_PROG -t overlay | grep ovl_esc_test | tee -a $seqres.full | \
+       grep -q 'datadir+'.*spaces || \
+       echo "ERROR: escaped spaces truncated from datadir+ mount option"
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/086.out b/tests/overlay/086.out
new file mode 100644 (file)
index 0000000..b34758f
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 086
+Silence is golden