Skip to content

omamobile-mmd: the bridge tests wait for the signals they read - #638

Merged
derekross merged 1 commit into
derekross:mainfrom
W4HO-ham:mmd-test-signal-waits
Nov 11, 2026
Merged

derekross merged 1 commit into
derekross:mainfrom
W4HO-ham:mmd-test-signal-waits

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

From #461: built on a Pixel 7 Pro, omamobile-mmd's test/all failed in check(), not the same way twice (a list of modem interfaces, then an IndexError in test_enable_goes_to_sitd_radio).

Cause. Three tests in test_bridge.py wait for a property and then read the client's recorded signals at once. The client's signals are handed over by the main loop, and a synchronous property read can return the new value before the loop has dispatched the signals sent with it. On a fast machine the 20 ms spin inside wait_until hides that; on a slow one the list is short or empty:

Test What it read too early How it failed
test_sim_appears_later the four InterfacesAdded, then StateChanged one list of four
test_enable_goes_to_sitd_radio the last StateChanged IndexError
test_sitd_going_away_and_coming_back the last InterfacesRemoved IndexError

Reproduced on an x86 laptop by pinning the tests to one core with four busy loops on it (taskset -c 0 nice -n 10 python3 -m unittest test_bridge): the five runs that finished before I stopped it all failed, each in one or two of these three tests and nowhere else.

Change. One helper, signals(name, wanted, message), waits (5 s, as the other waits) until the recorded signals of that name satisfy the test's condition, and the three reads go through it. The assertions are unchanged. Nothing outside test/test_bridge.py is touched, so no version change.

Tested. On the same loaded core, ten runs of test_bridge in a row pass (about 109 s each, against 8 s unloaded). packages/omamobile-mmd/test/all and tools/pr-check pass. Not run on a phone.

The other signal reads in the file sit behind a fixed spin(.1) or spin(.2) after a call that has already returned; none of them failed in the loaded runs, so I left them alone.

Three tests waited for a property and then read the client's recorded signals at once. A property read can show a change before the main loop has handed the client the signals sent with it, so on a slow machine the list was short or empty: test_sim_appears_later saw one InterfacesAdded of four, test_enable_goes_to_sitd_radio and test_sitd_going_away_and_coming_back raised IndexError. Seen when the package was built on a Pixel 7 Pro (derekross#461), and on a laptop with the tests pinned to one loaded core, where every run failed in one of the three.

Each of the three now waits for the signal it checks, through one helper. On the loaded core ten runs of test_bridge in a row pass. Tests only, no version change.
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham, that was quick, and the cause is the right one: the
client records a signal only when the main loop runs, a property read
doesn't run it, and wait_until spins before the read, not after. So a
change that lands during the read is visible in the property while its
signals are still queued.

I checked that this covers both failures I had on the 7 Pro. Plain load on
my laptop wasn't enough to make main fail (it's faster than yours), so I
forced the order of events from outside the tree: the fake sitd's push()
30 ms late and the client stalled 80 ms before each property read. On main
that gives exactly my two, and nothing else:

ERROR test_enable_goes_to_sitd_radio   IndexError: list index out of range
FAIL  test_sim_appears_later           Lists differ: one list of interfaces against four

On this head all 23 pass, and main with #461 and this on top passes all 37,
under the same stall and pinned to a loaded core. The assertions are
untouched, a missing signal now fails with its name after 5 s, and nothing
outside test/ changes, so no version change is right. It merges cleanly
with #461 in either order.

Two small things for whenever you're next in that file, neither needed
here: the remaining reads behind a fixed spin(.1) or spin(.2) hold
because the bridge sends those signals before it answers the call the test
just made, but they could go through the same helper; and the lambda in
signals() calls named() twice where a local would do.

Merging this as it is.

@derekross
derekross merged commit d9b7834 into derekross:main Nov 11, 2026
2 checks passed
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…ross#638)

Three tests in test_bridge.py waited for a property and then read the client's recorded signals at once. A property read can return before the main loop has delivered the signals sent with it, so on a slow machine (seen building the package on a Pixel 7 Pro, derekross#461) test_sim_appears_later saw one InterfacesAdded of four and test_enable_goes_to_sitd_radio raised IndexError. Each now waits for the signal it checks, through one helper. Tests only, no version change.
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.

2 participants