diff mbox series

[3/3] btrfs-progs: misc-tests: add a basic resume test using error injection

Message ID 977dda7e1d53682ac275444c9db87a256c262c77.1718775066.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: csum-change enhancement | expand

Commit Message

Qu Wenruo June 19, 2024, 5:33 a.m. UTC
The new test case does:

- Inject error at the very first commit transaction to make sure the
  injection is compiled in
- 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        | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100755 tests/misc-tests/065-csum-conversion-inject/test.sh
diff mbox series

Patch

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..10d3cf02063b
--- /dev/null
+++ b/tests/misc-tests/065-csum-conversion-inject/test.sh
@@ -0,0 +1,48 @@ 
+#!/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()
+{
+	run_check_mkfs_test_dev --csum crc32c
+
+	# This is for the very first transaction commit.
+	export INJECT="0x3964edd9"
+	run_mayfail "$TOP/btrfstune" --csum xxhash "$TEST_DEV" &&\
+		_not_run "this test requires debug build with error injection"
+	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