btrfs-progs: tests: make misc/038 work with free-space-tree

The test misc-tests/038-backup-root-corruption expects a particular
layout of the backup roots but this gets slightly changed due to free
space tree.

  $ make TEST=038-backup-root-corruption TEST_ARGS_MKFS='-Rfree-space-tree' TEST_ENABLE_OVERRIDE=true test-misc

Will result in test failure as the expected root is in slot 3 and not 2.
Update the test to try both.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-10-07 17:05:34 +02:00
parent d0ea2b2af4
commit 49bd94cc14
1 changed files with 9 additions and 1 deletions

View File

@ -25,7 +25,15 @@ backup2_root_ptr=$(dump_super | grep -A1 "backup 2" | grep backup_tree_root | aw
main_root_ptr=$(dump_super | awk '/^root\t/{print $2}')
[ "$backup2_root_ptr" -eq "$main_root_ptr" ] || _fail "Backup slot 2 is not in use"
if [ "$backup2_root_ptr" -ne "$main_root_ptr" ]; then
_log "Backup slot 2 not in use, trying slot 3"
# Or use the next slot in case of free-space-tree
backup3_root_ptr=$(dump_super | grep -A1 "backup 3" | grep backup_tree_root | awk '{print $2}')
if [ "$backup3_root_ptr" -ne "$main_root_ptr" ]; then
_fail "Neither backup slot 2 nor slot 3 are in use"
fi
_log "Backup slot 3 in use"
fi
run_check "$INTERNAL_BIN/btrfs-corrupt-block" -m $main_root_ptr -f generation "$TEST_DEV"