diff options
Diffstat (limited to 'systest')
-rwxr-xr-x | systest | 54 |
1 files changed, 2 insertions, 52 deletions
@@ -6,60 +6,10 @@ import re import subprocess import unittest +import systest -class AssertionFailure(cliapp.AppException): - def __init__(self, msg): - self._str = msg - - def __str__(self): - return self._str - - -class TestCase(unittest.TestCase): - - '''Base class for system tests. - - This extends ``unittest.TestCase`` with some things that are - relevant to system tests. - - ''' - - def runcmd(self, argv, stdin='', *args, **kwargs): - p = subprocess.Popen(argv, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = p.communicate(stdin) - return p.returncode, out, err - - def hostcmd(self, argv, *args, **kwargs): - '''Run external command on test host.''' - returncode, out, err = self.runcmd(argv, *args, **kwargs) - if returncode: - msg = 'host command failed: %s\n%s' % (' '.join(argv), err) - logging.error(msg) - raise cliapp.AppException(msg) - return out - - def targetcmd(self, argv, *args, **kwargs): - '''Run command on test target.''' - full_argv = (['ssh', '-l', self.settings['user'], - self.settings['target']] + - argv) - returncode, out, err = self.runcmd(full_argv, *args, **kwargs) - if returncode: - msg = 'target command failed: %s\n%s' % (' '.join(argv), err) - logging.error(msg) - raise cliapp.AppException(msg) - return out - - def assertMatches(self, pat, text, msg=None): - self.assert_(re.match(pat, text), - msg=('pattern %s does not match %s' % (pat, text)) or msg) - - -class DebianBaseTests(TestCase): +class DebianBaseTests(systest.TestCase): def test_only_ssh_port(self): out = self.hostcmd(['nmap', self.settings['target']]) |