summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/lib/py/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/net/lib/py/utils.py')
-rw-r--r--tools/testing/selftests/net/lib/py/utils.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index d3715e6c21f2..4930a90a64ea 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -56,10 +56,10 @@ class bkg(cmd):
return self.process(terminate=self.terminate)
-def ip(args, json=None, ns=None, host=None):
- cmd_str = "ip "
+def tool(name, args, json=None, ns=None, host=None):
+ cmd_str = name + ' '
if json:
- cmd_str += '-j '
+ cmd_str += '--json '
cmd_str += args
cmd_obj = cmd(cmd_str, ns=ns, host=host)
if json:
@@ -67,6 +67,12 @@ def ip(args, json=None, ns=None, host=None):
return cmd_obj
+def ip(args, json=None, ns=None, host=None):
+ if ns:
+ args = f'-netns {ns} ' + args
+ return tool('ip', args, json=json, host=host)
+
+
def rand_port():
"""
Get unprivileged port, for now just random, one day we may decide to check if used.