Skip to content

tests: Replace timing-dependent synchronization with event-driven helpers

Wander Lairson Costa linux-rt-users 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest36 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/36tests: Add pre-test and post-test cleanup of stalld processestests/helpers/test_helpers.sh tests/run_tests.sh+76 -10 replies
2/36tests/helpers: Fix stalld daemon detection in start_stalld()tests/helpers/test_helpers.sh+13 -320 replies
3/36tests/helpers: Remove duplicate log() functiontests/helpers/test_helpers.sh+0 -50 replies
4/36tests: Add per-test runtime measurement to run_tests.shtests/run_tests.sh+14 -50 replies
5/36tests/functional: Fix and refactor test_backend_selection.shtests/functional/test_backend_selection.sh+61 -1320 replies
6/36tests/functional: Fix test_logging_destinations.sh path and backendtests/functional/test_logging_destinations.sh+11 -110 replies
7/36tests/helpers: Replace sleep with poll in start_stalld_with_log()tests/helpers/test_helpers.sh+28 -20 replies
8/36tests/helpers: Fix stop_stalld() timeout and shutdown logictests/helpers/test_helpers.sh+19 -100 replies
9/36tests/helpers: Fix relative path in backend detection functionstests/helpers/test_helpers.sh+2 -20 replies
10/36tests/functional: Remove redundant post-stop_stalld sleepstests/functional/test_affinity.sh tests/functional/test_boost_duration.sh tests/functional/test_boost_runtime.sh +4 more+0 -300 replies
11/36tests/functional: Fix false positive log matching in test_logging_destinationstests/functional/test_logging_destinations.sh+10 -40 replies
12/36tests/helpers: Rewrite wait_for_log_message() with process substitutiontests/helpers/test_helpers.sh+18 -230 replies
13/36tests/helpers: Add wait_for_stalld_ready() and use in start_stalld_with_log()tests/helpers/test_helpers.sh+16 -290 replies
14/36tests/helpers: Fix fractional sleep timeout bugstests/helpers/test_helpers.sh+12 -100 replies
15/36tests/helpers: Flush stdout after starvation_gen startup messagestests/helpers/starvation_gen.c+1 -00 replies
16/36tests/helpers: Add start_starvation_gen() helper functiontests/helpers/test_helpers.sh+57 -10 replies
17/36tests/helpers: Add wait_for_starvation_detected() and wait_for_boost_detected()tests/helpers/test_helpers.sh+19 -10 replies
18/36tests/functional: Use start_starvation_gen() helpertests/functional/test_boost_duration.sh tests/functional/test_boost_period.sh tests/functional/test_boost_restoration.sh +11 more+70 -2420 replies
19/36tests/functional: Replace detection sleeps with event-driven helperstests/functional/test_boost_duration.sh tests/functional/test_boost_period.sh tests/functional/test_boost_restoration.sh +11 more+176 -2930 replies
20/36tests/functional: Remove duplicated -a flag in test_fifo_priority_starvationtests/functional/test_fifo_priority_starvation.sh+1 -10 replies
21/36tests/functional: Add missing -a flag in test_starvation_detectiontests/functional/test_starvation_detection.sh+1 -10 replies
22/36tests/functional: Use start_stalld_with_log() in test_log_onlytests/functional/test_log_only.sh+1 -220 replies
23/36tests/functional: Use start_stalld_with_log() in test_logging_destinationstests/functional/test_logging_destinations.sh+2 -150 replies
24/36tests/functional: Use start_stalld_with_log() in test_cpu_selectiontests/functional/test_cpu_selection.sh+11 -440 replies
25/36tests/functional: Use wait_for_stalld_ready() in test_backend_selectiontests/functional/test_backend_selection.sh+3 -30 replies
26/36tests/functional: Use timeout for error path in test_force_fifotests/functional/test_force_fifo.sh+7 -150 replies
27/36tests/functional: Use timeout for invalid argument teststests/functional/test_affinity.sh tests/functional/test_boost_duration.sh tests/functional/test_boost_period.sh +4 more+77 -1550 replies
28/36tests: Add pass() helper and replace assert_equals hacktests/functional/test_affinity.sh tests/functional/test_backend_selection.sh tests/functional/test_boost_duration.sh +11 more+43 -340 replies
29/36tests/functional: Use pass() for all test pass reportingtests/functional/test_affinity.sh tests/functional/test_boost_duration.sh tests/functional/test_boost_period.sh +12 more+118 -1180 replies
30/36tests: Add fail() helper and use for all test failurestests/functional/test_affinity.sh tests/functional/test_backend_selection.sh tests/functional/test_boost_duration.sh +18 more+97 -1750 replies
31/36tests/helpers: Use pass()/fail() in assert functionstests/helpers/test_helpers.sh+18 -320 replies
32/36tests/functional: Fix multi-CPU detection in test_starvation_detectiontests/functional/test_starvation_detection.sh tests/helpers/test_helpers.sh+12 -90 replies
33/36tests/functional: Accept FIFO fallback in test_fifo_boostingtests/functional/test_fifo_boosting.sh+4 -130 replies
34/36tests/functional: Fix readiness detection and FIFO fallback in test_force_fifotests/functional/test_force_fifo.sh tests/helpers/test_helpers.sh+4 -20 replies
35/36tests/functional: Fix invalid pidfile test in test_pidfiletests/functional/test_pidfile.sh+2 -60 replies
36/36stalld: die on invalid CPU affinitysrc/stalld.c+2 -40 replies

Reviews trailers per patch

None of the 36 patches has a Reviewed-by or Acked-by.

