From 49bd94cc14c13927ca9867059b37144db2d923af Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 7 Oct 2021 17:05:34 +0200 Subject: [PATCH] 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 --- tests/misc-tests/038-backup-root-corruption/test.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/misc-tests/038-backup-root-corruption/test.sh b/tests/misc-tests/038-backup-root-corruption/test.sh index 5cab4c9a..b6c3671f 100755 --- a/tests/misc-tests/038-backup-root-corruption/test.sh +++ b/tests/misc-tests/038-backup-root-corruption/test.sh @@ -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"