[3/3] btrfs-progs: fsck-test: case for corrupted dir item name
diff mbox

Message ID 20170714074746.28177-3-suy.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Su Yue July 14, 2017, 7:47 a.m. UTC
In this test case, all name in dir_item, dir_index, inode_ref
are corrupted to another one.
btrfs check should report errors about the corrupted dir_item but
btrfs can't repair the case now.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 .../fsck-tests/026-bad-dir-item-name/default_case.img.xz | Bin 0 -> 1924 bytes
 tests/fsck-tests/026-bad-dir-item-name/test.sh           |  13 +++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz
 create mode 100755 tests/fsck-tests/026-bad-dir-item-name/test.sh

Comments

David Sterba Aug. 23, 2017, 5:13 p.m. UTC | #1
On Fri, Jul 14, 2017 at 03:47:46PM +0800, Su Yue wrote:
> In this test case, all name in dir_item, dir_index, inode_ref
> are corrupted to another one.
> btrfs check should report errors about the corrupted dir_item but
> btrfs can't repair the case now.
> 
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
>  .../fsck-tests/026-bad-dir-item-name/default_case.img.xz | Bin 0 -> 1924 bytes
>  tests/fsck-tests/026-bad-dir-item-name/test.sh           |  13 +++++++++++++
>  2 files changed, 13 insertions(+)
>  create mode 100644 tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz
>  create mode 100755 tests/fsck-tests/026-bad-dir-item-name/test.sh
> 
> diff --git a/tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz b/tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz
> new file mode 100644
> index 0000000000000000000000000000000000000000..27e8553f103095170420c0e115cab4bc889c2af5
> GIT binary patch
> literal 1924
> zcmV-~2YdMaH+ooF000E$*0e?f03iVu0001VFXf})3;zd1T>wRyj;C3^v%$$4d1t#p
> zhBKh;(bwue6)D<_5I7>z%J5C)A&&>6?lo!ie$bd8`v{))yg-I115-YV9jb8*<k9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Cyyf{%N%`u(f}%=E#P~`Ly*<NR_=?@VGr}kp3?ZBVAP?YK
> z=xKj!f>qG_Nfz<bNEHI;=&!Ai+W@lT=(S%^VnD_b^Q`Z!q>xGDrCS=&Q2Qg@v<Vng
> z`+lI-Dc3H;7_hDgjr;QcR?<BLjClA^Jb%ICn?~Jo){NV>3;Z=#e+p)R!nYrnu~L@K
> z6d?=m1ZsNX$W?=u{byS+^y!aE>yhFncJubwz8*?+4HoXj{B7oKzghz%cb}#G|JRNg
> z_iS1_L_@Gyy7KcQlwur;Hlqa!l`K#J#sC1dx@D`5yoSO60pJdR7ytmxHBFVV#Ao{g
> K000001X)^)|E<>m
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/tests/fsck-tests/026-bad-dir-item-name/test.sh b/tests/fsck-tests/026-bad-dir-item-name/test.sh
> new file mode 100755
> index 00000000..00a550ce
> --- /dev/null
> +++ b/tests/fsck-tests/026-bad-dir-item-name/test.sh
> @@ -0,0 +1,13 @@
> +#!/bin/bash
> +#
> +# confirm whether btrfsck supports to check name and hash mismatch in dir_item
> +
> +source "$TOP/tests/common"
> +
> +check_prereq btrfs
> +
> +image=$(extract_image "./default_case.img.xz")
> +
> +run_mustfail "$TOP/btrfs" check "$image"

run_mustfail requires 1st argument to be a string that's printed in case
the command (2nd parameter) unexpectedly succeeds. So this test really
fails but because it does not find the 'check' command, not something we
want of course. I'll fix that and add some sort of assertion to
run_mustfail so this is caught when the test is being developed, I think
the 1st extra parameter is too easy to forget.

The patches look otherwise ok, 1-3 fixed applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz b/tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..27e8553f103095170420c0e115cab4bc889c2af5
GIT binary patch
literal 1924
zcmV-~2Yd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oEnK601Yq<FCZKb0+0k@Wob<=L^nC}Ei7r_kXu;jQnyLQLGVdg3_?RIg$7s$
zdb#K8y_cp=>d$qK1-D4Cyyf{%N%`u(f}%=E#P~`Ly*<NR_=?@VGr}kp3?ZBVAP?YK
z=xKj!f>qG_Nfz<bNEHI;=&!Ai+W@lT=(S%^VnD_b^Q`Z!q>xGDrCS=&Q2Qg@v<Vng
z`+lI-Dc3H;7_hDgjr;QcR?<BLjClA^Jb%ICn?~Jo){NV>3;Z=#e+p)R!nYrnu~L@K
z6d?=m1ZsNX$W?=u{byS+^y!aE>yhFncJubwz8*?+4HoXj{B7oKzghz%cb}#G|JRNg
z_iS1_L_@Gyy7KcQlwur;Hlqa!l`K#J#sC1dx@D`5yoSO60pJdR7ytmxHBFVV#Ao{g
K000001X)^)|E<>m

literal 0
HcmV?d00001

diff --git a/tests/fsck-tests/026-bad-dir-item-name/test.sh b/tests/fsck-tests/026-bad-dir-item-name/test.sh
new file mode 100755
index 00000000..00a550ce
--- /dev/null
+++ b/tests/fsck-tests/026-bad-dir-item-name/test.sh
@@ -0,0 +1,13 @@ 
+#!/bin/bash
+#
+# confirm whether btrfsck supports to check name and hash mismatch in dir_item
+
+source "$TOP/tests/common"
+
+check_prereq btrfs
+
+image=$(extract_image "./default_case.img.xz")
+
+run_mustfail "$TOP/btrfs" check "$image"
+
+rm -f "$image"