linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2] btrfs-progs: tests/mkfs: make sure rootdir got its xattr copied
Date: Mon,  9 Oct 2023 14:04:09 +1030	[thread overview]
Message-ID: <3daf7ed97305f5482800e28c960e3b5c2ed222b3.1696822345.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1696822345.git.wqu@suse.com>

The new test case would:

- Create a dir as source dir for --rootdir
- Add xattr for that source dir
- Create a file inside that source dir
- Add xattr for that file
- Run "mkfs.btrfs --rootdir" with that source dir
- Mount the created fs
- Make sure the following xattr exists:
  * Xattr for the rootdir
  * Xattr for that file inside the mount point

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 tests/mkfs-tests/027-rootdir-xattr/test.sh | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100755 tests/mkfs-tests/027-rootdir-xattr/test.sh

diff --git a/tests/mkfs-tests/027-rootdir-xattr/test.sh b/tests/mkfs-tests/027-rootdir-xattr/test.sh
new file mode 100755
index 000000000000..bff9dc71d8e0
--- /dev/null
+++ b/tests/mkfs-tests/027-rootdir-xattr/test.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# Test if the source dir has xattr, "mkfs.btrfs --rootdir" would properly copy
+# that xattr to the rootdir inode.
+
+source "$TEST_TOP/common" || exit
+
+setup_root_helper
+prepare_test_dev
+
+check_global_prereq setfattr
+check_global_prereq getfattr
+
+# Here we don't want to use /tmp, as it's pretty common /tmp is tmpfs, which
+# doesn't support xattr.
+# Instead we go $TEST_TOP/btrfs-progs-mkfs-tests-027.XXXXXX/ instead.
+src_dir=$(mktemp -d --tmpdir=$TEST_TOP btrfs-progs-mkfs-tests-027.XXXXXX)
+run_mayfail setfattr -n user.rootdir "$src_dir"
+if [ $? -ne 0 ]; then
+	rm -rf -- "$src_dir"
+	_not_run "unable to set xattr to temporaray directory"
+fi
+run_check touch "$src_dir/foobar"
+run_check setfattr -n user.foobar "$src_dir/foobar"
+
+run_check_mkfs_test_dev --rootdir "$src_dir"
+run_check_mount_test_dev
+
+attr=$(run_check_stdout getfattr -n user.rootdir --absolute-names "$src_dir")
+if ! echo $attr | grep -q "user.rootdir" ; then
+	rm -rf -- "$src_dir"
+	_fail "no rootdir xattr found"
+fi
+
+attr=$(run_check_stdout getfattr -n user.foobar --absolute-names "$src_dir/foobar")
+if ! echo $attr | grep -q "user.foobar" ; then
+	rm -rf -- "$src_dir"
+	_fail "no regular file xattr found"
+fi
+
+rm -rf -- "$src_dir"
-- 
2.42.0


  parent reply	other threads:[~2023-10-09  3:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09  3:34 [PATCH 0/2] btrfs-progs: make sure "mkfs --rootdir" copies the xattr for the rootdir Qu Wenruo
2023-10-09  3:34 ` [PATCH 1/2] btrfs-progs: mkfs/rootdir: add the missing xattr for the rootdir inode Qu Wenruo
2023-10-09  3:34 ` Qu Wenruo [this message]
2023-10-09 13:58   ` [PATCH 2/2] btrfs-progs: tests/mkfs: make sure rootdir got its xattr copied David Sterba
2023-10-09 20:40     ` Qu Wenruo

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=3daf7ed97305f5482800e28c960e3b5c2ed222b3.1696822345.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).