diff mbox series

[2/2] btrfs-progs: convert-tests: new test case to verify the rollback output

Message ID 4ed8c93ac44c1e1a628eec173e666240a7c0673b.1721020542.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: convert: fix the rollback filename output | expand

Commit Message

Qu Wenruo July 15, 2024, 5:17 a.m. UTC
The new new test case is to make sure the rollback output for a fixed
content converted fs contains the string "ext2_saved/image".

As we have a bug in the past where after the string "ext2_saved", we can
have some unterminated garbage.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../convert-tests/026-rollback-output/test.sh | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 tests/convert-tests/026-rollback-output/test.sh
diff mbox series

Patch

diff --git a/tests/convert-tests/026-rollback-output/test.sh b/tests/convert-tests/026-rollback-output/test.sh
new file mode 100755
index 000000000000..ed3d14c1aa5e
--- /dev/null
+++ b/tests/convert-tests/026-rollback-output/test.sh
@@ -0,0 +1,26 @@ 
+#!/bin/bash
+# Make sure "btrfs-convert -r" is outputting the correct filename
+
+source "$TEST_TOP/common" || exit
+source "$TEST_TOP/common.convert" || exit
+
+setup_root_helper
+prepare_test_dev
+
+check_global_prereq mkfs.ext4
+check_prereq btrfs-convert
+check_prereq btrfs
+
+convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
+run_check_umount_test_dev
+convert_test_do_convert
+
+tmp=$(mktemp --tmpdir btrfs-progs-convert-rollback.XXXXXX)
+# Rollback and save the output.
+run_check_stdout "$TOP/btrfs-convert" --rollback "$TEST_DEV" >> "$tmp"
+
+if ! grep -q "ext2_saved/image" "$tmp"; then
+	rm -f -- "$tmp"
+	_fail "rollback filename output is corruptedd"
+fi
+rm -f -- "$tmp"