On Mon, Feb 22, 2016 at 02:59:57PM +0800, Qu Wenruo wrote:
> zA}GrL`3QeIdg)w^i(C5r-$jn2OSESOZGFpc5^m2cCgLRjc8Y&wBj@6PxG<e;@Q)<_
> Mne-=t|1Sdn0?V+~RR910
>
> literal 0
> HcmV?d00001
>
> diff --git a/tests/misc-tests/012-find-root-no-result/test.sh b/tests/misc-tests/012-find-root-no-result/test.sh
> new file mode 100644
> index 0000000..4951633
> --- /dev/null
> +++ b/tests/misc-tests/012-find-root-no-result/test.sh
> @@ -0,0 +1,20 @@
> +#!/bin/bash
> +# Regression test for case btrfs-find-root may print no result on a
> +# recent fs or balanced fs, whose metadata chunk is the first chunk
> +# and the only metadata chunk
> +
> +source $TOP/tests/common
> +
> +check_prereq btrfs-find-root
> +check_prereq btrfs-image
> +
> +$TOP/btrfs-image -r first_meta_chunk.btrfs-image test.img || \
> + _fail "failed to extract first_meta_chunk.btrfs-image"
> +
> +result=$($TOP/btrfs-find-root test.img | sed '/^Superblock/d')
> +
> +if [ -z "$result" ]; then
> + _fail "btrfs-find-root failed to find tree root"
> +fi
> +
> +rm test.img
Applied with following fixups:
--- a/tests/misc-tests/012-find-root-no-result/test.sh
+++ b/tests/misc-tests/012-find-root-no-result/test.sh
@@ -8,13 +8,17 @@ source $TOP/tests/common
check_prereq btrfs-find-root
check_prereq btrfs-image
-$TOP/btrfs-image -r first_meta_chunk.btrfs-image test.img || \
+run_check $TOP/btrfs-image -r first_meta_chunk.btrfs-image test.img || \
_fail "failed to extract first_meta_chunk.btrfs-image"
-result=$($TOP/btrfs-find-root test.img | sed '/^Superblock/d')
+result=$(run_check_stdout $TOP/btrfs-find-root test.img | sed '/^Superblock/d')
if [ -z "$result" ]; then
_fail "btrfs-find-root failed to find tree root"
fi
+if ! echo "$result" | grep -q 'Found tree root at'; then
+ _fail "btrfs-find-root failed to find tree root, unexpected output"
+fi
+
rm test.img
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html