summaryrefslogtreecommitdiff
path: root/tests/fsck-tests
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2015-03-02 11:41:50 +0800
committerDavid Sterba <dsterba@suse.cz>2015-03-09 12:08:56 +0100
commita624680b0e45e0f7ea1c847f8ccebe04aa52ba75 (patch)
tree51d6859eaff8328eb8d3f5d7ed668ad7ae519063 /tests/fsck-tests
parent0c13bf7936a0388c0bdc99dc80218a0179c88f31 (diff)
btrfs-progs: fsck-test: Add check_sudo to check valid root/sudo privilege
Although fsck-test/012 uses sudo, it uses 'sudo -n', which won't prompt user to input password and will return 1 if no valid credential is found. And this makes test result quite annoying since it fails to mount and still continue, which will always fail. This patch will check 'sudo -v -n' and 'sudo -n true' to determine whether sudo works fine in different version/settings, since in some setting/version, 'sudo -v -n' will fail even the user is set NOPASSWD. Also, remove the 'have_root_helper' variant, since there is a possibility that sudo credential will timeout during the test and 'have_root_helper' won't help to detect such problem. New '_sudo' command will do credential check if needed to avoid such problem. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'tests/fsck-tests')
-rwxr-xr-xtests/fsck-tests/012-leaf-corruption/test.sh14
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/fsck-tests/012-leaf-corruption/test.sh b/tests/fsck-tests/012-leaf-corruption/test.sh
index 896f717a..5873e3fb 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=$($sudo 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$($sudo 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=$($sudo 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,16 +85,12 @@ check_inode()
check_leaf_corrupt_no_data_ext()
{
image=$1
- if [ $have_root_helper -ne 1 ]; then
- echo " [NOTRUN] root privileges needed to verify recovery"
- exit 0
- fi
if [ -z $TEST_MNT ]; then
echo "\$TEST_MNT not set, use $(pwd)/tmp as fallback"
TEST_MNT="$(pwd)/tmp"
fi
mkdir -p $TEST_MNT || _fail "failed to create mount point"
- $sudo 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,7 +102,7 @@ check_leaf_corrupt_no_data_ext()
${leaf_no_data_ext_list[i + 4]}
((i+=4))
done
- $sudo umount $TEST_MNT
+ $_sudo umount $TEST_MNT
}
setup_root_helper