Skip to contentSkip to conversation

Restore support for running tests without prior test results

PATCH In review Bart Van Assche 3 participants 4 messages May 20, 2020 – Jun 15, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Restore support for running tests without prior test results

This patch fixes the following runtime error:

./check: line 245: LAST_TEST_RUN: unbound variable

Fixes 203b5723a28e ("Show last run for skipped tests")
---
 check | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
check +7 -1
index 0a4e539a5cd9..5151d01995ac 100755
@@ -240,9 +240,15 @@ _output_last_test_run() {
 }
 
 _output_test_run() {
+	local param_count
 	if [[ -t 1 ]]; then
 		# Move the cursor back up to the status.
-		tput cuu $((${#LAST_TEST_RUN[@]} + 1))
+		if [ -n "${LAST_TEST_RUN+set}" ]; then
+			param_count=${#LAST_TEST_RUN[@]}
+		else
+			param_count=0
+		fi
+		tput cuu $((param_count + 1))
 	fi
 
 	local status=${TEST_RUN["status"]}
#1 lore raw
Quoted 22 lines · Bart Van Assche

This patch fixes the following runtime error:

./check: line 245: LAST_TEST_RUN: unbound variable

Fixes 203b5723a28e ("Show last run for skipped tests")
---
 check | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
check +1 -0
index 0a4e539a5cd9..5151d01995ac 100755
@@ -240,9 +240,15 @@ _output_last_test_run() {
 }
 
 _output_test_run() {
+	local param_count
 	if [[ -t 1 ]]; then
 		# Move the cursor back up to the status.

check _output_last_test_run() { · line 254

Quoted 10 lines
check +6 -1
-		tput cuu $((${#LAST_TEST_RUN[@]} + 1))
+		if [ -n "${LAST_TEST_RUN+set}" ]; then
+			param_count=${#LAST_TEST_RUN[@]}
+		else
+			param_count=0
+		fi
+		tput cuu $((param_count + 1))
 	fi
 
 	local status=${TEST_RUN["status"]}

Omar, ping?

#3 lore raw
In reply to Bart Van Assche
Quoted 15 lines · Bart Van Assche

This patch fixes the following runtime error:

./check: line 245: LAST_TEST_RUN: unbound variable

Fixes 203b5723a28e ("Show last run for skipped tests")
---
  check | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
check +0 -0
index 0a4e539a5cd9..5151d01995ac 100755

check _output_last_test_run() { · line 243

Quoted 4 lines
check +1 -0
@@ -240,9 +240,15 @@ _output_last_test_run() {
  }
 
  _output_test_run() {
+	local param_count

Is there any particular reason why new line is not added after variable declaration ? (I see that check file is not strict about that, which it should be to start with).

check _output_last_test_run() { · line 254

Quoted 12 lines
check +5 -1
  	if [[ -t 1 ]]; then
  		# Move the cursor back up to the status.
-		tput cuu $((${#LAST_TEST_RUN[@]} + 1))
+		if [ -n "${LAST_TEST_RUN+set}" ]; then
+			param_count=${#LAST_TEST_RUN[@]}
+		else
+			param_count=0 > +		fi
+		tput cuu $((param_count + 1))
  	fi
 
  	local status=${TEST_RUN["status"]}

Overall patch looks good, I've tested it with nvme group which works fine.

#2 lore raw
In reply to Bart Van Assche
Quoted 31 lines · Bart Van Assche
Quoted 30 lines · Bart Van Assche

This patch fixes the following runtime error:

./check: line 245: LAST_TEST_RUN: unbound variable

Fixes 203b5723a28e ("Show last run for skipped tests")
---
 check | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
check +7 -1
index 0a4e539a5cd9..5151d01995ac 100755
@@ -240,9 +240,15 @@ _output_last_test_run() {
 }
 
 _output_test_run() {
+	local param_count
 	if [[ -t 1 ]]; then
 		# Move the cursor back up to the status.
-		tput cuu $((${#LAST_TEST_RUN[@]} + 1))
+		if [ -n "${LAST_TEST_RUN+set}" ]; then
+			param_count=${#LAST_TEST_RUN[@]}
+		else
+			param_count=0
+		fi
+		tput cuu $((param_count + 1))
 	fi
 
Quoted 4 lines

check _output_last_test_run() { · line 254

Quoted 2 lines
check +0 -0
 	local status=${TEST_RUN["status"]}

Omar, ping?

Sorry Bart, I had a family emergency so I've been away for a few weeks. This fix didn't work for me for the same reason that Li Zhijian reported in https://github.com/osandov/blktests/pull/64. For now I'm going to apply that fix instead. If you'd like blktests to work with set -u, please do so by adding it to the main check script and modifying the rest of the framework.