[PATCH 06/11] tests: add --fail-fast flag to stop on first failure

Wander Lairson Costa <[email protected]> Fri, 10 Jul 2026 10:38:05 -0300
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
Add a --fail-fast option to run_tests.sh that prints the test
summary and exits immediately when a test fails.  The exit
triggers the cleanup trap, so RT throttling and DL-server state
are still restored.

Use print_summary || true before exit 1 to prevent set -e from
intercepting the non-zero return of print_summary's final
[ ${FAILED_TESTS} -eq 0 ] check.

Signed-off-by: Wander Lairson Costa <[email protected]>
---
 tests/run_tests.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 6bfae0f..a2d50e0 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -19,6 +19,7 @@ THREADING_MODE_MATRIX=0  # Threading mode matrix testing disabled by default (en
 THREADING_MODES=("power" "adaptive" "aggressive")  # Threading modes to test
 THREADING_MODE=""  # Specific threading mode to use (empty = default)
 VERBOSE=0  # Run tests with bash -vx for trace output
+FAIL_FAST=0  # Stop on first test failure
 
 # Source test helpers for RT throttling and DL-server management
 source "${TEST_ROOT}/helpers/test_helpers.sh" 2>/dev/null || true
@@ -520,6 +521,10 @@ run_shell_test() {
 			if [ -n "${mode}" ]; then
 				MODE_FAILED["${mode}"]=$((MODE_FAILED["${mode}"] + 1))
 			fi
+			if [ ${FAIL_FAST} -eq 1 ]; then
+				print_summary || true
+				exit 1
+			fi
 		fi
 	fi
 }
@@ -609,6 +614,10 @@ while [[ $# -gt 0 ]]; do
 			VERBOSE=1
 			shift
 			;;
+		--fail-fast)
+			FAIL_FAST=1
+			shift
+			;;
 		--disable-dl-server)
 			DISABLE_DL_SERVER=1
 			shift
@@ -673,6 +682,7 @@ while [[ $# -gt 0 ]]; do
 			echo ""
 			echo "Other Options:"
 			echo "  --verbose            Run tests with bash -vx for trace output"
+			echo "  --fail-fast          Stop on first test failure"
 			echo "  --disable-dl-server  Disable DL-server before running tests"
 			echo "  -h, --help           Show this help"
 			echo ""
-- 
2.55.0