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
# Conflicts:
# test/tasst/exesite.py
---
test/tasst/exesite.py | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/test/tasst/exesite.py b/test/tasst/exesite.py
index e69db8ad..811b670e 100644
--- a/test/tasst/exesite.py
+++ b/test/tasst/exesite.py
@@ -13,10 +13,13 @@ tasst/exesite.py - Manage simulated network sites for testing
import contextlib
+import json
import avocado
from avocado.utils.process import CmdError
-from avocado_classless.test import assert_eq, assert_raises, test_output
+from avocado_classless.test import (
+ assert_eq, assert_in, assert_raises, test_output
+)
from tasst.typecheck import typecheck
@@ -93,6 +96,11 @@ class Site(contextlib.AbstractContextManager):
raise avocado.TestCancel(
f"Missing commands {', '.join(missing)} on {self.name}")
+ def ifs(self):
+ self.require_cmds('ip')
+ info = json.loads(self.output('ip -j link show'))
+ return [i['ifname'] for i in info]
+
def test_site(sitefn):
def test_true(s):
@@ -143,9 +151,14 @@ def test_site(sitefn):
ignore_status=True):
pass
+ def test_has_lo(s):
+ with s as site:
+ assert_in('lo', site.ifs())
+
return test_output(test_true, test_false, test_echo, test_timeout,
test_bg_true, test_bg_false, test_bg_echo,
- test_bg_timeout, test_bg_context_timeout)(sitefn)
+ test_bg_timeout, test_bg_context_timeout,
+ test_has_lo)(sitefn)
class RealHost(Site):
--
2.41.0