| Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 1 | # Copyright (C) 2019 - 2022 Armin Kuster <akuster808@gmail.com> | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 2 | # | 
|  | 3 | import re | 
| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | from tempfile import mkstemp | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 |  | 
|  | 6 | from oeqa.runtime.case import OERuntimeTestCase | 
|  | 7 | from oeqa.core.decorator.depends import OETestDepends | 
|  | 8 | from oeqa.runtime.decorator.package import OEHasPackage | 
|  | 9 |  | 
|  | 10 |  | 
|  | 11 | class ClamavTest(OERuntimeTestCase): | 
|  | 12 |  | 
| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 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 | f.write("nameserver 127.0.0.1") | 
|  | 23 | f.write(os.linesep) | 
|  | 24 |  | 
|  | 25 | @classmethod | 
|  | 26 | def tearDownClass(cls): | 
|  | 27 | os.remove(cls.tmp_path) | 
|  | 28 |  | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | @OEHasPackage(['clamav']) | 
|  | 30 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 
|  | 31 | def test_freshclam_help(self): | 
|  | 32 | status, output = self.target.run('freshclam --help ') | 
|  | 33 | msg = ('freshclam --hlep  command does not work as expected. ', | 
|  | 34 | 'Status and output:%s and %s' % (status, output)) | 
|  | 35 | self.assertEqual(status, 0, msg = msg) | 
|  | 36 |  | 
|  | 37 | @OETestDepends(['clamav.ClamavTest.test_freshclam_help']) | 
| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 38 | @OEHasPackage(['openssh-scp', 'dropbear']) | 
|  | 39 | def test_ping_clamav_net(self): | 
|  | 40 | dst = '/etc/resolv.conf' | 
|  | 41 | self.tc.target.run('rm -f %s' % dst) | 
|  | 42 | (status, output) = self.tc.target.copyTo(self.tmp_path, dst) | 
|  | 43 | msg = 'File could not be copied. Output: %s' % output | 
|  | 44 | self.assertEqual(status, 0, msg=msg) | 
|  | 45 |  | 
|  | 46 | status, output = self.target.run('ping -c 1 database.clamav.net') | 
|  | 47 | msg = ('ping database.clamav.net failed: output is:\n%s' % output) | 
|  | 48 | self.assertEqual(status, 0, msg = msg) | 
|  | 49 |  | 
|  | 50 | @OETestDepends(['clamav.ClamavTest.test_ping_clamav_net']) | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 51 | def test_freshclam_download(self): | 
|  | 52 | status, output = self.target.run('freshclam --show-progress') | 
| Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 53 | msg = ('freshclam : DB dowbload failed. ' | 
|  | 54 | 'Status and output:%s and %s' % (status, output)) | 
|  | 55 | self.assertEqual(status, 0, msg = msg) |