From: "zhangyi (F)" <yi.zhang@huawei.com>
To: linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Cc: miklos@szeredi.hu, amir73il@gmail.com, eguan@redhat.com,
darrick.wong@oracle.com, yi.zhang@huawei.com, miaoxie@huawei.com
Subject: [PATCH for xfstests 3/4] overlay: add fsck.overlay opaque directory test
Date: Thu, 14 Dec 2017 14:48:45 +0800 [thread overview]
Message-ID: <20171214064846.21587-4-yi.zhang@huawei.com> (raw)
In-Reply-To: <20171214064846.21587-1-yi.zhang@huawei.com>
Add fsck.overlay test case to test it how to deal with invalid/valid
opaque xattr in underlying directories of overlayfs.
Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
---
tests/overlay/202 | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/overlay/202.out | 5 ++
tests/overlay/group | 1 +
3 files changed, 147 insertions(+)
create mode 100755 tests/overlay/202
create mode 100644 tests/overlay/202.out
diff --git a/tests/overlay/202 b/tests/overlay/202
new file mode 100755
index 0000000..3f217ad
--- /dev/null
+++ b/tests/overlay/202
@@ -0,0 +1,141 @@
+#! /bin/bash
+# FS QA Test 202
+#
+# Test fsck.overlay how to deal with opaque xattr in overlayfs.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Huawei. All Rights Reserved.
+# Author: zhangyi (F) <yi.zhang@huawei.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_attrs
+_require_command "$FSCK_OVERLAY_PROG" fsck.overlay
+
+# remove all files from previous tests
+_scratch_mkfs
+
+OVL_OPAQUE_XATTR="trusted.overlay.opaque"
+OVL_OPAQUE_XATTR_VAL="y"
+
+# Set opaque xattr to a directory
+set_opaque()
+{
+ local target=$1
+
+ $SETFATTR_PROG -n $OVL_OPAQUE_XATTR -v $OVL_OPAQUE_XATTR_VAL $target
+}
+
+# Check opaque xattr
+check_opaque()
+{
+ local dir=$1
+
+ opaque=$($GETFATTR_PROG --absolute-names --only-values -n \
+ $OVL_OPAQUE_XATTR $dir)
+
+ [[ $opaque == $OVL_OPAQUE_XATTR_VAL ]] || \
+ echo "Opaque xattr removed incorrectly"
+}
+
+# Create test directories
+lowerdir=$OVL_BASE_SCRATCH_MNT/lower
+lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
+upperdir=$OVL_BASE_SCRATCH_MNT/upper
+workdir=$OVL_BASE_SCRATCH_MNT/workdir
+
+mkdir -p $lowerdir $lowerdir2 $upperdir $workdir $workdir
+
+# Test invalid opaque xattr covering a nonexistent lower target, should remove
+echo "+ Invalid opaque"
+mkdir $lowerdir/testdir1
+mkdir -p $upperdir/testdir/testdir2
+set_opaque $lowerdir/testdir1
+set_opaque $upperdir/testdir/testdir2
+_overlay_fsck_dirs -a $lowerdir $upperdir $workdir >> $seqres.full 2>&1 || \
+ _fail "fsck should not fail"
+$GETFATTR_PROG --absolute-names -d -m $OVL_OPAQUE_XATTR_VAL $lowerdir/testdir1
+$GETFATTR_PROG --absolute-names -d -m $OVL_OPAQUE_XATTR_VAL $upperdir/testdir/testdir2
+rm -rf $lowerdir/* $upperdir/*
+
+# Test valid opaque xattr in upper covering lower target, should not remove
+echo "+ Valid opaque"
+mkdir $lowerdir/testdir
+touch $lowerdir/foo
+mkdir $upperdir/testdir
+mkdir $upperdir/foo
+set_opaque $upperdir/testdir
+set_opaque $upperdir/foo
+_overlay_fsck_dirs -a $lowerdir $upperdir $workdir >> $seqres.full 2>&1 || \
+ _fail "fsck should not fail"
+check_opaque $upperdir/testdir
+check_opaque $upperdir/foo
+rm -rf $lowerdir/* $upperdir/*
+
+# Test valid opaque xattr in middle layer covering lower target, should not remove
+echo "+ Valid opaque(2)"
+mkdir $lowerdir2/testdir
+touch $lowerdir2/foo
+mkdir $lowerdir/testdir
+mkdir $lowerdir/foo
+set_opaque $lowerdir/testdir
+set_opaque $lowerdir/foo
+_overlay_fsck_dirs -a "$lowerdir:$lowerdir2" $upperdir $workdir >> \
+ $seqres.full 2>&1 || _fail "fsck should not fail"
+check_opaque $lowerdir/testdir
+check_opaque $lowerdir/foo
+rm -rf $lowerdir2/* $lowerdir/*
+
+# Test valid opaque in merged directory, should not remove
+echo "+ Valid opaque(3)"
+mkdir $lowerdir/testdir1
+mkdir -p $upperdir/testdir1/testdir2
+set_opaque $upperdir/testdir1/testdir2
+_overlay_fsck_dirs -a $lowerdir $upperdir $workdir >> $seqres.full 2>&1 || \
+ _fail "fsck should not fail"
+check_opaque $upperdir/testdir1/testdir2
+rm -rf $lowerdir/* $upperdir/*
+
+# success, all done
+status=0
+exit
diff --git a/tests/overlay/202.out b/tests/overlay/202.out
new file mode 100644
index 0000000..1aadc4d
--- /dev/null
+++ b/tests/overlay/202.out
@@ -0,0 +1,5 @@
+QA output created by 202
++ Invalid opaque
++ Valid opaque
++ Valid opaque(2)
++ Valid opaque(3)
diff --git a/tests/overlay/group b/tests/overlay/group
index 7c5fcbb..e39b5e0 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -50,3 +50,4 @@
047 auto quick copyup hardlink
048 auto quick copyup hardlink
201 auto quick fsck
+202 auto quick fsck
--
2.5.0
next prev parent reply other threads:[~2017-12-14 6:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 6:48 [PATCH for xfstests 0/4] overlay: add fsck.overlay basic tests zhangyi (F)
2017-12-14 6:48 ` [PATCH for xfstests 1/4] overlay: add filesystem check helper zhangyi (F)
2017-12-14 9:05 ` Amir Goldstein
2017-12-14 12:40 ` zhangyi (F)
2017-12-14 13:14 ` Amir Goldstein
2017-12-14 6:48 ` [PATCH for xfstests 2/4] overlay: add fsck.overlay whiteout test zhangyi (F)
2017-12-14 13:13 ` Amir Goldstein
2017-12-15 5:35 ` zhangyi (F)
2017-12-14 6:48 ` zhangyi (F) [this message]
2017-12-14 13:25 ` [PATCH for xfstests 3/4] overlay: add fsck.overlay opaque directory test Amir Goldstein
2017-12-14 6:48 ` [PATCH for xfstests 4/4] overlay: add fsck.overlay redirect " zhangyi (F)
2017-12-14 13:44 ` Amir Goldstein
2017-12-15 6:42 ` zhangyi (F)
2017-12-15 7:23 ` Amir Goldstein
2017-12-15 8:57 ` zhangyi (F)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171214064846.21587-4-yi.zhang@huawei.com \
--to=yi.zhang@huawei.com \
--cc=amir73il@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=eguan@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox