Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- avocado/tasst/site.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/avocado/tasst/site.py b/avocado/tasst/site.py index 682baee..61e424c 100644 --- a/avocado/tasst/site.py +++ b/avocado/tasst/site.py @@ -42,6 +42,9 @@ class Site: def fg(self, cmd, **kwargs): self.output(cmd, **kwargs) + def bg(self, cmd, **kwargs): + raise NotImplementedError + def require_cmds(self, *cmds): missing = [c for c in cmds if self.fg('type {}'.format(c), ignore_status=True) != 0] @@ -79,6 +82,18 @@ class BaseSiteTasst(Tasst): out = site.output('echo {}'.format(s)) self.assertEquals(out, s.encode('utf-8')) + def test_bg_true(self): + site = self.get_subsetup(BaseSiteTasst) + proc = site.bg('true') + status = proc.wait() + self.assertEquals(status, 0) + + def test_bg_false(self): + site = self.get_subsetup(BaseSiteTasst) + proc = site.bg('false') + status = proc.wait() + self.assertNotEquals(status, 0) + # Represents the host on which the tests are running, as opposed to # some simulated host created by the tests @@ -94,6 +109,12 @@ class RealHost(Site): assert not sudo, "BUG: Shouldn't run commands with privilege on host" return avocado.utils.process.system(cmd, **kwargs) + def bg(self, cmd, sudo=False, **kwargs): + assert not sudo, "BUG: Shouldn't run commands with privilege on host" + proc = avocado.utils.process.SubProcess(cmd, **kwargs) + proc.start() + return proc + REAL_HOST = RealHost() -- 2.40.1