lib/oeqa/runtime: image sanity tests
These are basic sanity tests. A test can be force run by setting TEST_SUITES = "ping ssh <module-name>" 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 <stefanx.stanacar@intel.com> Signed-off-by: Radu Moisan <radu.moisan@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
54f3848397
commit
06d6f9d52e
|
@ -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]))
|
||||
|
||||
|
|
@ -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)
|
|
@ -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))
|
|
@ -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)
|
||||
|
|
@ -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))
|
||||
|
|
@ -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)
|
|
@ -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)
|
|
@ -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])
|
|
@ -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)
|
||||
|
Loading…
Reference in New Issue