Skip to content

[tests] Fix startup logcat race in MonitorAdbLogcat - #12196

Merged
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-fix-device-readiness-flakes
Jul 21, 2026
Merged

[tests] Fix startup logcat race in MonitorAdbLogcat#12196
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-fix-device-readiness-flakes

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Pull Request

MonitorAdbLogcat() previously only tailed live adb logcat output. Several device tests start the app before monitoring begins, so startup lines could be emitted and missed before the tailer attached, causing intermittent failures like missing Displayed/startup markers.

This change makes MonitorAdbLogcat() first read buffered logcat output with adb logcat -d and run the same matcher over those lines, then continue tailing live output. That keeps behavior centralized in the shared helper and avoids per-test delay/retry changes.

  • Useful description of why the change is necessary.
  • Links to issues fixed
    • N/A
  • Unit tests
    • N/A (no new unit tests in final diff; change is exercised through existing device tests that use MonitorAdbLogcat).

Process buffered adb logcat output before starting live monitoring so early startup lines are not missed when tests begin monitoring after app launch. Add focused unit tests for buffered logcat matching behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ae324e4e-c922-4429-8222-3e37164d1e43
Drop the extra helper unit-test file and keep the success flag as bool, while retaining the buffered logcat pre-scan behavior change in MonitorAdbLogcat.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ae324e4e-c922-4429-8222-3e37164d1e43
Copilot AI review requested due to automatic review settings July 21, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes device-test logcat monitoring more reliable by having MonitorAdbLogcat() scan already-buffered logcat output before attaching to live adb logcat streaming, reducing flakiness when startup markers are emitted before monitoring begins.

Changes:

  • Read buffered logcat output via adb logcat -d and run the existing matcher against it before starting live monitoring.
  • Add TryMatchLogcatOutput() to centralize “scan + write-to-file + predicate match” behavior for buffered logcat output.

Limit both buffered and live predicate evaluation to the first successful match and make TryMatchLogcatOutput private to reduce API surface.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ae324e4e-c922-4429-8222-3e37164d1e43
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Jul 21, 2026
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) July 21, 2026 19:18
@jonathanpeppers
jonathanpeppers merged commit d326a79 into main Jul 21, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-fix-device-readiness-flakes branch July 21, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants