hil: harness follow-ups from #4594 (park refusal race, interrupted notice, runner stop)

Open
#4,601 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
22/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
github-actions, python
Domain
testing

Research direction

Start in test/hil/hil_test.py at _should_park/_park_refusal and their callers _sysview_capture/_board_battery, then _abort_report/_already_aborted in helper/hil_report.py, _BoardProcess.ended/_stop_boards, _died_row, and _retain in helper/farm_profile.py; line numbers are offset by a few dozen. Reproduce each with the in-process stubs the report describes before editing, and note item 5 asks for an interrupt-policy decision rather than a patch. Done means one refusal string drives both decision and message, termination is matched from the recorded signal, lingering-but-finished rows survive, and test_hil_flash.OpenocdEsp stops leaving /tmp/tinyusb-hil-locks fixtures behind.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

These come from the audit record refresh for #4542, which reviewed #4594 (490eb4ec9..17301f1a6). Claude and Codex each checked the other's findings, and each item below was reproduced in-process with stubs. Nothing was run on a rig. The audit's own harness commits do not touch any of these paths. Line numbers are at 17301f1a6 plus the audit commits, so they are a few dozen lines off in hil_test.py.

Defects

  1. SystemView capture can skip the park checks (test/hil/hil_test.py _should_park / _park_refusal, used in _sysview_capture and _board_battery):
    • The two functions re-read the openocd_esp pending record separately.
    • pending_refusal() clears entries that have ended. So when an older run's record clears between the two calls, the reason comes back empty. The park then reports not parked: with no cause.
    • In _sysview_capture, that empty reason falls past the elif/else that holds the park-image and remaining-time checks, so the capture runs without them.
    • Fix: compute one refusal string ('' means park) and use it for both the decision and the message.
  2. An interrupted run's notice gets overwritten (hil_test.py _abort_report with helper/hil_report.py _already_aborted):
    • The banner reads **HIL run interrupted by SIGTERM.**, but _already_aborted() matches only the **HIL run ab prefix.
    • So an accumulating no-boards re-run replaces both the caveat and the termination with no-boards.
    • Fix: match on the recorded termination instead of the caveat text.
  3. A finished row is lost when its process outlives the stop grace (hil_test.py _BoardProcess.ended / _stop_boards):
    • b.result is filled at pipe EOF, but a board only counts as ended once its sentinel fires.
    • A board that has written its row and then lingers (an atexit handler or a non-daemon thread) goes to _left_running. Its row is dropped and _abort_report lists it as never reported.
    • Fix: keep the row, and also report that the process survived.
  4. A real-time signal aborts the whole run (hil_test.py _died_row): signal.Signals(-exitcode) raises ValueError for SIGRTMIN+n, which escapes run_boards. Fix: fall back to signal {n}.
  5. A second SIGINT can skip stopping the boards (hil_test.py run_boards finally):
    • The window is short: before _stop_boards()'s _interrupts_ignored() takes effect.
    • In that window, a second SIGINT escapes without stopping the boards or registering survivors.
    • Moving the context manager alone does not close every entry window, so the parent's interrupt policy needs a decision.
  6. An agentrc identity error can hide the reset's own failure (helper/farm_profile.py _retain):
    • _retain runs in reset's finally, and its _engine() reload can raise when agentrc's source identity changes mid-reset.
    • That error replaces the reset's own exception and loses its .operation.
    • Fix: keep both failures, without suppressing the identity error.
  7. Minor:
    • _frame_result turns an unpickle failure into a generic "died (exit code 0)" row; put the decode error in the cell.
    • .github/workflows/pr_comment.yml:311-315 still says the code-size comment reports a failed agentrc fetch, but a missing agentrc now fails the freshness check and posts nothing, which is intended. Drop the stale comment and the redundant continue-on-error.

Cleanups

  • An explicit agentrc engine API for unresolved evidence (ctx.retain_unproven or similar), so farm_profile._retain stops appending rows to the engine-private ctx.ledger. This needs an agentrc change.
  • .claude/skills/hil-contract/SKILL.md:215: keep tinyusb's obligations (which entry points refuse, when to stop the board, what the cell shows) and link agentrc's hil Flashers and Recovery sections for the pending record's mechanics.

Test isolation (pre-existing)

test_hil_flash.OpenocdEsp writes a fake pending record (usj-30_ED_A0_E0_C9_02.openocd-esp-pending.json, token t0k) into the real /tmp/tinyusb-hil-locks, so the next hil-test run fails two OpenocdEsp tests. This was observed on master 490eb4ec9: a clean run leaves the file behind, and the next run fails.

Dominant language
C
Stars
7.3k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
67

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.