summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2018-04-03 13:39:47 +0800
committerDavid Sterba <dsterba@suse.com>2018-04-24 13:00:11 +0200
commit5f53c23e7676e9fafb78fa166e3f00e143b5a2c5 (patch)
treea6039863b686c15610f82676274c97554e011883
parent2777e53911c51e33cf689eccab285ec557f13b12 (diff)
downloadbtrfs-progs-5f53c23e7676e9fafb78fa166e3f00e143b5a2c5.tar.gz
btrfs-progs-5f53c23e7676e9fafb78fa166e3f00e143b5a2c5.tar.bz2
btrfs-progs-5f53c23e7676e9fafb78fa166e3f00e143b5a2c5.zip
btrfs-progs: tests/fsck: Add test case to check if btrfs check can skip data csum verfication for metadata dump
Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rwxr-xr-xtests/fsck-tests/031-metadatadump-check-data-csum/test.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh b/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh
new file mode 100755
index 00000000..30b0b7a3
--- /dev/null
+++ b/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# To check if "btrfs check" can detect metadata dump (restored by btrfs-iamge)
+# and ignore --check-data-csum option
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+check_prereq mkfs.btrfs
+check_prereq btrfs-image
+setup_root_helper
+prepare_test_dev
+
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
+run_check_mount_test_dev
+
+run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/file" bs=4k count=16
+run_check_umount_test_dev
+
+run_check $SUDO_HELPER "$TOP/btrfs-image" "$TEST_DEV" "restored_image"
+
+# use prepare_test_dev() to wipe all existing data on $TEST_DEV
+# so there is no way that restored image could have mathcing data csum
+prepare_test_dev
+
+run_check $SUDO_HELPER "$TOP/btrfs-image" -r "restored_image" "$TEST_DEV"
+
+# Should not report any error
+run_check "$TOP/btrfs" check --check-data-csum "$TEST_DEV"
+
+rm -rf -- "restored_image*"