From: Stefan Stanacar Date: Fri, 28 Jun 2013 08:54:48 +0000 (+0300) Subject: lib/oeqa/runtime: image sanity tests X-Git-Tag: rev_ivi_2015_02_04~11874 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f22e91593b2b7796f8e829ce0a74fb320e24ba2a;p=scm%2Fbb%2Ftizen-distro.git lib/oeqa/runtime: image sanity tests These are basic sanity tests. A test can be force run by setting TEST_SUITES = "ping ssh " in local.conf. By default there are suites for minimal, sato and sato-sdk images. (From OE-Core rev: dd3dc2804395f050df74fa936e65ce5e911442eb) Signed-off-by: Stefan Stanacar Signed-off-by: Radu Moisan Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oeqa/runtime/__init__.py b/meta/lib/oeqa/runtime/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py new file mode 100644 index 0000000..835e135 --- /dev/null +++ b/meta/lib/oeqa/runtime/connman.py @@ -0,0 +1,34 @@ +import unittest +from oeqa.oetest import oeRuntimeTest, skipModule +from oeqa.utils.decorators import * + +def setUpModule(): + if not oeRuntimeTest.hasPackage("connman"): + skipModule("No connman package in image") + + +class ConnmanTest(oeRuntimeTest): + + @skipUnlessPassed('test_ssh') + def test_connmand_help(self): + (status, output) = self.target.run('/usr/sbin/connmand --help') + self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) + + + @skipUnlessPassed('test_connmand_help') + def test_connmand_running(self): + status = self.target.run('ls -l `which ps` | grep busybox')[0] + if status == 0: + oeRuntimeTest.pscmd = 'ps' + else: + oeRuntimeTest.pscmd = 'ps -ef' + (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand') + self.assertEqual(status, 0, msg="no connmand process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1]) + + @skipUnlessPassed('test_connmand_running') + def test_connmand_unique(self): + self.target.run('/usr/sbin/connmand') + output = self.target.run(oeRuntimeTest.pscmd + ' | grep -c [c]onnmand')[1] + self.assertEqual(output, "1", msg="more than one connmand running in background, ps output: %s\n%s" % (output, self.target.run(oeRuntimeTest.pscmd)[1])) + + diff --git a/meta/lib/oeqa/runtime/dmesg.py b/meta/lib/oeqa/runtime/dmesg.py new file mode 100644 index 0000000..b0e2175 --- /dev/null +++ b/meta/lib/oeqa/runtime/dmesg.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 dmesg')[0] == 0, "No dmesg in image or no connection") + +class DmesgTest(oeRuntimeTest): + + @skipUnlessPassed('test_ssh') + def test_dmesg(self): + (status, output) = self.target.run('dmesg | grep -v mmci-pl18x | grep -i error') + self.assertEqual(status, 1, msg = "Error messages in dmesg log: %s" % output) diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py new file mode 100644 index 0000000..397d075 --- /dev/null +++ b/meta/lib/oeqa/runtime/multilib.py @@ -0,0 +1,14 @@ +import unittest +from oeqa.oetest import oeRuntimeTest, skipModule + +def setUpModule(): + multilibs = oeRuntimeTest.tc.d.getVar("MULTILIBS", True) or "" + if "multlib:lib32" not in multilibs: + skipModule("this isn't a multilib:lib32 image") + + +class MultilibFileTest(oeRuntimeTest): + + def test_file_connman(self): + (status, output) = self.target.run('file -L /usr/sbin/connmand | grep "ELF 32-bit LSB executable"') + self.assertEqual(status, 0, msg="status and output : %s and %s" % (status,output)) diff --git a/meta/lib/oeqa/runtime/ping.py b/meta/lib/oeqa/runtime/ping.py new file mode 100644 index 0000000..d6a0c28 --- /dev/null +++ b/meta/lib/oeqa/runtime/ping.py @@ -0,0 +1,11 @@ +import subprocess +import unittest +import sys +from oeqa.oetest import oeRuntimeTest + +class PingTest(oeRuntimeTest): + + def test_ping(self): + status = subprocess.call("ping -w 30 -c 1 %s" % oeRuntimeTest.tc.qemu.ip, shell=True, stdout=subprocess.PIPE) + self.assertEqual(status, 0) + diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py new file mode 100644 index 0000000..57101b0 --- /dev/null +++ b/meta/lib/oeqa/runtime/rpm.py @@ -0,0 +1,25 @@ +import unittest +from oeqa.oetest import oeRuntimeTest, skipModule +from oeqa.utils.decorators import * + +def setUpModule(): + if not oeRuntimeTest.hasFeature("package-management"): + skipModule("rpm module skipped: target doesn't have package-management in IMAGE_FEATURES") + if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: + skipModule("rpm module skipped: target doesn't have rpm as primary package manager") + + +class RpmHelpTest(oeRuntimeTest): + + @skipUnlessPassed('test_ssh') + def test_rpm_help(self): + (status, output) = self.target.run('rpm --help') + self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) + +class RpmQueryTest(oeRuntimeTest): + + @skipUnlessPassed('test_rpm_help') + def test_rpm_query(self): + (status, output) = self.target.run('rpm -q rpm') + self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) + diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py new file mode 100644 index 0000000..8cfacd4 --- /dev/null +++ b/meta/lib/oeqa/runtime/smart.py @@ -0,0 +1,27 @@ +import unittest +from oeqa.oetest import oeRuntimeTest +from oeqa.utils.decorators import * + +def setUpModule(): + if not oeRuntimeTest.hasFeature("package-management"): + skipModule("Image doesn't have package management feature") + if not oeRuntimeTest.hasPackage("smart"): + skipModule("Image doesn't have smart installed") + +class SmartHelpTest(oeRuntimeTest): + + def test_smart_help(self): + status = self.target.run('smart --help')[0] + self.assertEqual(status, 0) + +class SmartQueryTest(oeRuntimeTest): + + @skipUnlessPassed('test_smart_help') + def test_smart_query(self): + (status, output) = self.target.run('smart query rpm') + self.assertEqual(status, 0, msg="smart query failed, output: %s" % output) + + @skipUnlessPassed('test_smart_query') + def test_smart_info(self): + (status, output) = self.target.run('smart info rpm') + self.assertEqual(status, 0, msg="smart info rpm failed, output: %s" % output) diff --git a/meta/lib/oeqa/runtime/ssh.py b/meta/lib/oeqa/runtime/ssh.py new file mode 100644 index 0000000..8c96020 --- /dev/null +++ b/meta/lib/oeqa/runtime/ssh.py @@ -0,0 +1,16 @@ +import subprocess +import unittest +import sys +from oeqa.oetest import oeRuntimeTest, skipModule +from oeqa.utils.decorators import * + +def setUpModule(): + if not (oeRuntimeTest.hasPackage("dropbear") or oeRuntimeTest.hasPackage("openssh")): + skipModule("No ssh package in image") + +class SshTest(oeRuntimeTest): + + @skipUnlessPassed('test_ping') + def test_ssh(self): + (status, output) = self.target.run('uname -a') + self.assertEqual(status, 0, msg="SSH Test failed: %s" % output) diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py new file mode 100644 index 0000000..edf4f39 --- /dev/null +++ b/meta/lib/oeqa/runtime/systemd.py @@ -0,0 +1,24 @@ +import unittest +from oeqa.oetest import oeRuntimeTest, skipModule +from oeqa.utils.decorators import * + +def setUpModule(): + if not oeRuntimeTest.hasFeature("systemd"): + skipModule("target doesn't have systemd in DISTRO_FEATURES") + if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", True): + skipModule("systemd is not the init manager for this image") + + +class SystemdBasicTest(oeRuntimeTest): + + @skipUnlessPassed('test_ssh') + def test_systemd_version(self): + (status, output) = self.target.run('systemctl --version') + self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) + +class SystemdTests(oeRuntimeTest): + + @skipUnlessPassed('test_systemd_version') + def test_systemd_failed(self): + (status, output) = self.target.run('systemctl --failed | grep "0 loaded units listed"') + self.assertEqual(status, 0, msg="Failed systemd services: %s" % self.target.run('systemctl --failed')[1]) diff --git a/meta/lib/oeqa/runtime/xorg.py b/meta/lib/oeqa/runtime/xorg.py new file mode 100644 index 0000000..96cc20a --- /dev/null +++ b/meta/lib/oeqa/runtime/xorg.py @@ -0,0 +1,21 @@ +import unittest +from oeqa.oetest import oeRuntimeTest, skipModule +from oeqa.utils.decorators import * + +def setUpModule(): + if not oeRuntimeTest.hasFeature("x11-base"): + skipModule("target doesn't have x11 in IMAGE_FEATURES") + + +class XorgTest(oeRuntimeTest): + + @skipUnlessPassed('test_ssh') + def test_xorg_running(self): + (status, output) = self.target.run('ps | grep -v xinit | grep [X]org') + self.assertEqual(status, 0, msg="Xorg does not appear to be running %s" % self.target.run('ps')[1]) + + @skipUnlessPassed('test_ssh') + def test_xorg_error(self): + (status, output) = self.target.run('cat /var/log/Xorg.0.log | grep -v "(EE) error," | grep -v "PreInit" | grep -v "evdev:" | grep -v "glx" | grep "(EE)"') + self.assertEqual(status, 1, msg="Errors in Xorg log: %s" % output) +