f4a57e761e3e8fc3d6e36fa78d0c7db9dd1a01cc
[platform/upstream/btrfs-progs.git] / tests / misc-tests / 012-find-root-no-result / test.sh
1 #!/bin/bash
2 # Regression test for case btrfs-find-root may print no result on a
3 # recent fs or balanced fs, whose metadata chunk is the first chunk
4 # and the only metadata chunk
5
6 source "$TEST_TOP/common"
7
8 check_prereq btrfs-find-root
9 check_prereq btrfs-image
10
11 run_check $TOP/btrfs-image -r first_meta_chunk.btrfs-image test.img || \
12         _fail "failed to extract first_meta_chunk.btrfs-image"
13
14 result=$(run_check_stdout $TOP/btrfs-find-root test.img | sed '/^Superblock/d')
15
16 if [ -z "$result" ]; then
17         _fail "btrfs-find-root failed to find tree root"
18 fi
19
20 if ! echo "$result" | grep -q 'Found tree root at'; then
21         _fail "btrfs-find-root failed to find tree root, unexpected output"
22 fi
23
24 rm test.img