PatchClaude
1/36Co-Authored-By
2/36
3/36
4/36
5/36
6/36
7/36
8/36
9/36
10/36
11/36
12/36
13/36
14/36
15/36
16/36
17/36
18/36
19/36
20/36
21/36
22/36
23/36
24/36
25/36
26/36
27/36
28/36
29/36
30/36
31/36
32/36
33/36
34/36
35/36
36/36

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH stalld 00/36] tests: Replace timing-dependent synchronization with event-driven helpers

The stalld test suite relies heavily on hardcoded sleep calls for
synchronization: waiting for stalld to initialize, for starvation to be detected, and for boosting to occur. These fixed delays make the tests both slow (sleeping the full duration even when the event happens instantly) and unreliable (too short on slow systems, too long on fast ones).

This series replaces approximately 120 sleep calls across 20 test files with event-driven helpers that return as soon as the expected event occurs. The core mechanism is wait_for_log_message(), which uses process substitution with tail -f to detect log patterns instantly rather than polling. On top of this, domain-specific helpers like wait_for_starvation_detected(), wait_for_boost_detected(), start_starvation_gen(), and start_stalld_with_log() encapsulate common synchronization patterns into reusable functions with proper readiness detection and cleanup.

The series also introduces pass() and fail() helpers to standardize test result reporting, replaces duplicated stalld invocation boilerplate with shared helpers, and fixes several pre-existing test bugs exposed by the tighter synchronization: invalid argument tests that never actually failed, a multi-CPU detection grep that was too restrictive, and FIFO fallback behavior that was incorrectly treated as an error. A stalld source fix is included to die on invalid CPU affinity, which was silently ignored.

Clark Williams (1):
tests: Add pre-test and post-test cleanup of stalld processes

Wander Lairson Costa (35):
tests/helpers: Fix stalld daemon detection in start_stalld() tests/helpers: Remove duplicate log() function
tests: Add per-test runtime measurement to run_tests.sh tests/functional: Fix and refactor test_backend_selection.sh tests/functional: Fix test_logging_destinations.sh path and backend tests/helpers: Replace sleep with poll in start_stalld_with_log() tests/helpers: Fix stop_stalld() timeout and shutdown logic tests/helpers: Fix relative path in backend detection functions tests/functional: Remove redundant post-stop_stalld sleeps tests/functional: Fix false positive log matching in
test_logging_destinations
tests/helpers: Rewrite wait_for_log_message() with process
substitution
tests/helpers: Add wait_for_stalld_ready() and use in
start_stalld_with_log()
tests/helpers: Fix fractional sleep timeout bugs tests/helpers: Flush stdout after starvation_gen startup messages tests/helpers: Add start_starvation_gen() helper function tests/helpers: Add wait_for_starvation_detected() and
wait_for_boost_detected()
tests/functional: Use start_starvation_gen() helper tests/functional: Replace detection sleeps with event-driven helpers tests/functional: Remove duplicated -a flag in
test_fifo_priority_starvation
tests/functional: Add missing -a flag in test_starvation_detection tests/functional: Use start_stalld_with_log() in test_log_only tests/functional: Use start_stalld_with_log() in
test_logging_destinations
tests/functional: Use start_stalld_with_log() in test_cpu_selection tests/functional: Use wait_for_stalld_ready() in
test_backend_selection
tests/functional: Use timeout for error path in test_force_fifo tests/functional: Use timeout for invalid argument tests
tests: Add pass() helper and replace assert_equals hack tests/functional: Use pass() for all test pass reporting
tests: Add fail() helper and use for all test failures tests/helpers: Use pass()/fail() in assert functions tests/functional: Fix multi-CPU detection in test_starvation_detection tests/functional: Accept FIFO fallback in test_fifo_boosting tests/functional: Fix readiness detection and FIFO fallback in
test_force_fifo
tests/functional: Fix invalid pidfile test in test_pidfile
stalld: die on invalid CPU affinity

 src/stalld.c                                  |   6 +-
 tests/functional/test_affinity.sh             |  43 +--
 tests/functional/test_backend_selection.sh    | 193 +++-------
 tests/functional/test_boost_duration.sh       | 118 ++----
 tests/functional/test_boost_period.sh         | 116 ++----
 tests/functional/test_boost_restoration.sh    |  79 ++--
 tests/functional/test_boost_runtime.sh        | 132 ++-----
 tests/functional/test_cpu_selection.sh        |  79 +---
 tests/functional/test_deadline_boosting.sh    | 116 +++---
 tests/functional/test_fifo_boosting.sh        | 133 +++----
 .../test_fifo_priority_starvation.sh          | 106 ++----
 tests/functional/test_force_fifo.sh           | 101 ++---
 tests/functional/test_foreground.sh           |  18 +-
 tests/functional/test_idle_detection.sh       |  40 +-
 tests/functional/test_log_only.sh             |  46 +--
 tests/functional/test_logging_destinations.sh |  51 ++-
 tests/functional/test_pidfile.sh              |  75 ++--
 tests/functional/test_runqueue_parsing.sh     | 118 +++---
 tests/functional/test_starvation_detection.sh | 136 +++----
 tests/functional/test_starvation_threshold.sh |  98 ++---
 tests/functional/test_task_merging.sh         |  69 ++--
 tests/helpers/starvation_gen.c                |   1 +
 tests/helpers/test_helpers.sh                 | 351 ++++++++++++------
 tests/run_tests.sh                            |  61 ++-
 24 files changed, 905 insertions(+), 1381 deletions(-)
Signature · 1 line
2.53.0