From eca65a8977aba6f02dad820a88aacbb9120421ca Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 1 Mar 2017 09:21:51 +0800 Subject: [PATCH] btrfs-progs: tests: Allow check test to repair in lowmem mode for certain errors Since lowmem mode can repair certain corruptions (mostly in fs tree), insert a beacon into each fsck test cases to allow some of them be tested in lowmem mode. With this patch, fsck option override will check the beacon file ".lowmem_repairable" in the same directory of the test image, and if the beacon exists, then it will also run lowmem mode repair to repair the image. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- tests/common.local | 15 ++++++++++++++- .../004-no-dir-index/.lowmem_repairable | 0 .../009-no-dir-item-or-index/.lowmem_repairable | 0 .../010-no-rootdir-inode-item/.lowmem_repairable | 0 .../011-no-inode-item/.lowmem_repairable | 0 .../016-wrong-inode-nbytes/.lowmem_repairable | 0 .../.lowmem_repairable | 0 7 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/fsck-tests/004-no-dir-index/.lowmem_repairable create mode 100644 tests/fsck-tests/009-no-dir-item-or-index/.lowmem_repairable create mode 100644 tests/fsck-tests/010-no-rootdir-inode-item/.lowmem_repairable create mode 100644 tests/fsck-tests/011-no-inode-item/.lowmem_repairable create mode 100644 tests/fsck-tests/016-wrong-inode-nbytes/.lowmem_repairable create mode 100644 tests/fsck-tests/017-missing-all-file-extent/.lowmem_repairable diff --git a/tests/common.local b/tests/common.local index d2b8d073..f5e96f5b 100644 --- a/tests/common.local +++ b/tests/common.local @@ -14,11 +14,24 @@ fi # gets arguments of a current command and can decide if the argument insertion # should happen, eg. if some option combination does not make sense or would # break tests +# +# Return 0 if we need to skip option override +# Return 1 if we don't need to skip option override _skip_spec() { + local beacon + + beacon=.lowmem_repairable + + # For lowmem repair, only support fs tree repair for now + # So we place lowmem repair beacon in the same dir of the test case if echo "$TEST_ARGS_CHECK" | grep -q 'mode=lowmem' && echo "$@" | grep -q -- '--repair'; then - return 0 + dir="$(dirname ${@: -1})" + if [ -f ${dir}/${beacon} ]; then + return 1; + fi + return 0; fi return 1 } diff --git a/tests/fsck-tests/004-no-dir-index/.lowmem_repairable b/tests/fsck-tests/004-no-dir-index/.lowmem_repairable new file mode 100644 index 00000000..e69de29b diff --git a/tests/fsck-tests/009-no-dir-item-or-index/.lowmem_repairable b/tests/fsck-tests/009-no-dir-item-or-index/.lowmem_repairable new file mode 100644 index 00000000..e69de29b diff --git a/tests/fsck-tests/010-no-rootdir-inode-item/.lowmem_repairable b/tests/fsck-tests/010-no-rootdir-inode-item/.lowmem_repairable new file mode 100644 index 00000000..e69de29b diff --git a/tests/fsck-tests/011-no-inode-item/.lowmem_repairable b/tests/fsck-tests/011-no-inode-item/.lowmem_repairable new file mode 100644 index 00000000..e69de29b diff --git a/tests/fsck-tests/016-wrong-inode-nbytes/.lowmem_repairable b/tests/fsck-tests/016-wrong-inode-nbytes/.lowmem_repairable new file mode 100644 index 00000000..e69de29b diff --git a/tests/fsck-tests/017-missing-all-file-extent/.lowmem_repairable b/tests/fsck-tests/017-missing-all-file-extent/.lowmem_repairable new file mode 100644 index 00000000..e69de29b