Re: [PATCH blktests RFC 1/2] check: allow strict error-checking by "set -e" in each test case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/30/25 12:54 AM, Shin'ichiro Kawasaki wrote:
diff --git a/check b/check
index dad5e70..3cf741a 100755
--- a/check
+++ b/check
@@ -502,9 +502,9 @@ _check_and_call_test_device() {
  			fi
  		fi
  		RESULTS_DIR="$OUTPUT/$(basename "$TEST_DEV")""$postfix"
-		if ! _call_test test_device; then
-			ret=1
-		fi
+		_call_test test_device
+		# shellcheck disable=SC2181
+		(($? != 0)) && ret=1

These alternatives may be easier to read than the above:

if _call_test test_device; then :; else ret=1; fi

if ! { _call_test test_device; }; then ret=1; fi

Additionally, please add a comment that explains that ! should not be
used directly because it causes set -e to be ignored in the called
function.

@@ -695,9 +695,9 @@ _check() {
  		if [[ $group != "$prev_group" ]]; then
  			prev_group="$group"
  			if [[ ${#tests[@]} -gt 0 ]]; then
-				if ! ( _run_group "${tests[@]}" ); then
-					ret=1
-				fi
+				( _run_group "${tests[@]}" )
+				# shellcheck disable=SC2181
+				(($? != 0)) && ret=1

Is the above change necessary? This command shows that the exclamation
mark does not affect subshells:

$ bash -c '!(set -e; false; echo set -e has been ignored)'
$

Thanks,

Bart.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux