Skip to content

tests/functional: fix MCS-51 idle wakeup race - #37

Merged
zevorn merged 1 commit into
develfrom
codex/fix-mcs51-isa-timeout
Aug 25, 2026
Merged

zevorn merged 1 commit into
develfrom
codex/fix-mcs51-isa-timeout

Conversation

@zevorn

@zevorn zevorn commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Keep Timer 0 running until the MCS-51 idle test has actually returned from PCON.IDL.
  • Remove the previous 180-second timeout workaround and restore the functional-test default of 90 seconds.

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.IDL executes. 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-flake
  • CI-equivalent MCS-51 test selection: 4/4 passed (5 + 7 functional subtests, 29 + 29 qtest subtests)
  • Deterministic early-interrupt regression: 5/5 passed after timing out 5/5 before the fix
  • MCS-51 functional stress: 1000/1000 passed at 16 workers
  • python3 -m py_compile tests/functional/mcs51/test_isa.py
  • scripts/checkpatch.pl --no-strict origin/devel..HEAD (0 errors, 0 warnings)

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>
@zevorn
zevorn merged commit 7c6caae into devel Aug 25, 2026
95 of 96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant