overlay: run unionmount testsuite test cases
authorAmir Goldstein <amir73il@gmail.com>
Sun, 31 May 2020 11:01:54 +0000 (14:01 +0300)
committerEryu Guan <guaneryu@gmail.com>
Sun, 26 Jul 2020 13:33:20 +0000 (21:33 +0800)
Add support for running unionmount-testsuite from xfstests.
This requires that unionmount-testsuite is installed under src dir or
that UNIONMOUNT_TESTSUITE variable points to the location of the
testsuite.  It also requires a recent version of unionmount-testsuite
that supports setting basedir path via UNIONMOUNT_* environment variables.

Add tests for three basic configurations:
1. overlay with upper/lower on same fs
2. overlay with upper/lower not on same fs without xino
3. overlay with upper/lower not on same fs with xino

The samefs test uses scratch partition for lower/upper layers.
The non samefs tests use the scratch partition for upper layer and the
test partition for lower layer.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
README.overlay
common/config
common/overlay
tests/overlay/100 [new file with mode: 0755]
tests/overlay/100.out [new file with mode: 0644]
tests/overlay/101 [new file with mode: 0755]
tests/overlay/101.out [new file with mode: 0644]
tests/overlay/102 [new file with mode: 0755]
tests/overlay/102.out [new file with mode: 0644]
tests/overlay/group

index 30b5ddb..39e25ad 100644 (file)
@@ -50,3 +50,18 @@ In the example above, MOUNT_OPTIONS will be used to mount the base scratch fs,
 TEST_FS_MOUNT_OPTS will be used to mount the base test fs,
 OVERLAY_MOUNT_OPTIONS will be used to mount both test and scratch overlay and
 OVERLAY_FSCK_OPTIONS will be used to check both test and scratch overlay.
+
+
+Unionmount Testsuite
+====================
+
+xfstests can be used as a test harness to run unionmount testsuite test cases
+and provide extended test coverage for overlayfs.
+
+To enable running unionmount testsuite, clone the git repository from:
+  https://github.com/amir73il/unionmount-testsuite.git
+under the xfstests src directory, or set the environment variable
+UNIONMOUNT_TESTSUITE to the local path where the repository was cloned.
+
+Run './check -overlay -g overlay/union' to execute all the unionmount testsuite
+test cases.
index 8023273..e356bcd 100644 (file)
@@ -71,6 +71,8 @@ export OVL_LOWER="ovl-lower"
 export OVL_WORK="ovl-work"
 # overlay mount point parent must be the base fs root
 export OVL_MNT="ovl-mnt"
+# By default unionmount-testsuite is expected under src
+export UNIONMOUNT_TESTSUITE=${UNIONMOUNT_TESTSUITE:=$here/src/unionmount-testsuite}
 
 # From e2fsprogs/e2fsck/e2fsck.h:
 # Exit code used by fsck-type programs
index f8e1e27..5e6a7e0 100644 (file)
@@ -363,3 +363,57 @@ _repair_overlay_scratch_fs()
        esac
        return $res
 }
+
+# This test requires that unionmount testsuite is installed at
+# $UNIONMOUNT_TESTSUITE and that it supports configuring layers and overlay
+# mount paths via UNIONMOUNT_* environment variables.
+_require_unionmount_testsuite()
+{
+       [ -x "$UNIONMOUNT_TESTSUITE/run" ] || \
+               _notrun "unionmount testsuite required."
+
+       # Verify that UNIONMOUNT_* vars are supported
+       local usage=`UNIONMOUNT_BASEDIR=_ "$UNIONMOUNT_TESTSUITE/run" 2>&1`
+       echo $usage | grep -wq "UNIONMOUNT_BASEDIR" || \
+               _notrun "newer version of unionmount testsuite required."
+}
+
+_unionmount_testsuite_run()
+{
+       [ "$FSTYP" = overlay ] || \
+               _notrun "Filesystem $FSTYP not supported with unionmount testsuite."
+
+       # Provide the mounted base fs for upper and lower dirs and the
+       # overlay mount point.
+       # unionmount testsuite will perform the overlay mount.
+       # test fs is used for lower layer in non-samefs runs.
+       # scratch fs is used for upper layer in non-samefs runs and
+       # for both layers in samefs runs.
+       if (echo $* | grep -qv samefs) ; then
+               _overlay_base_test_mount
+               export UNIONMOUNT_LOWERDIR=$OVL_BASE_TEST_DIR/union
+       fi
+       export UNIONMOUNT_BASEDIR=$OVL_BASE_SCRATCH_MNT/union
+
+       _scratch_mkfs
+       rm -rf $UNIONMOUNT_BASEDIR $UNIONMOUNT_LOWERDIR
+       mkdir -p $UNIONMOUNT_BASEDIR $UNIONMOUNT_LOWERDIR
+
+       cd $UNIONMOUNT_TESTSUITE
+       echo "run $* ..." > $seqres.full
+       ./run $* >> $seqres.full || \
+               echo "unionmount testsuite failed! see $seqres.full for details."
+}
+
+_unionmount_testsuite_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+
+       [ -n "$UNIONMOUNT_BASEDIR" ] || return 0
+
+       # Cleanup overlay mount after unionmount testsuite run
+       cd $UNIONMOUNT_TESTSUITE
+       echo "run --clean-up ..." >> $seqres.full
+       ./run --clean-up >> $seqres.full 2>&1
+}
diff --git a/tests/overlay/100 b/tests/overlay/100
new file mode 100755 (executable)
index 0000000..a2e82df
--- /dev/null
@@ -0,0 +1,38 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 100
+#
+# Run unionmount testsuite to verify correctness
+# with single lower layer on same fs as upper
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_unionmount_testsuite_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_unionmount_testsuite
+
+_unionmount_testsuite_run --ov --samefs --verify
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/100.out b/tests/overlay/100.out
new file mode 100644 (file)
index 0000000..798c013
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 100
+Silence is golden
diff --git a/tests/overlay/101 b/tests/overlay/101
new file mode 100755 (executable)
index 0000000..2b3a75d
--- /dev/null
@@ -0,0 +1,39 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 101
+#
+# Run unionmount testsuite to verify correctness
+# with single lower layer not on same fs as upper
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_unionmount_testsuite_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs overlay
+_supported_os Linux
+_require_test
+_require_scratch
+_require_unionmount_testsuite
+
+_unionmount_testsuite_run --ov --verify
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/101.out b/tests/overlay/101.out
new file mode 100644 (file)
index 0000000..e651a91
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 101
+Silence is golden
diff --git a/tests/overlay/102 b/tests/overlay/102
new file mode 100755 (executable)
index 0000000..2dddbe5
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 102
+#
+# Run unionmount testsuite to verify correctness
+# with single lower layer not on same fs as upper
+# with xino enabled
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_unionmount_testsuite_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs overlay
+_supported_os Linux
+_require_test
+_require_scratch
+_require_unionmount_testsuite
+
+_unionmount_testsuite_run --ov --xino --verify
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/102.out b/tests/overlay/102.out
new file mode 100644 (file)
index 0000000..86dd1f9
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 102
+Silence is golden
index 0cebcad..267161f 100644 (file)
@@ -77,3 +77,6 @@
 072 auto quick copyup hardlink
 073 auto quick whiteout
 074 auto quick exportfs dangerous
+100 auto quick union samefs
+101 auto quick union nonsamefs
+102 auto quick union nonsamefs xino