Blame SOURCES/tests-fix-covscan-SHELLCHECK_WARNING-complaints.patch

6f63b5
From 815072b9163cae73671baae448f974cc8f8a84be Mon Sep 17 00:00:00 2001
6f63b5
From: Rafael Aquini <aquini@redhat.com>
6f63b5
Date: Sun, 12 Apr 2020 21:08:01 -0400
6f63b5
Subject: [PATCH] tests: fix covscan SHELLCHECK_WARNING complaints
6f63b5
6f63b5
Signed-off-by: Rafael Aquini <aquini@redhat.com>
6f63b5
---
6f63b5
 tests/counters.sh                      |  2 +-
6f63b5
 tests/fadvise_reserve.sh               |  2 +-
6f63b5
 tests/fallocate_align.sh               |  2 +-
6f63b5
 tests/fallocate_basic.sh               |  2 +-
6f63b5
 tests/fallocate_stress.sh              |  2 +-
6f63b5
 tests/madvise_reserve.sh               |  2 +-
6f63b5
 tests/mremap-expand-slice-collision.sh |  2 +-
6f63b5
 tests/mremap-fixed-huge-near-normal.sh |  2 +-
6f63b5
 tests/mremap-fixed-normal-near-huge.sh |  2 +-
6f63b5
 tests/quota.sh                         |  2 +-
6f63b5
 tests/readahead_reserve.sh             |  2 +-
6f63b5
 tests/wrapper-utils.sh                 | 18 +++++++++---------
6f63b5
 12 files changed, 20 insertions(+), 20 deletions(-)
6f63b5
6f63b5
diff --git a/tests/counters.sh b/tests/counters.sh
6f63b5
index e3ffabe..27bfca3 100755
6f63b5
--- a/tests/counters.sh
6f63b5
+++ b/tests/counters.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # Huge page overcommit was not available until 2.6.24
6f63b5
-compare_kvers `uname -r` "2.6.24"
6f63b5
+compare_kvers "$(uname -r)" "2.6.24"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	EXP_RC=$RC_FAIL
6f63b5
 else
6f63b5
diff --git a/tests/fadvise_reserve.sh b/tests/fadvise_reserve.sh
6f63b5
index 74496ec..ff96003 100755
6f63b5
--- a/tests/fadvise_reserve.sh
6f63b5
+++ b/tests/fadvise_reserve.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # fadvise is known broken before 2.6.30
6f63b5
-compare_kvers `uname -r` "2.6.30"
6f63b5
+compare_kvers "$(uname -r)" "2.6.30"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL (assumed) kernel bug"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/fallocate_align.sh b/tests/fallocate_align.sh
6f63b5
index 5105151..4397cd3 100755
6f63b5
--- a/tests/fallocate_align.sh
6f63b5
+++ b/tests/fallocate_align.sh
6f63b5
@@ -5,7 +5,7 @@
6f63b5
 #
6f63b5
 # hugetlbfs fallocate support was not available until 4.3
6f63b5
 #
6f63b5
-compare_kvers `uname -r` "4.3.0"
6f63b5
+compare_kvers "$(uname -r)" "4.3.0"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL no fallocate support in kernels before 4.3.0"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/fallocate_basic.sh b/tests/fallocate_basic.sh
6f63b5
index 904dfd6..1af6196 100755
6f63b5
--- a/tests/fallocate_basic.sh
6f63b5
+++ b/tests/fallocate_basic.sh
6f63b5
@@ -5,7 +5,7 @@
6f63b5
 #
6f63b5
 # hugetlbfs fallocate support was not available until 4.3
6f63b5
 #
6f63b5
-compare_kvers `uname -r` "4.3.0"
6f63b5
+compare_kvers "$(uname -r)" "4.3.0"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL no fallocate support in kernels before 4.3.0"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/fallocate_stress.sh b/tests/fallocate_stress.sh
6f63b5
index 622084f..3b5b70a 100755
6f63b5
--- a/tests/fallocate_stress.sh
6f63b5
+++ b/tests/fallocate_stress.sh
6f63b5
@@ -5,7 +5,7 @@
6f63b5
 #
6f63b5
 # hugetlbfs fallocate support was not available until 4.3
6f63b5
 #
