Thread (11 messages) 11 messages, 2 authors, 2016-02-25

Re: [PATCH 5/5] btrfs-progs: misc-test: Add regression test for find-root gives empty result

From: David Sterba <hidden>
Date: 2016-02-24 12:11:03

On Mon, Feb 22, 2016 at 02:59:57PM +0800, Qu Wenruo wrote:
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help