Patchwork [6/8] lib/oeqa/runtime: add tests for syslog and df

login
register
mail settings
Submitter Stanacar, StefanX
Date July 12, 2013, 4:46 p.m.
Message ID <b6123bdbc995f1815f567e6eb3902f4d9e735316.1373647359.git.stefanx.stanacar@intel.com>
Download mbox | patch
Permalink /patch/53625/
State New
Headers show

Comments

Stanacar, StefanX - July 12, 2013, 4:46 p.m.
From: Alexandru Palalau <alexandru.palalau@intel.com>

Signed-off-by: Alexandru Palalau <alexandru.palalau@intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
---
 meta/classes/testimage.bbclass  |  4 ++--
 meta/lib/oeqa/runtime/df.py     | 13 +++++++++++++
 meta/lib/oeqa/runtime/syslog.py | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 meta/lib/oeqa/runtime/df.py
 create mode 100644 meta/lib/oeqa/runtime/syslog.py

Patch

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index f66f514..22f0a92 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -2,8 +2,8 @@  TEST_LOG_DIR ?= "${WORKDIR}/testimage"
 
 DEFAULT_TEST_SUITES = "ping auto"
 DEFAULT_TEST_SUITES_pn-core-image-minimal = "ping"
-DEFAULT_TEST_SUITES_pn-core-image-sato = "ping ssh connman rpm smart xorg dmesg"
-DEFAULT_TEST_SUITES_pn-core-image-sato-sdk = "ping ssh connman rpm smart gcc xorg dmesg"
+DEFAULT_TEST_SUITES_pn-core-image-sato = "ping ssh connman df rpm smart xorg syslog dmesg"
+DEFAULT_TEST_SUITES_pn-core-image-sato-sdk = "ping ssh connman df rpm smart gcc xorg syslog dmesg"
 
 TEST_SUITES ?= "${DEFAULT_TEST_SUITES}"
 
diff --git a/meta/lib/oeqa/runtime/df.py b/meta/lib/oeqa/runtime/df.py
new file mode 100644
index 0000000..a781ea4
--- /dev/null
+++ b/meta/lib/oeqa/runtime/df.py
@@ -0,0 +1,13 @@ 
+import unittest
+from oeqa.oetest import oeRuntimeTest
+from oeqa.utils.decorators import *
+
+def setUpModule():
+    skipModuleUnless(oeRuntimeTest.tc.target.run('which df')[0] == 0, "No df in image or no connection")
+
+class DfTest(oeRuntimeTest):
+
+    @skipUnlessPassed("test_ssh")
+    def test_df(self):
+        (status,output) = self.target.run("df | awk '{if($1 == \"/dev/root\") print $4}'")
+        self.assertTrue(int(output)>5120, msg="Not enough space on image. Current size is %s" % output)
diff --git a/meta/lib/oeqa/runtime/syslog.py b/meta/lib/oeqa/runtime/syslog.py
new file mode 100644
index 0000000..9259349
--- /dev/null
+++ b/meta/lib/oeqa/runtime/syslog.py
@@ -0,0 +1,34 @@ 
+import unittest
+from oeqa.oetest import oeRuntimeTest, skipModule
+from oeqa.utils.decorators import *
+
+def setUpModule():
+    if not oeRuntimeTest.hasPackage("syslog"):
+        skipModule("No syslog package in image")
+
+class SyslogTest(oeRuntimeTest):
+
+    @skipUnlessPassed("test_ssh")
+    def test_syslog_help(self):
+        (status,output) = self.target.run('/sbin/syslogd --help')
+        self.assertEqual(status, 1, msg="status and output: %s and %s" % (status,output))
+
+    @skipUnlessPassed("test_syslog_help")
+    def test_syslogd_running(self):
+        (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
+        self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
+
+class SyslogTestConfig(oeRuntimeTest):
+
+    def setUp(self):
+        self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
+
+    @skipUnlessPassed("test_syslogd_running")
+    def test_syslogd_configurable(self):
+        (status,output) = self.target.run('/etc/init.d/syslog restart')
+        self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
+        (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
+        self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
+
+    def tearDown(self):
+        self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")