Start adding convenience functions for handling sites as places with
network setup with a simple helper which lists the network interface names
for a site.
Signed-off-by: David Gibson
---
test/tasst/snh.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/test/tasst/snh.py b/test/tasst/snh.py
index dfbe2c84..8ee9802a 100644
--- a/test/tasst/snh.py
+++ b/test/tasst/snh.py
@@ -13,6 +13,7 @@ tasst/snh.py - Simulated network hosts for testing
import contextlib
+import json
import subprocess
import sys
@@ -105,6 +106,10 @@ class SimNetHost(contextlib.AbstractContextManager):
file=sys.stderr)
return proc
+ def ifs(self):
+ info = json.loads(self.output('ip', '-j', 'link', 'show'))
+ return [i['ifname'] for i in info]
+
# Internal tests
def test_true(self):
with self as snh:
@@ -157,9 +162,14 @@ class SimNetHost(contextlib.AbstractContextManager):
pass
exeter.assert_raises(subprocess.TimeoutExpired, run_timeout)
+ def test_has_lo(self):
+ with self as snh:
+ assert 'lo' in snh.ifs()
+
SELFTESTS = [test_true, test_false, test_echo, test_timeout,
test_bg_true, test_bg_false, test_bg_echo, test_bg_timeout,
- test_bg_context_timeout]
+ test_bg_context_timeout,
+ test_has_lo]
@classmethod
def selftest(cls, setup):
--
2.45.2