diff mbox series

[3/3] progs: tests: misc: btrfs-{find-root,select-super} are internal commands

Message ID 20200301033344.808-4-marcos@mpdesouza.com (mailing list archive)
State New, archived
Headers show
Series progs: fix testsuite | expand

Commit Message

Marcos Paulo de Souza March 1, 2020, 3:33 a.m. UTC
From: Marcos Paulo de Souza <mpdesouza@suse.com>

With this commit, testsuite works as expected.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 tests/common                                        | 13 +++++++++----
 tests/misc-tests/012-find-root-no-result/test.sh    |  2 +-
 .../020-fix-superblock-corruption/test.sh           |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

Comments

Qu Wenruo March 2, 2020, 12:03 a.m. UTC | #1
On 2020/3/1 上午11:33, Marcos Paulo de Souza wrote:
> From: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> With this commit, testsuite works as expected.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  tests/common                                        | 13 +++++++++----
>  tests/misc-tests/012-find-root-no-result/test.sh    |  2 +-
>  .../020-fix-superblock-corruption/test.sh           |  2 +-
>  3 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/common b/tests/common
> index 605cf72c..26190d85 100644
> --- a/tests/common
> +++ b/tests/common
> @@ -305,13 +305,18 @@ run_mustfail_stdout()
>  
>  check_prereq()
>  {
> -	if [ "$1" = "btrfs-corrupt-block" -o "$1" = "fssum" ]; then
> +	case "$1" in
> +	btrfs-corrupt-block|btrfs-find-root|btrfs-select-super|fssum)
>  		if ! [ -f "$INTERNAL_BIN/$1" ]; then
>  			_fail "Failed prerequisites: $INTERNAL_BIN/$1";
>  		fi
> -	elif ! [ -f "$TOP/$1" ]; then
> -		_fail "Failed prerequisites: $TOP/$1";
> -	fi
> +		;;
> +	*)
> +		if ! [ -f "$TOP/$1" ]; then
> +			_fail "Failed prerequisites: $TOP/$1";
> +		fi
> +		;;
> +	esac
>  }
>  
>  check_global_prereq()
> diff --git a/tests/misc-tests/012-find-root-no-result/test.sh b/tests/misc-tests/012-find-root-no-result/test.sh
> index 6dd447f3..edfdfd38 100755
> --- a/tests/misc-tests/012-find-root-no-result/test.sh
> +++ b/tests/misc-tests/012-find-root-no-result/test.sh
> @@ -11,7 +11,7 @@ check_prereq btrfs-image
>  run_check "$TOP/btrfs-image" -r first_meta_chunk.btrfs-image test.img || \
>  	_fail "failed to extract first_meta_chunk.btrfs-image"
>  
> -result=$(run_check_stdout "$TOP/btrfs-find-root" test.img | sed '/^Superblock/d')
> +result=$(run_check_stdout "$INTERNAL_BIN/btrfs-find-root" test.img | sed '/^Superblock/d')
>  
>  if [ -z "$result" ]; then
>  	_fail "btrfs-find-root failed to find tree root"
> diff --git a/tests/misc-tests/020-fix-superblock-corruption/test.sh b/tests/misc-tests/020-fix-superblock-corruption/test.sh
> index 404d416b..d67a87c3 100755
> --- a/tests/misc-tests/020-fix-superblock-corruption/test.sh
> +++ b/tests/misc-tests/020-fix-superblock-corruption/test.sh
> @@ -25,7 +25,7 @@ test_superblock_restore()
>  		_fail "btrfs check should detect corruption"
>  
>  	# Copy backup superblock to primary
> -	run_check "$TOP/btrfs-select-super" -s 1 "$TEST_DEV"
> +	run_check "$INTERNAL_BIN/btrfs-select-super" -s 1 "$TEST_DEV"
>  
>  	# Perform btrfs check
>  	run_check "$TOP/btrfs" check "$TEST_DEV"
>
diff mbox series

Patch

diff --git a/tests/common b/tests/common
index 605cf72c..26190d85 100644
--- a/tests/common
+++ b/tests/common
@@ -305,13 +305,18 @@  run_mustfail_stdout()
 
 check_prereq()
 {
-	if [ "$1" = "btrfs-corrupt-block" -o "$1" = "fssum" ]; then
+	case "$1" in
+	btrfs-corrupt-block|btrfs-find-root|btrfs-select-super|fssum)
 		if ! [ -f "$INTERNAL_BIN/$1" ]; then
 			_fail "Failed prerequisites: $INTERNAL_BIN/$1";
 		fi
-	elif ! [ -f "$TOP/$1" ]; then
-		_fail "Failed prerequisites: $TOP/$1";
-	fi
+		;;
+	*)
+		if ! [ -f "$TOP/$1" ]; then
+			_fail "Failed prerequisites: $TOP/$1";
+		fi
+		;;
+	esac
 }
 
 check_global_prereq()
diff --git a/tests/misc-tests/012-find-root-no-result/test.sh b/tests/misc-tests/012-find-root-no-result/test.sh
index 6dd447f3..edfdfd38 100755
--- a/tests/misc-tests/012-find-root-no-result/test.sh
+++ b/tests/misc-tests/012-find-root-no-result/test.sh
@@ -11,7 +11,7 @@  check_prereq btrfs-image
 run_check "$TOP/btrfs-image" -r first_meta_chunk.btrfs-image test.img || \
 	_fail "failed to extract first_meta_chunk.btrfs-image"
 
-result=$(run_check_stdout "$TOP/btrfs-find-root" test.img | sed '/^Superblock/d')
+result=$(run_check_stdout "$INTERNAL_BIN/btrfs-find-root" test.img | sed '/^Superblock/d')
 
 if [ -z "$result" ]; then
 	_fail "btrfs-find-root failed to find tree root"
diff --git a/tests/misc-tests/020-fix-superblock-corruption/test.sh b/tests/misc-tests/020-fix-superblock-corruption/test.sh
index 404d416b..d67a87c3 100755
--- a/tests/misc-tests/020-fix-superblock-corruption/test.sh
+++ b/tests/misc-tests/020-fix-superblock-corruption/test.sh
@@ -25,7 +25,7 @@  test_superblock_restore()
 		_fail "btrfs check should detect corruption"
 
 	# Copy backup superblock to primary
-	run_check "$TOP/btrfs-select-super" -s 1 "$TEST_DEV"
+	run_check "$INTERNAL_BIN/btrfs-select-super" -s 1 "$TEST_DEV"
 
 	# Perform btrfs check
 	run_check "$TOP/btrfs" check "$TEST_DEV"