selftests: net: fix cmd.process() timeout handling
Subsystems (3)
v3 cover selftests: net: fix cmd.process() timeout handling
Pass the timeout argument correctly in cmd.process(). As Jakub noted, fixing the timeout broke the bpftrace() command in netpoll_basic.py, so fix it first.
Changelog:v2->v3: https://lore.kernel.org/all/[email protected]/
* Resubmit to net-next.
v1->v2: https://lore.kernel.org/all/[email protected]/
* Add patch #1.
Gal Pressman (2):
selftests: net: pass bpftrace timeout to cmd()
selftests: net: fix timeout passed as positional argument to
communicate()
tools/testing/selftests/net/lib/py/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.52.0
PATCH v3 1/2 selftests: net: pass bpftrace timeout to cmd()
The bpftrace() helper configures an interval based exit timer but does not propagate the timeout to the cmd object, which defaults to 5 seconds. Since the default BPFTRACE_TIMEOUT is 10 seconds, cmd.process() always raises a TimeoutExpired exception before bpftrace has a chance to exit gracefully.
Pass timeout+5 to cmd() to allow bpftrace to complete gracefully.
Note: this issue is masked by a bug in the way cmd() passes timeout, this is fixed in the next commit.
--- tools/testing/selftests/net/lib/py/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/lib/py/utils.py +2 -1
@@ -258,8 +258,9 @@ def bpftrace(expr, json=None, ns=None, host=None, timeout=None): cmd_arr += ['-f', 'json', '-q'] if timeout: expr += ' interval:s:' + str(timeout) + ' { exit(); }' + timeout += 5 cmd_arr += ['-e', expr] - cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False) + cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False, timeout=timeout) if json: # bpftrace prints objects as lines ret = {}
Signature · 1 line
2.52.0
PATCH v3 2/2 selftests: net: fix timeout passed as positional argument to communicate()
In reply to Gal PressmanThe cited commit refactored the hardcoded timeout=5 into a parameter, but dropped the keyword from the communicate() call.
Since Popen.communicate()'s first positional argument is 'input' (not 'timeout'), the timeout value is silently treated as stdin input and the call never enforces a timeout.
Pass timeout as a keyword argument to restore the intended behavior.
--- tools/testing/selftests/net/lib/py/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/lib/py/utils.py +1 -1
@@ -93,7 +93,7 @@ class cmd: def _process_terminate(self, terminate, timeout): if terminate: self.proc.terminate() - stdout, stderr = self.proc.communicate(timeout) + stdout, stderr = self.proc.communicate(timeout=timeout) self.stdout = stdout.decode("utf-8") self.stderr = stderr.decode("utf-8") self.proc.stdout.close()
Signature · 1 line
2.52.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 10 Mar 2026 13:58:01 +0200 you wrote:
Pass the timeout argument correctly in
cmd.process(). As Jakub noted, fixing the timeout broke thebpftrace()command innetpoll_basic.py, so fix it first.Changelog:
v2->v3: https://lore.kernel.org/all/[email protected]/
* Resubmit to net-next.[...]
Here is the summary with links:
- [net-next,v3,1/2] selftests: net: pass bpftrace timeout to cmd()
https://git.kernel.org/netdev/net-next/c/82562972b854 - [net-next,v3,2/2] selftests: net: fix timeout passed as positional argument to communicate() https://git.kernel.org/netdev/net-next/c/f0bd19316663
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html