Skip to contentSkip to conversation

samhain: add more tests and fix ret checks

PATCH New Armin Kuster 1 participant 1 message May 8, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 samhain: add more tests and fix ret checks

---
 lib/oeqa/runtime/cases/samhain.py | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)
lib/oeqa/runtime/cases/samhain.py +27 -4
index e4bae7b..5043a38 100644
@@ -1,6 +1,7 @@
 # Copyright (C) 2019 Armin Kuster <[email protected]>
 #
 import re
+import os
 
 from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
@@ -11,10 +12,32 @@ class SamhainTest(OERuntimeTestCase):
 
     @OEHasPackage(['samhain-standalone'])
     @OETestDepends(['ssh.SSHTest.test_ssh'])
-    def test_samhain_standalone_help(self):
+    def test_samhain_help(self):
+        machine = self.td.get('MACHINE', '')
+        status, output = self.target.run('echo "127.0.0.1 %s.localdomain  %s" >> /etc/hosts' % (machine, machine))
+        msg = ("samhain can't append hosts. "
+               'Status and output:%s and %s' % (status, output))
+        self.assertEqual(status, 0, msg = msg)
+
         status, output = self.target.run('samhain --help')
-        match = re.search('Please report bugs to [email protected].', output)
+        msg = ('samhain command does not work as expected. '
+               'Status and output:%s and %s' % (status, output))
+        self.assertEqual(status, 0, msg = msg)
+
+    @OETestDepends(['samhain.SamhainTest.test_samhain_help'])
+    def test_samhain_init_db(self):
+        status, output = self.target.run('samhain -t init')
+        match = re.search('FAILED: 0 ', output)
+        if not match:
+            msg = ('samhain database init had an unexpected failure. '
+               'Status and output:%s and %s' % (status, output))
+            self.assertEqual(status, 0, msg = msg)
+
+    @OETestDepends(['samhain.SamhainTest.test_samhain_init_db'])
+    def test_samhain_db_check(self):
+        status, output = self.target.run('samhain -t check')
+        match = re.search('FAILED: 0 ', output)
         if not match:
-            msg = ('samhain-standalone command does not work as expected. '
+            msg = ('samhain errors found in db. '
                'Status and output:%s and %s' % (status, output))
-            self.assertEqual(status, 1, msg = msg)
+            self.assertEqual(status, 0, msg = msg)
Signature · 1 line
2.17.1