Skip to content
Permalink
Browse files

tests: add basic overlayfs tests

Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
  • Loading branch information...
snajpa committed Nov 6, 2019
1 parent 84c3d1f commit d49f3afcb40d44be94c5e25d8a9293ebeaec6e27
@@ -333,6 +333,7 @@ AC_CONFIG_FILES([
tests/zfs-tests/tests/functional/no_space/Makefile
tests/zfs-tests/tests/functional/nopwrite/Makefile
tests/zfs-tests/tests/functional/online_offline/Makefile
tests/zfs-tests/tests/functional/overlayfs/Makefile
tests/zfs-tests/tests/functional/pool_checkpoint/Makefile
tests/zfs-tests/tests/functional/pool_names/Makefile
tests/zfs-tests/tests/functional/poolversion/Makefile
@@ -90,6 +90,10 @@ tags = ['functional', 'io']
tests = ['mmap_libaio_001_pos']
tags = ['functional', 'mmap']

[tests/functional/overlayfs:Linux]
tests = ['overlayfs_basic', 'overlayfs_layered']
tags = ['functional', 'overlayfs']

[tests/functional/procfs:Linux]
tests = ['procfs_list_basic', 'procfs_list_concurrent_readers',
'procfs_list_stale_read', 'pool_state']
@@ -44,6 +44,7 @@ SUBDIRS = \
no_space \
nopwrite \
online_offline \
overlayfs \
pool_checkpoint \
pool_names \
poolversion \
@@ -0,0 +1,6 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/overlayfs
dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
overlayfs_basic.ksh \
overlayfs_layered.ksh
@@ -0,0 +1,34 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib

default_cleanup
@@ -0,0 +1,69 @@
#!/bin/ksh -p
# SPDX-License-Identifier: CDDL-1.0 OR MPL-2.0

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (C) 2019 Pavel Snajdr <snajpa@snajpa.net
# Copyright (C) 2019 vpsFree.cz
#

. $STF_SUITE/include/libtest.shlib

verify_runnable "both"

function cleanup
{
log_must umount -f $TESTDIR/overlay
log_must rm -rf $TESTDIR/*
}

log_assert "ZFS supports being upper/lower/mnt of overlayfs."
log_onexit cleanup

modprobe overlay 2> /dev/null
cd $TESTDIR
mkdir lower upper work overlay
touch lower/{a,b}
touch upper/{c,d}
echo "orig" > lower/testfile
echo "upper" > upper/testfile

# Basic overlayfs mount
log_must mount -t overlay \
-o lowerdir=lower/,upperdir=upper/,workdir=work/ \
none overlay/

# Does presented overlay have all the files we expect?
log_must stat overlay/{a,b,c,d,testfile}

# We'd expect content of the upper test file
log_must grep upper overlay/testfile

echo "new" > overlay/testfile

# We'd expect content of the upper test file changed now
log_must grep new upper/testfile

log_must umount $TESTDIR/overlay

log_assert "ZFS supports being upper/lower/mnt of overlayfs as expected."
@@ -0,0 +1,75 @@
#!/bin/ksh -p
# SPDX-License-Identifier: CDDL-1.0 OR MPL-2.0

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (C) 2019 Pavel Snajdr <snajpa@snajpa.net
# Copyright (C) 2019 vpsFree.cz
#

. $STF_SUITE/include/libtest.shlib

verify_runnable "both"

function cleanup
{
log_must umount -f $TESTDIR/merge
log_must rm -rf $TESTDIR/*
}

log_assert "ZFS supports multilayered overlayfs."
log_onexit cleanup

modprobe overlay 2> /dev/null
cd $TESTDIR
mkdir lower middle upper work merge
mkdir {lower,middle,upper}/{dira,dirb}
touch lower/{dira,dirb}/{a,b}
touch middle/{dira,dirb}/{c,d}
touch upper/{dira,dirb}/{e,f}
echo "orig" > lower/testfile
echo "mid" > middle/testfile
echo "upper" > upper/testfile

# multi-level overlayfs mount
log_must mount -t overlay \
-o lowerdir=lower/:middle/,upperdir=upper/,workdir=work/ \
none merge/

# Does presented overlay have all the files we expect?
log_must stat merge/{dira,dirb}/{a,b,c,d,e,f} merge/testfile

# We'd expect content of the upper test file
log_must grep upper merge/testfile

echo "new" > merge/testfile

# We'd expect content of the lower test file not changed
log_must grep orig lower/testfile

# We'd expect content of the upper test file changed to new
log_must grep new upper/testfile

log_must umount $TESTDIR/merge

log_assert "ZFS supports multi-layered overlayfs as expected."
@@ -0,0 +1,43 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib

if ! is_linux ; then
log_unsupported "overlayfs is linux-only"
elif ! grep overlay /proc/filesystems; then
log_unsupported "kernel built without overlayfs or module not loaded"
elif ! renameat2 -C ; then
log_unsupported "renameat2 not supported on this (pre-3.15) linux kernel"
fi

DISK=${DISKS%% *}
default_setup $DISK

0 comments on commit d49f3af

Please sign in to comment.
You can’t perform that action at this time.