6f63b5
-compare_kvers `uname -r` "4.3.0"
6f63b5
+compare_kvers "$(uname -r)" "4.3.0"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL no fallocate support in kernels before 4.3.0"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/madvise_reserve.sh b/tests/madvise_reserve.sh
6f63b5
index cfe582d..eb289d6 100755
6f63b5
--- a/tests/madvise_reserve.sh
6f63b5
+++ b/tests/madvise_reserve.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # madvise is known broken before 2.6.30
6f63b5
-compare_kvers `uname -r` "2.6.30"
6f63b5
+compare_kvers "$(uname -r)" "2.6.30"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL (assumed) kernel bug"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/mremap-expand-slice-collision.sh b/tests/mremap-expand-slice-collision.sh
6f63b5
index 8c9d98a..dd4eba3 100755
6f63b5
--- a/tests/mremap-expand-slice-collision.sh
6f63b5
+++ b/tests/mremap-expand-slice-collision.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # mremap-expand-slice-collision is known broken before 2.6.33
6f63b5
-compare_kvers `uname -r` "2.6.33"
6f63b5
+compare_kvers "$(uname -r)" "2.6.33"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL (assumed) kernel bug"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/mremap-fixed-huge-near-normal.sh b/tests/mremap-fixed-huge-near-normal.sh
6f63b5
index 4b89c35..22fde79 100755
6f63b5
--- a/tests/mremap-fixed-huge-near-normal.sh
6f63b5
+++ b/tests/mremap-fixed-huge-near-normal.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # mremap-fixed-huge-near-normal is known broken before 2.6.33
6f63b5
-compare_kvers `uname -r` "2.6.33"
6f63b5
+compare_kvers "$(uname -r)" "2.6.33"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL (assumed) kernel bug"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/mremap-fixed-normal-near-huge.sh b/tests/mremap-fixed-normal-near-huge.sh
6f63b5
index 9ed058f..45b8f26 100755
6f63b5
--- a/tests/mremap-fixed-normal-near-huge.sh
6f63b5
+++ b/tests/mremap-fixed-normal-near-huge.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # mremap-fixed-normal-near-huge is known broken before 2.6.33
6f63b5
-compare_kvers `uname -r` "2.6.33"
6f63b5
+compare_kvers "$(uname -r)" "2.6.33"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL (assumed) kernel bug"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/quota.sh b/tests/quota.sh
6f63b5
index 398d442..55c764a 100755
6f63b5
--- a/tests/quota.sh
6f63b5
+++ b/tests/quota.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # There are known bugs in quota accounting prior to 2.6.24
6f63b5
-compare_kvers `uname -r` "2.6.24"
6f63b5
+compare_kvers "$(uname -r)" "2.6.24"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	EXP_RC=$RC_FAIL
6f63b5
 else
6f63b5
diff --git a/tests/readahead_reserve.sh b/tests/readahead_reserve.sh
6f63b5
index 5ab7400..861ef5a 100755
6f63b5
--- a/tests/readahead_reserve.sh
6f63b5
+++ b/tests/readahead_reserve.sh
6f63b5
@@ -3,7 +3,7 @@
6f63b5
 . wrapper-utils.sh
6f63b5
 
6f63b5
 # readahead is known broken before 2.6.30
6f63b5
-compare_kvers `uname -r` "2.6.30"
6f63b5
+compare_kvers "$(uname -r)" "2.6.30"
6f63b5
 if [ $? -eq 1 ]; then
6f63b5
 	echo "FAIL (assumed) kernel bug"
6f63b5
 	exit $RC_FAIL
6f63b5
diff --git a/tests/wrapper-utils.sh b/tests/wrapper-utils.sh
6f63b5
index 2f6451d..79e7ed1 100644
6f63b5
--- a/tests/wrapper-utils.sh
6f63b5
+++ b/tests/wrapper-utils.sh
6f63b5
@@ -1,12 +1,12 @@
6f63b5
 #!/bin/bash
6f63b5
 
6f63b5
 # Standard return codes
6f63b5
-RC_PASS=0
6f63b5
-RC_CONFIG=1
6f63b5
-RC_FAIL=2
6f63b5
-RC_XFAIL=3
6f63b5
-RC_XPASS=4
6f63b5
-RC_BUG=99
6f63b5
+export RC_PASS=0
6f63b5
+export RC_CONFIG=1
6f63b5
+export RC_FAIL=2
6f63b5
+export RC_XFAIL=3
6f63b5
+export RC_XPASS=4
6f63b5
+export RC_BUG=99
6f63b5
 
6f63b5
 function unexpected_pass()
6f63b5
 {
6f63b5
@@ -28,10 +28,10 @@ function check_rc()
6f63b5
 	EXP_RC=$1
6f63b5
 	ACT_RC=$2
6f63b5
 
6f63b5
-	if [ $ACT_RC -eq $RC_PASS -a $EXP_RC -ne $RC_PASS ]; then
6f63b5
+	if [[ ($ACT_RC -eq $RC_PASS) && ($EXP_RC -ne $RC_PASS) ]]; then
6f63b5
 		unexpected_pass
6f63b5
 		return $RC_XPASS
6f63b5
-	elif [ $EXP_RC -ne $RC_PASS -a $EXP_RC -eq $ACT_RC ]; then
6f63b5
+	elif [[ ($EXP_RC -ne $RC_PASS) && ($EXP_RC -eq $ACT_RC) ]]; then
6f63b5
 		expected_fail
6f63b5
 		return $RC_XFAIL
6f63b5
 	else
6f63b5
@@ -47,7 +47,7 @@ function exec_and_check()
6f63b5
 	EXP_RC=$1
6f63b5
 	shift
6f63b5
 
6f63b5
-	OUTPUT=`$@`
6f63b5
+	OUTPUT=$("$@")
6f63b5
 	check_rc $EXP_RC $?
6f63b5
 	RC=$?
6f63b5
 	echo $OUTPUT
6f63b5
-- 
6f63b5
2.25.2
6f63b5