blob: 5043a38cc66bb4bd56eb048bb81166d8bcc143ab [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001# Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
2#
3import re
Brad Bishopc342db32019-05-15 21:57:59 -04004import os
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 SamhainTest(OERuntimeTestCase):
12
13 @OEHasPackage(['samhain-standalone'])
14 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishopc342db32019-05-15 21:57:59 -040015 def test_samhain_help(self):
16 machine = self.td.get('MACHINE', '')
17 status, output = self.target.run('echo "127.0.0.1 %s.localdomain %s" >> /etc/hosts' % (machine, machine))
18 msg = ("samhain can't append hosts. "
Brad Bishop19323692019-04-05 15:28:33 -040019 'Status and output:%s and %s' % (status, output))
Brad Bishopc342db32019-05-15 21:57:59 -040020 self.assertEqual(status, 0, msg = msg)
21
22 status, output = self.target.run('samhain --help')
23 msg = ('samhain command does not work as expected. '
24 'Status and output:%s and %s' % (status, output))
25 self.assertEqual(status, 0, msg = msg)
26
27 @OETestDepends(['samhain.SamhainTest.test_samhain_help'])
28 def test_samhain_init_db(self):
29 status, output = self.target.run('samhain -t init')
30 match = re.search('FAILED: 0 ', output)
31 if not match:
32 msg = ('samhain database init had an unexpected failure. '
33 'Status and output:%s and %s' % (status, output))
34 self.assertEqual(status, 0, msg = msg)
35
36 @OETestDepends(['samhain.SamhainTest.test_samhain_init_db'])
37 def test_samhain_db_check(self):
38 status, output = self.target.run('samhain -t check')
39 match = re.search('FAILED: 0 ', output)
40 if not match:
41 msg = ('samhain errors found in db. '
42 'Status and output:%s and %s' % (status, output))
43 self.assertEqual(status, 0, msg = msg)