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@xxxxxxxxx> --- README.overlay | 15 ++++++++++++ common/config | 2 ++ common/overlay | 54 +++++++++++++++++++++++++++++++++++++++++++ tests/overlay/100 | 38 ++++++++++++++++++++++++++++++ tests/overlay/100.out | 2 ++ tests/overlay/101 | 39 +++++++++++++++++++++++++++++++ tests/overlay/101.out | 2 ++ tests/overlay/102 | 40 ++++++++++++++++++++++++++++++++ tests/overlay/102.out | 2 ++ tests/overlay/group | 3 +++ 10 files changed, 197 insertions(+) create mode 100755 tests/overlay/100 create mode 100644 tests/overlay/100.out create mode 100755 tests/overlay/101 create mode 100644 tests/overlay/101.out create mode 100755 tests/overlay/102 create mode 100644 tests/overlay/102.out diff --git a/README.overlay b/README.overlay index 30b5ddb2..39e25ada 100644 --- a/README.overlay +++ b/README.overlay @@ -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. diff --git a/common/config b/common/config index 8023273d..e356bcda 100644 --- a/common/config +++ b/common/config @@ -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 diff --git a/common/overlay b/common/overlay index f8e1e27f..5e6a7e0f 100644 --- a/common/overlay +++ b/common/overlay @@ -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 index 00000000..a2e82dfa --- /dev/null +++ b/tests/overlay/100 @@ -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 index 00000000..798c0136 --- /dev/null +++ b/tests/overlay/100.out @@ -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 index 00000000..2b3a75d4 --- /dev/null +++ b/tests/overlay/101 @@ -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 index 00000000..e651a915 --- /dev/null +++ b/tests/overlay/101.out @@ -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 index 00000000..2dddbe50 --- /dev/null +++ b/tests/overlay/102 @@ -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 index 00000000..86dd1f96 --- /dev/null +++ b/tests/overlay/102.out @@ -0,0 +1,2 @@ +QA output created by 102 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index 0cebcad0..267161f4 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -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 -- 2.17.1