Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | # Copyright (C) 2019 Armin Kuster <akuster808@gmail.com> |
| 2 | # |
| 3 | import re |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 4 | import os |
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 SamhainTest(OERuntimeTestCase): |
| 12 | |
| 13 | @OEHasPackage(['samhain-standalone']) |
| 14 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 15 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | 'Status and output:%s and %s' % (status, output)) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 20 | 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) |