blob: e0cad8f3073ef9200fca455fbd65167a3f31cd00 [file] [log] [blame]
Andrew Geissler615f2f12022-07-15 14:00:58 -05001# Copyright (C) 2019 - 2022 Armin Kuster <akuster808@gmail.com>
Brad Bishop19323692019-04-05 15:28:33 -04002#
3import re
Brad Bishopc342db32019-05-15 21:57:59 -04004from tempfile import mkstemp
Brad Bishop19323692019-04-05 15:28:33 -04005
6from oeqa.runtime.case import OERuntimeTestCase
7from oeqa.core.decorator.depends import OETestDepends
8from oeqa.runtime.decorator.package import OEHasPackage
9
10
11class ClamavTest(OERuntimeTestCase):
12
Brad Bishopc342db32019-05-15 21:57:59 -040013 @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 Bishop19323692019-04-05 15:28:33 -040029 @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 Bishopc342db32019-05-15 21:57:59 -040038 @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 Bishop19323692019-04-05 15:28:33 -040051 def test_freshclam_download(self):
52 status, output = self.target.run('freshclam --show-progress')
Andrew Geissler615f2f12022-07-15 14:00:58 -050053 msg = ('freshclam : DB dowbload failed. '
54 'Status and output:%s and %s' % (status, output))
55 self.assertEqual(status, 0, msg = msg)