From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: quwenruo@cn.fujitsu.com, David Sterba <dsterba@suse.cz>
Subject: [PATCH 2/2] btrfs-progs: teests, use the root helper in 012
Date: Wed, 14 Jan 2015 18:25:09 +0100 [thread overview]
Message-ID: <1421256309-8559-1-git-send-email-dsterba@suse.cz> (raw)
In-Reply-To: <1419471135-10878-1-git-send-email-quwenruo@cn.fujitsu.com>
We need it to mount/umount, to traverse lost+found and stat the results.
Signed-off-by: David Sterba <dsterba@suse.cz>
---
tests/fsck-tests/012-leaf-corruption/test.sh | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tests/fsck-tests/012-leaf-corruption/test.sh b/tests/fsck-tests/012-leaf-corruption/test.sh
index edf77193a08d..896f717a883c 100755
--- a/tests/fsck-tests/012-leaf-corruption/test.sh
+++ b/tests/fsck-tests/012-leaf-corruption/test.sh
@@ -55,20 +55,20 @@ check_inode()
name=$5
# Check whether the inode exists
- exists=$(find $path -inum $ino)
+ exists=$($sudo find $path -inum $ino)
if [ -z "$exists" ]; then
_fail "inode $ino not recovered correctly"
fi
# Check inode type
- found_mode=$(printf "%o" 0x$(stat $exists -c %f))
+ found_mode=$(printf "%o" 0x$($sudo stat $exists -c %f))
if [ $found_mode -ne $mode ]; then
echo "$found_mode"
_fail "inode $ino modes not recovered"
fi
# Check inode size
- found_size=$(stat $exists -c %s)
+ found_size=$($sudo stat $exists -c %s)
if [ $mode -ne 41700 -a $found_size -ne $size ]; then
_fail "inode $ino size not recovered correctly"
fi
@@ -85,8 +85,8 @@ check_inode()
check_leaf_corrupt_no_data_ext()
{
image=$1
- if [ $UID -ne 0 ]; then
- echo " [NOTRUN] verify recovery. need root privilege"
+ if [ $have_root_helper -ne 1 ]; then
+ echo " [NOTRUN] root privileges needed to verify recovery"
exit 0
fi
if [ -z $TEST_MNT ]; then
@@ -94,7 +94,7 @@ check_leaf_corrupt_no_data_ext()
TEST_MNT="$(pwd)/tmp"
fi
mkdir -p $TEST_MNT || _fail "failed to create mount point"
- mount $image -o ro $TEST_MNT
+ $sudo mount $image -o ro $TEST_MNT
i=0
while [ $i -lt ${#leaf_no_data_ext_list[@]} ]; do
@@ -106,9 +106,11 @@ check_leaf_corrupt_no_data_ext()
${leaf_no_data_ext_list[i + 4]}
((i+=4))
done
- umount $TEST_MNT
+ $sudo umount $TEST_MNT
}
+setup_root_helper
+
generate_leaf_corrupt_no_data_ext test.img
check_image test.img
check_leaf_corrupt_no_data_ext test.img
--
2.1.3
next prev parent reply other threads:[~2015-01-14 17:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-25 1:32 [PATCH 0/5] New btrfsck test framework Qu Wenruo
2014-12-25 1:32 ` [PATCH 1/5] btrfs-progs: New btrfsck test infrastructure Qu Wenruo
2014-12-25 1:32 ` [PATCH 2/5] btrfs-progs: Move btrfs-image dump to corresponding dir Qu Wenruo
2014-12-25 1:32 ` [PATCH 3/5] btrfs-progs: Move bad root items test cases to its " Qu Wenruo
2014-12-25 1:32 ` [PATCH 4/5] btrfs-progs: Move leaf-corruption no extent data case and add verification script Qu Wenruo
2014-12-25 1:32 ` [PATCH 5/5] btrfs-progs: Move extent tree rebuild test to its dir Qu Wenruo
2015-01-14 17:25 ` [PATCH 1/2] btrfs-progs: tests, add support for running commands under root David Sterba
2015-01-15 0:33 ` Qu Wenruo
2015-01-19 18:07 ` David Sterba
2015-01-14 17:25 ` David Sterba [this message]
2015-01-14 17:43 ` [PATCH 0/5] New btrfsck test framework David Sterba
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=1421256309-8559-1-git-send-email-dsterba@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo@cn.fujitsu.com \
/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).