[tests] Fix startup logcat race in MonitorAdbLogcat - #12196
Merged
jonathanpeppers merged 3 commits intoJul 21, 2026
Conversation
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
Contributor
There was a problem hiding this comment.
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 -dand 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
enabled auto-merge (squash)
July 21, 2026 19:18
dalexsoto
approved these changes
Jul 21, 2026
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.
Pull Request
MonitorAdbLogcat()previously only tailed liveadb logcatoutput. 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 missingDisplayed/startup markers.This change makes
MonitorAdbLogcat()first read buffered logcat output withadb logcat -dand 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.MonitorAdbLogcat).