tests/functional: fix MCS-51 idle wakeup race - #37
Merged
Merged
Conversation
The MCS-51 ISA functional test starts Timer 0 immediately before entering idle. If the host is descheduled long enough, the timer can expire and its handler can stop it before PCON.IDL executes. The firmware then enters idle with no remaining wake source and Meson eventually times out. Keep Timer 0 running in the handler and stop it only after IDL returns. Remove the 180-second timeout workaround because the failures were hangs rather than slow test runs. Signed-off-by: Chao Liu <chao.liu@processmission.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PCON.IDL.Root cause
The reported CI job did not run slowly; it hung. The idle firmware starts Timer 0 immediately before entering idle. If the runner is descheduled long enough, Timer 0 can overflow first, and the interrupt handler stops it before
PCON.IDLexecutes. The firmware then enters idle with no remaining wake source, so the console wait lasts until Meson kills the test.A deterministic icount fault injection forced Timer 0 to expire before the idle instruction. Before this change it timed out in 5/5 runs. The trace showed the interrupt being taken and returned before
PCON.IDL, with no active timer left. Keeping Timer 0 active in the handler let a later overflow wake the CPU; the same fault injection then passed in 5/5 runs.Validation
ninja -C builds/build-mcs51-ci-flakepython3 -m py_compile tests/functional/mcs51/test_isa.pyscripts/checkpatch.pl --no-strict origin/devel..HEAD(0 errors, 0 warnings)