Thread (5 messages) 5 messages, 3 authors, 2021-09-20
STALE1762d

[PATCH 2/2] btrfs-progs: misc-tests: add new test case to make sure btrfstune rejects corrupted fs

From: Qu Wenruo <hidden>
Date: 2021-09-08 02:05:53
Subsystem: the rest · Maintainer: Linus Torvalds

Although btrfstune will already warn users to make sure the fs is not
corrupted, we can never trust end users.

If the target fs has transid error, btrfstune can cause further damage,
thus we need to make sure btrfstune can safely reject fs with transid
error, other than ignoring the problem.

The image is copied from fsck-tests/002, just override check_image() to
run "btrfstune -u" instead.

Signed-off-by: Qu Wenruo <redacted>
---
 .../default_case.img                             |  1 +
 .../049-btrfstune-transid-mismatch/test.sh       | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
 create mode 120000 tests/misc-tests/049-btrfstune-transid-mismatch/default_case.img
 create mode 100755 tests/misc-tests/049-btrfstune-transid-mismatch/test.sh
diff --git a/tests/misc-tests/049-btrfstune-transid-mismatch/default_case.img b/tests/misc-tests/049-btrfstune-transid-mismatch/default_case.img
new file mode 120000
index 000000000000..eb54ddcbb402
--- /dev/null
+++ b/tests/misc-tests/049-btrfstune-transid-mismatch/default_case.img
@@ -0,0 +1 @@
+../../fsck-tests/002-bad-transid/default_case.img
\ No newline at end of file
diff --git a/tests/misc-tests/049-btrfstune-transid-mismatch/test.sh b/tests/misc-tests/049-btrfstune-transid-mismatch/test.sh
new file mode 100755
index 000000000000..c6d721eaea65
--- /dev/null
+++ b/tests/misc-tests/049-btrfstune-transid-mismatch/test.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+# Verify that btrfstune would reject fs with transid mismatch problems
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs-image
+check_prereq btrfs
+check_prereq btrfstune
+
+# Although we're not checking the image, here we just reuse the infrastructure
+check_image() {
+	run_mustfail "btrfstune should fail when the image has transid error" \
+		  "$TOP/btrfstune" -u "$1"
+}
+
+check_all_images
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help