btrfs-progs: make some of the fsck-tests run without root
cover btrfs-progs: make some of the fsck-tests run without root
Hello,
While running tests on my ctree sync patches I noticed these tests were failing when I ran as a normal user. Most of them are just needing to call setup_root_helper before calling the loop device helpers, some need a $SUDO_HELPER added to a few places. With these patches in place I can run make test-fsck as a normal user. Thanks,
Josef
Josef Bacik (4):
btrfs-progs: fix fsck-tests/056 to run without root
btrfs-progs: fix fsck-tests/057 to run without root
btrfs-progs: fix fsck-tests/059 to run without root
btrfs-progs: fix fsck-tests/060 to run without root
tests/fsck-tests/056-raid56-false-alerts/test.sh | 6 +++--- tests/fsck-tests/057-seed-false-alerts/test.sh | 8 ++++---- tests/fsck-tests/059-shrunk-device/test.sh | 4 ++-- tests/fsck-tests/060-degraded-check/test.sh | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/4 btrfs-progs: fix fsck-tests/056 to run without root
We need to make sure the root helper is setup before calling the loop helpers, and additionally we need to use $SUDO_HELPER when we run the final btrfs check. With this patch we can now run this test as a normal user.
--- tests/fsck-tests/056-raid56-false-alerts/test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/fsck-tests/056-raid56-false-alerts/test.sh +3 -3
@@ -10,13 +10,13 @@ check_prereq btrfs check_prereq mkfs.btrfs check_global_prereq losetup +setup_root_helper + setup_loopdevs 3 prepare_loopdevs dev1=${loopdevs[1]} TEST_DEV=$dev1 -setup_root_helper - run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid1 -d raid5 "${loopdevs[@]}" run_check_mount_test_dev
@@ -26,6 +26,6 @@ run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/file" bs=16K count=1 \ run_check_umount_test_dev # Check data csum should not report false alerts -run_check "$TOP/btrfs" check --check-data-csum "$dev1" +run_check $SUDO_HELPER "$TOP/btrfs" check --check-data-csum "$dev1" cleanup_loopdevs
Signature · 1 line
2.39.2
PATCH 2/4 btrfs-progs: fix fsck-tests/057 to run without root
In reply to Josef BacikThe setup_root_helper needs to be called before messing with the loop devices, and btrfs check needs to be run with $SUDO_HELPER.
--- tests/fsck-tests/057-seed-false-alerts/test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tests/fsck-tests/057-seed-false-alerts/test.sh +4 -4
@@ -10,14 +10,14 @@ check_prereq mkfs.btrfs check_prereq btrfstune check_global_prereq losetup +setup_root_helper + setup_loopdevs 2 prepare_loopdevs dev1=${loopdevs[1]} dev2=${loopdevs[2]} TEST_DEV=$dev1 -setup_root_helper - run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev1" run_check $SUDO_HELPER "$TOP/btrfstune" -S 1 "$dev1" run_check_mount_test_dev
@@ -32,8 +32,8 @@ sprouted_output=$(_mktemp btrfs-progs-sprouted-check-stdout.XXXXXX) # The false alerts are just warnings, so we need to save and filter # the output -run_check_stdout "$TOP/btrfs" check "$dev1" >> "$seed_output" -run_check_stdout "$TOP/btrfs" check "$dev2" >> "$sprouted_output" +run_check_stdout $SUDO_HELPER "$TOP/btrfs" check "$dev1" >> "$seed_output" +run_check_stdout $SUDO_HELPER "$TOP/btrfs" check "$dev2" >> "$sprouted_output" # There should be no warning for both seed and sprouted fs if grep -q "WARNING" "$seed_output"; then
Signature · 1 line
2.39.2
PATCH 3/4 btrfs-progs: fix fsck-tests/059 to run without root
In reply to Josef BacikWe missed a couple of $SUDO_HELPER uses in this test that made it impossible to run without root. Add them in so we can run as a normal user.
--- tests/fsck-tests/059-shrunk-device/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/fsck-tests/059-shrunk-device/test.sh +2 -2
@@ -14,7 +14,7 @@ _mktemp_local "$file" 1g dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file") -run_check "$TOP/mkfs.btrfs" -f "$dev" +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev" # The original device size from prepare_loopdevs is 2G. # Since the fs is empty, shrinking it to 996m will not cause any
@@ -26,5 +26,5 @@ dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file") run_mustfail "btrfs check should detect errors in device size" \ "$TOP/btrfs" check "$dev" -losetup -d "$dev" +$SUDO_HELPER losetup -d "$dev" rm -- "$file"
Signature · 1 line
2.39.2
PATCH 4/4 btrfs-progs: fix fsck-tests/060 to run without root
In reply to Josef BacikWe need to call the setup_root_helper before we start messing with the loop devices.
--- tests/fsck-tests/060-degraded-check/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/fsck-tests/060-degraded-check/test.sh +2 -2
@@ -10,14 +10,14 @@ check_prereq mkfs.btrfs check_global_prereq losetup check_global_prereq wipefs +setup_root_helper + setup_loopdevs 3 prepare_loopdevs dev1=${loopdevs[1]} dev2=${loopdevs[2]} dev3=${loopdevs[3]} -setup_root_helper - # Run 1: victim is dev1 run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" run_check $SUDO_HELPER wipefs -fa $dev1
Signature · 1 line
2.39.2
Quoted 17 lines · Josef Bacik
Hello,
While running tests on my ctree sync patches I noticed these tests were failing when I ran as a normal user. Most of them are just needing to call
setup_root_helperbefore calling the loop device helpers, some need a $SUDO_HELPER added to a few places. With these patches in place I can run make test-fsck as a normal user. Thanks,Josef
Josef Bacik (4):
btrfs-progs: fix fsck-tests/056 to run without root
btrfs-progs: fix fsck-tests/057 to run without root
btrfs-progs: fix fsck-tests/059 to run without root
btrfs-progs: fix fsck-tests/060 to run without root
Quoted 9 lines
tests/fsck-tests/056-raid56-false-alerts/test.sh | 6 +++--- tests/fsck-tests/057-seed-false-alerts/test.sh | 8 ++++---- tests/fsck-tests/059-shrunk-device/test.sh | 4 ++-- tests/fsck-tests/060-degraded-check/test.sh | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-)--
2.39.2
LGTM.
--
真実はいつも一つ!/ Always, there's only one truth!
Quoted 8 lines · Josef Bacik
Hello,
While running tests on my ctree sync patches I noticed these tests were failing when I ran as a normal user. Most of them are just needing to call
setup_root_helperbefore calling the loop device helpers, some need a $SUDO_HELPER added to a few places. With these patches in place I can run make test-fsck as a normal user. Thanks,
Quoted 7 lines
Josef
Josef Bacik (4):
btrfs-progs: fix fsck-tests/056 to run without root
btrfs-progs: fix fsck-tests/057 to run without root
btrfs-progs: fix fsck-tests/059 to run without root
btrfs-progs: fix fsck-tests/060 to run without root
Added to devel, thanks. I went through all other tests, there are some more missing helper setup calls but they're also called within some other helpers (like run_check_mkfs_test_dev). I've added them for clarity.