From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 3/3] btrfs-progs: misc-tests: add a basic resume test using error injection
Date: Fri, 21 Jun 2024 14:46:56 +0930 [thread overview]
Message-ID: <470dda58291481fe01e53d904be3db6141ff93fb.1718946934.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1718946934.git.wqu@suse.com>
The new test case does:
- Inject error at the very first commit transaction to make sure the
injection is compiled in
Furthermore check the stdout/stderr to make sure the failure is really
caued by the error injection.
- Inject error at the last commit transaction of new data csum
generation
- Resume the csum conversion and make sure it works
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
.../065-csum-conversion-inject/test.sh | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100755 tests/misc-tests/065-csum-conversion-inject/test.sh
diff --git a/tests/misc-tests/065-csum-conversion-inject/test.sh b/tests/misc-tests/065-csum-conversion-inject/test.sh
new file mode 100755
index 000000000000..c213232ec545
--- /dev/null
+++ b/tests/misc-tests/065-csum-conversion-inject/test.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Verify the csum conversion can still resume after an interruption
+
+source "$TEST_TOP/common" || exit
+source "$TEST_TOP/common.convert" || exit
+
+check_experimental_build
+setup_root_helper
+prepare_test_dev
+
+check_injection()
+{
+ local tmp_output=$(mktemp --tmpdir btrfs-progs-check-injection.XXXXXX)
+ local ret
+
+ run_check_mkfs_test_dev --csum crc32c
+
+ # This is for the very first transaction commit.
+ export INJECT="0x3964edd9"
+ "$TOP/btrfstune" --csum xxhash "$TEST_DEV" &> "$tmp_output"
+ ret=$?
+ cat "$tmp_output" >> "$RESULTS"
+ if [ "$ret" -eq 0 ]; then
+ _not_run "this test requires debug build with error injection"
+ fi
+ if ! grep -q "$INJECT" "$tmp_output"; then
+ rm "$tmp_output"
+ unset INJECT
+ _fail "csum conversion failed for unexpected reasons."
+ fi
+ rm "$tmp_output"
+ unset INJECT
+}
+
+test_resume_data_csum_generation()
+{
+ local new_csum="$1"
+
+ # Error at the end of the data csum generation.
+ export INJECT="0x4de02239"
+ run_mustfail "error injection not working" "$TOP/btrfstune" \
+ --csum "$new_csum" "$TEST_DEV"
+ unset INJECT
+ run_check "$TOP/btrfstune" --csum "$new_csum" "$TEST_DEV"
+ run_check "$TOP/btrfs" check --check-data-csum "$TEST_DEV"
+}
+
+check_injection
+
+run_check_mkfs_test_dev --csum crc32c
+
+# We only mount the filesystem once to populate its contents, later one we
+# would never mount the fs (to reduce the dependency on kernel features).
+run_check_mount_test_dev
+populate_fs
+run_check_umount_test_dev
+
+test_resume_data_csum_generation xxhash
+test_resume_data_csum_generation blake2
+test_resume_data_csum_generation sha256
+test_resume_data_csum_generation crc32c
--
2.45.2
prev parent reply other threads:[~2024-06-21 5:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 5:16 [PATCH v2 0/3] btrfs-progs: btrfs-progs: csum-change enhancement Qu Wenruo
2024-06-21 5:16 ` [PATCH v2 1/3] btrfs-progs: csum-change: add error handling for search old csums Qu Wenruo
2024-06-21 5:16 ` [PATCH v2 2/3] btrfs-progs: csum-change: add leaf based threshold Qu Wenruo
2024-06-21 5:16 ` Qu Wenruo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=470dda58291481fe01e53d904be3db6141ff93fb.1718946934.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox