Process: add wait_line and fix delta_only buffer offset - #4654
Open
mcgov (mcgov) wants to merge 3 commits into
Open
Process: add wait_line and fix delta_only buffer offset#4654mcgov (mcgov) wants to merge 3 commits into
mcgov (mcgov) wants to merge 3 commits into
Conversation
Add Process.wait_line, which consumes captured output line by line and hands each complete line to a caller supplied predicate. This allows matching on structured content (for example all key=value pairs of a uevent line) instead of the single substring search wait_output does. Also fix wait_output's delta_only bookkeeping: the offset was advanced to the end of the buffer on a match, so output that arrived after the matched keyword was skipped by the next call. Advance it to the end of the matched keyword instead, and on timeout use the length of the last buffer that was actually searched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5d5f58ad-b9df-4420-ad37-22caee78e925
mcgov (mcgov)
requested review from
LiliDeng and
Johnson (johnsongeorge-w)
as code owners
August 12, 2026 12:47
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a line-oriented waiting helper to Process and adjusts wait_output(delta_only=...) offset bookkeeping to better support incremental consumption of process output (used by the DPDK SRIOV hot-plug test rework).
Changes:
- Added
Process.wait_line(...)to consume captured output by complete lines and evaluate a caller-supplied predicate per line. - Updated
Process.wait_output(...)delta_onlyoffset advancement to move to the end of the matched keyword (and track the last searched buffer length for timeouts).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
AI Test Case SelectionSelected 1 test case(s): smoke_test Marketplace image: Result: Succeeded |
Add log line change for stdout -> 'output' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mcgov <6216084+mcgov@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
lisa/util/process.py:646
wait_outputcallsself.log_buffer.getvalue()twice per loop iteration (once forfind()and once forlen()). If new output is appended between those calls,last_search_lencan become longer than the buffer that was actually searched, so on timeoutlog_buffer_offsetmay skip over output that was never searched (reintroducing the delta_only bug this PR is trying to fix). Capture the buffer once and use it for both operations.
find_pos = self.log_buffer_offset if delta_only else 0
buffer = self.log_buffer.getvalue()
found_at_index = buffer.find(keyword, find_pos)
lisa/util/process.py:611
wait_lineonly evaluates complete newline-terminated lines. If the process exits without emitting a trailing newline, any remaining output after the last\nis never checked against the predicate, so a valid final line can be missed. Consider treating the remaining buffered text as a final line once the process is no longer running.
if not is_running:
# the process ended, and its remaining output is consumed.
break
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.
Part 1 of 9 of a stacked series that reworks the DPDK SRIOV hot plug tests. This one only touches
lisa/util/process.py.Process.wait_line, which consumes captured output line by line and hands each complete line to a caller supplied predicate, so tests can match on structured content (for example allkey=valuepairs of a uevent line) instead of the single substring searchwait_outputdoes.wait_output'sdelta_onlybookkeeping. The offset was advanced to the end of the whole buffer on a match, so any output that arrived after the matched keyword was skipped by the next call. It now advances to the end of the matched keyword, and on timeout uses the length of the last buffer that was actually searched.Key Test Cases:
verify_dpdk_sriov_rescind_failover_send_only|verify_dpdk_build_netvsc|smoke_test
Impacted LISA Features:
Sriov, NetworkInterface, SerialConsole
Tested Azure Marketplace Images:
canonical 0001-com-ubuntu-server-jammy 22_04-lts latest