Skip to content

Commit

Permalink
overlay: run unionmount testsuite test cases
Browse files Browse the repository at this point in the history
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 mount path via UNIONMOUNT_* environment variables.

Add tests for 2 basic configurations:
- overlay with upper/lower on same fs
- overlay with upper/lower on non same fs

The samefs test uses scratch partition for lower/upper layers.
The nonsamefs test uses the scratch partition for upper layer and the
test partition for lower layer.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
  • Loading branch information
amir73il committed Apr 12, 2020
1 parent 8281662 commit a36f476
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.overlay
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions common/config
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions common/overlay
Expand Up @@ -363,3 +363,56 @@ _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_MNTPOINT=_ "$UNIONMOUNT_TESTSUITE/run" 2>&1`
echo $usage | grep -wq "UNIONMOUNT_MNTPOINT" || \
_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 some tmpfs/bind mounts and 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
# as base dir for both layers in samefs runs.
export UNIONMOUNT_BASEDIR=$OVL_BASE_SCRATCH_MNT/union/base
export UNIONMOUNT_UPPERDIR=$OVL_BASE_SCRATCH_MNT/union/upper
export UNIONMOUNT_LOWERDIR=$OVL_BASE_TEST_DIR/union/lower
export UNIONMOUNT_MNTPOINT=$SCRATCH_MNT

_overlay_base_test_mount
_scratch_mkfs
rm -rf $UNIONMOUNT_BASEDIR $UNIONMOUNT_LOWERDIR $UNIONMOUNT_UPPERDIR
mkdir -p $UNIONMOUNT_BASEDIR $UNIONMOUNT_LOWERDIR $UNIONMOUNT_UPPERDIR

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_MNTPOINT" ] || return 0

# Cleanup overlay mount after unionmount testsuite run
$UMOUNT_PROG $UNIONMOUNT_MNTPOINT 2>/dev/null
}
37 changes: 37 additions & 0 deletions tests/overlay/100
@@ -0,0 +1,37 @@
#! /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_unionmount_testsuite

_unionmount_testsuite_run --ov --samefs --verify

# success, all done
echo "Silence is golden"
status=0
exit
2 changes: 2 additions & 0 deletions tests/overlay/100.out
@@ -0,0 +1,2 @@
QA output created by 100
Silence is golden
37 changes: 37 additions & 0 deletions tests/overlay/101
@@ -0,0 +1,37 @@
#! /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_unionmount_testsuite

_unionmount_testsuite_run --ov --verify

# success, all done
echo "Silence is golden"
status=0
exit
2 changes: 2 additions & 0 deletions tests/overlay/101.out
@@ -0,0 +1,2 @@
QA output created by 101
Silence is golden
2 changes: 2 additions & 0 deletions tests/overlay/group
Expand Up @@ -75,3 +75,5 @@
070 auto quick copyup redirect nested
071 auto quick copyup redirect nested nonsamefs
072 auto quick copyup hardlink
100 auto quick union samefs
101 auto quick union nonsamefs

0 comments on commit a36f476

Please sign in to comment.