diff options
| -rw-r--r-- | lib/oeqa/runtime/cases/clamav.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/oeqa/runtime/cases/clamav.py b/lib/oeqa/runtime/cases/clamav.py index fc77330..647861c 100644 --- a/lib/oeqa/runtime/cases/clamav.py +++ b/lib/oeqa/runtime/cases/clamav.py | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | # Copyright (C) 2019 Armin Kuster <akuster808@gmail.com> | 1 | # Copyright (C) 2019 Armin Kuster <akuster808@gmail.com> |
| 2 | # | 2 | # |
| 3 | import re | 3 | import re |
| 4 | from tempfile import mkstemp | ||
| 4 | 5 | ||
| 5 | from oeqa.runtime.case import OERuntimeTestCase | 6 | from oeqa.runtime.case import OERuntimeTestCase |
| 6 | from oeqa.core.decorator.depends import OETestDepends | 7 | from oeqa.core.decorator.depends import OETestDepends |
| @@ -9,6 +10,20 @@ from oeqa.runtime.decorator.package import OEHasPackage | |||
| 9 | 10 | ||
| 10 | class ClamavTest(OERuntimeTestCase): | 11 | class ClamavTest(OERuntimeTestCase): |
| 11 | 12 | ||
| 13 | @classmethod | ||
| 14 | def setUpClass(cls): | ||
| 15 | cls.tmp_fd, cls.tmp_path = mkstemp() | ||
| 16 | with os.fdopen(cls.tmp_fd, 'w') as f: | ||
| 17 | # use gooled public dns | ||
| 18 | f.write("nameserver 8.8.8.8") | ||
| 19 | f.write(os.linesep) | ||
| 20 | f.write("nameserver 8.8.4.4") | ||
| 21 | f.write(os.linesep) | ||
| 22 | |||
| 23 | @classmethod | ||
| 24 | def tearDownClass(cls): | ||
| 25 | os.remove(cls.tmp_path) | ||
| 26 | |||
| 12 | @OEHasPackage(['clamav']) | 27 | @OEHasPackage(['clamav']) |
| 13 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 28 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
| 14 | def test_freshclam_help(self): | 29 | def test_freshclam_help(self): |
| @@ -18,6 +33,19 @@ class ClamavTest(OERuntimeTestCase): | |||
| 18 | self.assertEqual(status, 0, msg = msg) | 33 | self.assertEqual(status, 0, msg = msg) |
| 19 | 34 | ||
| 20 | @OETestDepends(['clamav.ClamavTest.test_freshclam_help']) | 35 | @OETestDepends(['clamav.ClamavTest.test_freshclam_help']) |
| 36 | @OEHasPackage(['openssh-scp', 'dropbear']) | ||
| 37 | def test_ping_clamav_net(self): | ||
| 38 | dst = '/etc/resolv.conf' | ||
| 39 | self.tc.target.run('rm -f %s' % dst) | ||
| 40 | (status, output) = self.tc.target.copyTo(self.tmp_path, dst) | ||
| 41 | msg = 'File could not be copied. Output: %s' % output | ||
| 42 | self.assertEqual(status, 0, msg=msg) | ||
| 43 | |||
| 44 | status, output = self.target.run('ping -c 1 database.clamav.net') | ||
| 45 | msg = ('ping database.clamav.net failed: output is:\n%s' % output) | ||
| 46 | self.assertEqual(status, 0, msg = msg) | ||
| 47 | |||
| 48 | @OETestDepends(['clamav.ClamavTest.test_ping_clamav_net']) | ||
| 21 | def test_freshclam_download(self): | 49 | def test_freshclam_download(self): |
| 22 | status, output = self.target.run('freshclam --show-progress') | 50 | status, output = self.target.run('freshclam --show-progress') |
| 23 | match = re.search('Database updated', output) | 51 | match = re.search('Database updated', output) |
