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 <david(a)gibson.dropbear.id.au> --- avocado/tasst/site.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/avocado/tasst/site.py b/avocado/tasst/site.py index 6aa83c4..6450944 100644 --- a/avocado/tasst/site.py +++ b/avocado/tasst/site.py @@ -11,6 +11,7 @@ # Author: David Gibson <david(a)gibson.dropbear.id.au> import contextlib +import json import avocado from avocado.utils.process import CmdError @@ -50,6 +51,11 @@ class Site(contextlib.AbstractContextManager): raise avocado.TestCancel("Missing commands {} on {}" .format(', '.join(missing), 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] + class SiteTasst(Tasst): """ @@ -90,6 +96,10 @@ class SiteTasst(Tasst): status = proc.wait() self.assertNotEquals(status, 0) + def test_has_lo(self): + with self.setup_site() as site: + self.assertIn('lo', site.ifs()) + # Represents the host on which the tests are running, as opposed to # some simulated host created by the tests -- 2.40.1