* [PATCH] btrfs-progs: fsck-tests: script to verify init-csum-tree
@ 2017-01-26 19:39 Lakshmipathi.G
0 siblings, 0 replies; only message in thread
From: Lakshmipathi.G @ 2017-01-26 19:39 UTC (permalink / raw)
To: dsterba, linux-btrfs
Corrupt csum entry of a file and re-create csum tree using --init-csum
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
.../fsck-tests/025-verify-init-csum-option/test.sh | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100755 tests/fsck-tests/025-verify-init-csum-option/test.sh
diff --git a/tests/fsck-tests/025-verify-init-csum-option/test.sh b/tests/fsck-tests/025-verify-init-csum-option/test.sh
new file mode 100755
index 0000000..f496b33
--- /dev/null
+++ b/tests/fsck-tests/025-verify-init-csum-option/test.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# This is a basic script to verify --init-csum recreates the csum tree.
+
+source $TOP/tests/common
+
+check_prereq btrfs-corrupt-block
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 512M
+
+
+# simulate missing csum error and repair using init-csum option
+test_csum_corruption()
+{
+ run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+
+ run_check_mount_test_dev
+
+ export DATASET_SIZE=1
+ generate_dataset small
+
+ run_check_umount_test_dev
+
+ # find bytenr
+ bytenr=`$SUDO_HELPER $TOP/btrfs inspect-internal dump-tree -t csum $TEST_DEV | \
+ sed -n -r 's/.*EXTENT_CSUM (.*)\) itemoff .*/\1/p'`
+
+ # corrupt csum bytenr
+ run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -C $bytenr $TEST_DEV
+ $SUDO_HELPER $TOP/btrfs check $TEST_DEV &>> $RESULTS && \
+ _fail "btrfs check failed to detect missing csum."
+ run_check $SUDO_HELPER $TOP/btrfs check --repair --init-csum $TEST_DEV
+ run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
+}
+
+test_csum_corruption
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-26 19:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-26 19:39 [PATCH] btrfs-progs: fsck-tests: script to verify init-csum-tree Lakshmipathi.G
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).