btrfs-progs: fix issues in tests
v3 cover btrfs-progs: fix issues in tests
Fixes issues found in tests.
path 3/4 canonicalized the TEST_DEV path and affected few test group. Unit tests passed however a complete tests runs is not done.
Anand Jain (4):
btrfs-progs: fix fsck-test/037 skip corrupt FREE_SPACE_BITMAP
btrfs-progs: fix TEST_TOP path drop extra forward slash
btrfs-progs: test clean start after failures
btrfs-progs: fix misc-test/029 provide device for mount
tests/clean-tests.sh | 2 +- tests/cli-tests.sh | 2 +- tests/common | 6 ++++++ tests/convert-tests.sh | 2 +- tests/fsck-tests.sh | 2 +- tests/fsck-tests/037-freespacetree-repair/test.sh | 14 ++++++++++---- tests/fuzz-tests.sh | 2 +- tests/misc-tests.sh | 3 ++- tests/misc-tests/029-send-p-different-mountpoints/test.sh | 3 ++- tests/mkfs-tests.sh | 2 +- 10 files changed, 26 insertions(+), 12 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/4 btrfs-progs: fix fsck-test/037 skip corrupt FREE_SPACE_BITMAP
We don't have the FREE_SPACE_BITMAP in the default filesystem, skip the sub test by checking if the objectid is null for the FREE_SPACE_BITMAP. The null objectid check for the FREE_SPACE_EXTENT is not actually required, it is added to maintain similar flow in the code above it.
--- tests/fsck-tests/037-freespacetree-repair/test.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
tests/fsck-tests/037-freespacetree-repair/test.sh +10 -4
@@ -29,6 +29,9 @@ corrupt_fst_item() objectid=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \ grep -o "[[:digit:]]* FREE_SPACE_BITMAP [[:digit:]]*" | \ cut -d' ' -f1 | tail -2 | head -1) + if [[ $objectid == "" ]]; then + return 1 + fi offset=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \ grep -o "[[:digit:]]* FREE_SPACE_BITMAP [[:digit:]]*" | \ cut -d' ' -f3 | tail -2 | head -1)
@@ -38,6 +41,9 @@ corrupt_fst_item() objectid=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \ grep -o "[[:digit:]]* FREE_SPACE_EXTENT [[:digit:]]*" | \ cut -d' ' -f1 | tail -2 | head -1) + if [[ $objectid == "" ]]; then + return 1 + fi offset=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \ grep -o "[[:digit:]]* FREE_SPACE_EXTENT [[:digit:]]*" | \ cut -d' ' -f3 | tail -2 | head -1)
@@ -48,6 +54,8 @@ corrupt_fst_item() run_check "$INTERNAL_BIN/btrfs-corrupt-block" -r 10 -K "$objectid,$type,$offset" \ -f offset "$TEST_DEV" + + return 0 } if ! [ -f "/sys/fs/btrfs/features/free_space_tree" ]; then
@@ -69,8 +77,7 @@ done run_check_umount_test_dev # now corrupt one of the bitmap items -corrupt_fst_item "bitmap" -check_image "$TEST_DEV" +corrupt_fst_item "bitmap" && check_image "$TEST_DEV" # change the freespace such that we now have at least one free_space_extent # object
@@ -80,5 +87,4 @@ run_check $SUDO_HELPER fallocate -l 50m "$TEST_MNT/file" run_check_umount_test_dev # now corrupt an extent -corrupt_fst_item "extent" -check_image "$TEST_DEV" +corrupt_fst_item "extent" && check_image "$TEST_DEV"
Signature · 1 line
1.8.3.1
PATCH v3 2/4 btrfs-progs: fix TEST_TOP path drop extra forward slash
In reply to Anand JainFrom
TEST_TOP="$TOP/tests/"
to
TEST_TOP="$TOP/tests"
Affected test cases are:tests/clean-tests.shtests/cli-tests.shtests/convert-tests.shtests/fsck-tests.shtests/fuzz-tests.shtests/misc-tests.shtests/mkfs-tests.sh
--- tests/clean-tests.sh | 2 +- tests/cli-tests.sh | 2 +- tests/convert-tests.sh | 2 +- tests/fsck-tests.sh | 2 +- tests/fuzz-tests.sh | 2 +- tests/misc-tests.sh | 2 +- tests/mkfs-tests.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
tests/clean-tests.sh +1 -1
@@ -7,7 +7,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
tests/cli-tests.sh +1 -1
@@ -8,7 +8,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
tests/convert-tests.sh +1 -1
@@ -9,7 +9,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
tests/fsck-tests.sh +1 -1
@@ -8,7 +8,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
tests/fuzz-tests.sh +1 -1
@@ -8,7 +8,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
tests/misc-tests.sh +1 -1
@@ -8,7 +8,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
tests/mkfs-tests.sh +1 -1
@@ -8,7 +8,7 @@ if [ -z "$TOP" ]; then TOP=$(readlink -f "$SCRIPT_DIR/../") if [ -f "$TOP/configure.ac" ]; then # inside git - TEST_TOP="$TOP/tests/" + TEST_TOP="$TOP/tests" INTERNAL_BIN="$TOP" else # external, defaults to system binaries
Signature · 1 line
1.8.3.1
Re: [PATCH 2/4] btrfs-progs: fix TEST_TOP path drop extra forward slash
Quoted 4 lines · Anand Jain
From
TEST_TOP="$TOP/tests/"
to
TEST_TOP="$TOP/tests"
So this basically repeats the diff
Quoted 8 lines
Affected test cases are:
tests/clean-tests.shtests/cli-tests.shtests/convert-tests.shtests/fsck-tests.shtests/fuzz-tests.shtests/misc-tests.shtests/mkfs-tests.sh
And this repeats the diffstat.
The changelog should explain why the change is made, summarize some key points, etc.
I'll apply this patch and write a changelog but please try to improve that. What works is to postpone sending the patches and read them after a day or two, if it still makes sense then send it. Second look reveals all the typos and missing information.
PATCH v3 3/4 btrfs-progs: test clean start after failures
In reply to Anand JainAfter a failure it fails for a different reason
=== START TEST /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints $TEST_DEV not given, using /btrfs-progs/tests/test.img as fallback ====== RUN MAYFAIL mkdir -p /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt ====== RUN CHECK /btrfs-progs/mkfs.btrfs -f /btrfs-progs/tests/test.img
ERROR: /btrfs-progs/tests/test.img is mounted <====
Add clean_start() helper to unmount.
--- tests/common | 6 ++++++ tests/misc-tests.sh | 1 + 2 files changed, 7 insertions(+)
tests/common +6 -0
@@ -788,6 +788,12 @@ cleanup_loopdevs() run_check $SUDO_HELPER losetup --all } +# add all the cleanups here +clean_start() +{ + grep -q $TEST_MNT /proc/self/mounts && umount $TEST_MNT +} + init_env() { TEST_MNT="${TEST_MNT:-$TEST_TOP/mnt}"
tests/misc-tests.sh +1 -0
@@ -40,6 +40,7 @@ export IMAGE export TEST_DEV rm -f "$RESULTS" +clean_start # test rely on corrupting blocks tool check_prereq btrfs-corrupt-block
Signature · 1 line
1.8.3.1
Re: [PATCH 3/4] btrfs-progs: test clean start after failures
Quoted 11 lines · Anand Jain
After a failure it fails for a different reason
=== START TEST /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints $TEST_DEV not given, using /btrfs-progs/tests/test.img as fallback ====== RUN MAYFAIL mkdir -p /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt ====== RUN CHECK /btrfs-progs/mkfs.btrfs -f /btrfs-progs/tests/test.img
ERROR: /btrfs-progs/tests/test.img is mounted <====Add
clean_start()helper to unmount.
The testsuite is designed to stop on first failure and it's up the user to investigate and clean it up before starting it again. For that there's the test-clean make target. In some cases it might not clean up the environment completely, but that's typically if the test image is not unmoutnable due to some process having the directory open.
Quoted 14 lines
tests/common +6
-0+# add all the cleanups here +clean_start() +{ + grep -q $TEST_MNT /proc/self/mounts && umount $TEST_MNT +} + init_env() { TEST_MNT="${TEST_MNT:-$TEST_TOP/mnt}"tests/misc-tests.sh +0
-0
tests/misc-tests.sh export IMAGE · line 43
Quoted 4 lines
tests/misc-tests.sh +1
-0@@ -40,6 +40,7 @@ export IMAGE export TEST_DEV rm -f "$RESULTS" +clean_start
Instead of this I'd rather make it a hard stop if there's some problem with the environment, like the mountpoint still mounted, or more loop devices from the specific tests still set up as loop devices etc.
When I get to this situation I fix it manually (checkint mount output, losetup -D), but it'd be nice to have that automated.
PATCH v3 4/4 btrfs-progs: fix misc-test/029 provide device for mount
In reply to Anand JainThe mount fails with 'file exists' error. Fix it by providing the device name.
$ make TEST=029\* test-misc
[TEST] misc-tests.sh
[TEST/misc] 029-send-p-different-mountpoints
failed: mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
test failed for case 029-send-p-different-mountpoints
make: *** [test-misc] Error 1====== RUN CHECK mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
mount: mount /dev/loop1 on /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
failed: File exists
failed: mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt test failed for case 029-send-p-different-mountpoints
---
v2: use readlink to sanitize the TEST_DEV path
v3: readlink for TEST_DEV is not needed drop it
tests/misc-tests/029-send-p-different-mountpoints/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/misc-tests/029-send-p-different-mountpoints/test.sh +2 -1
@@ -20,7 +20,8 @@ run_check_mkfs_test_dev run_check_mount_test_dev run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1" -run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$TEST_DEV" "$SUBVOL_MNT" +lodev=$(losetup | grep ${TEST_DEV} | awk '{print $1}') +run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$lodev" "$SUBVOL_MNT" run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/test-subvol" run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \
Signature · 1 line
1.8.3.1
Re: [PATCH v3 4/4] btrfs-progs: fix misc-test/029 provide device for mount
Quoted 33 lines · Anand Jain
The mount fails with 'file exists' error. Fix it by providing the device name.
$ make TEST=029\* test-misc [TEST] misc-tests.sh [TEST/misc] 029-send-p-different-mountpoints failed: mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt test failed for case 029-send-p-different-mountpoints make: *** [test-misc] Error 1====== RUN CHECK mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
mount: mount/dev/loop1on /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
failed: File exists
failed: mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt test failed for case 029-send-p-different-mountpointsSigned-off-by Anand Jain <[email protected]>---
v2: use readlink to sanitize theTEST_DEVpath
v3: readlink forTEST_DEVis not needed drop ittests/misc-tests/029-send-p-different-mountpoints/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tests/misc-tests/029-send-p-different-mountpoints/test.sh +0
-0
tests/misc-tests/029-send-p-different-mountpoints/test.sh run_check_mkfs_test_dev · line 24
Quoted 6 lines
tests/misc-tests/029-send-p-different-mountpoints/test.sh +2
-1@@ -20,7 +20,8 @@ run_check_mkfs_test_dev run_check_mount_test_dev run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1" -run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$TEST_DEV" "$SUBVOL_MNT" +lodev=$(losetup | grep ${TEST_DEV} | awk '{print $1}') +run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$lodev" "$SUBVOL_MNT"
The test dev is not necessarily a loop device, yes by default it is, but TEST_DEV can be set externally.
I still wonder why the test fails for you because it does not for me and without more information it's not clear what is mount reporting as 'File exists', which is EEXIST.