btrfs-progs: tests: also check subpage warning for check_image cases

There are two types of test cases:

- Type 1 (without test.sh)
- Type 2 (test.sh, mostly will override check_image())

For Type 2 tests, we check subpage related warnings of btrfs-check, but
didn't check it for Type 1 test cases.

In fact, Type 1 test cases are more important, as they involve repair,
which can generate new tree blocks, and we want to make sure such new
tree blocks won't cause subpage related warnings.

This patch will add the extra check for Type 1 test cases.

And it will make sure the subpage related warnings are really from this
test case, to prevent false alerts.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2021-08-18 14:44:18 +08:00 committed by David Sterba
parent dc29a5c51d
commit 82e0720312

View File

@ -422,14 +422,26 @@ check_dm_target_support()
check_image()
{
local image
local tmp_output
tmp_output=$(mktemp --tmpdir btrfs-progs-test-check-image.XXXXXX)
image=$1
echo "testing image $(basename $image)" >> "$RESULTS"
"$TOP/btrfs" check "$image" >> "$RESULTS" 2>&1
[ $? -eq 0 ] && _fail "btrfs check should have detected corruption"
"$TOP/btrfs" check "$image" &> "$tmp_output"
ret=$?
cat "$tmp_output" >> "$RESULTS"
[ "$ret" -eq 0 ] && _fail "btrfs check should have detected corruption"
# Also make sure no subpage related warnings
check_test_results "$tmp_output" "$testname"
run_check "$TOP/btrfs" check --repair --force "$image"
run_check "$TOP/btrfs" check "$image"
run_check_stdout "$TOP/btrfs" check "$image" &> "$tmp_output"
# Also make sure no subpage related warnings for the repaired image
check_test_results "$tmp_output" "$testname"
rm -f -- "$tmp_output"
}
# Extract a usable image from packed formats