[PATCH 05/11] tests: fix intermittent starvation_gen readiness failure

Wander Lairson Costa <[email protected]> Fri, 10 Jul 2026 10:38:04 -0300
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
The process_alive check in the start_starvation_gen polling loop
uses kill -0, which can occasionally fail even when the process
is running. When this happens before the readiness grep has a
chance to run, the test aborts with a spurious "exited
prematurely" error.

Reorder the loop to check the log file for the ready message
before checking process liveness, so a transient kill -0 failure
does not prevent detection of a process that is already running.
Increase the initial sleep from 0.01s to 0.5s to give
starvation_gen time to start up before the first poll.

Signed-off-by: Wander Lairson Costa <[email protected]>
---
 tests/helpers/test_helpers.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/helpers/test_helpers.sh b/tests/helpers/test_helpers.sh
index 1e3d736..20937a3 100755
--- a/tests/helpers/test_helpers.sh
+++ b/tests/helpers/test_helpers.sh
@@ -1267,21 +1267,21 @@ start_starvation_gen() {
 	# starvation_gen prints "ready" after all threads pass the barrier.
 	# Brief initial sleep covers the fast path, then 1-second polling
 	# for slow/loaded systems.
-	sleep 0.01
+	sleep 0.5
 
 	local timeout=10
 	local elapsed=0
 	while [ $elapsed -lt $timeout ]; do
-		if ! process_alive ${STARVE_PID}; then
-			echo "  Log contents:"
-			cat "${STARVE_LOG}"
-			fail "starvation_gen exited prematurely"
-		fi
 		if grep -q "Press Ctrl+C to stop early" "${STARVE_LOG}" 2>/dev/null; then
 			echo "starvation_gen ready (PID ${STARVE_PID})"
 			return 0
 		fi
 		sleep 1
+		if ! process_alive ${STARVE_PID}; then
+			echo "  Log contents:"
+			cat "${STARVE_LOG}"
+			fail "starvation_gen exited prematurely"
+		fi
 		elapsed=$((elapsed + 1))
 	done
 
-- 
2.55.0