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

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