summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-10-27 16:39:47 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:19 +0000
commitb61326efb1bc66202831f9710716b5171a722039 (patch)
tree31e229ee225f0a816eb60a5fb721b021f8eab3e2 /meta/lib/oeqa/runtime
parentba1aec3407e38f4dc4141e4d6300b3d538dc9dd3 (diff)
downloadpoky-b61326efb1bc66202831f9710716b5171a722039.tar.gz
oeqa/runtime: Move to runtime_cases
The new oeqa core framework will modify the structure of the runtime folder the new runtime folder will have python code inside to support runtime test cases. (From OE-Core rev: 637b712096e9d230e15b1a432a561e4118db34c8) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r--meta/lib/oeqa/runtime/_ptest.py125
-rw-r--r--meta/lib/oeqa/runtime/_qemutiny.py9
-rw-r--r--meta/lib/oeqa/runtime/buildcvs.py32
-rw-r--r--meta/lib/oeqa/runtime/buildgalculator.py26
-rw-r--r--meta/lib/oeqa/runtime/buildiptables.py33
-rw-r--r--meta/lib/oeqa/runtime/connman.py31
-rw-r--r--meta/lib/oeqa/runtime/date.py31
-rw-r--r--meta/lib/oeqa/runtime/df.py12
-rw-r--r--meta/lib/oeqa/runtime/files/hellomod.c19
-rw-r--r--meta/lib/oeqa/runtime/files/hellomod_makefile8
-rw-r--r--meta/lib/oeqa/runtime/files/testmakefile5
-rw-r--r--meta/lib/oeqa/runtime/gcc.py47
-rw-r--r--meta/lib/oeqa/runtime/kernelmodule.py34
-rw-r--r--meta/lib/oeqa/runtime/ldd.py21
-rw-r--r--meta/lib/oeqa/runtime/logrotate.py30
-rw-r--r--meta/lib/oeqa/runtime/multilib.py42
-rw-r--r--meta/lib/oeqa/runtime/pam.py25
-rw-r--r--meta/lib/oeqa/runtime/parselogs.py325
-rw-r--r--meta/lib/oeqa/runtime/perl.py30
-rw-r--r--meta/lib/oeqa/runtime/ping.py22
-rw-r--r--meta/lib/oeqa/runtime/python.py35
-rw-r--r--meta/lib/oeqa/runtime/rpm.py120
-rw-r--r--meta/lib/oeqa/runtime/scanelf.py28
-rw-r--r--meta/lib/oeqa/runtime/scp.py22
-rw-r--r--meta/lib/oeqa/runtime/skeletoninit.py29
-rw-r--r--meta/lib/oeqa/runtime/smart.py218
-rw-r--r--meta/lib/oeqa/runtime/ssh.py19
-rw-r--r--meta/lib/oeqa/runtime/syslog.py52
-rw-r--r--meta/lib/oeqa/runtime/systemd.py178
-rw-r--r--meta/lib/oeqa/runtime/x32lib.py18
-rw-r--r--meta/lib/oeqa/runtime/xorg.py16
31 files changed, 0 insertions, 1642 deletions
diff --git a/meta/lib/oeqa/runtime/_ptest.py b/meta/lib/oeqa/runtime/_ptest.py
deleted file mode 100644
index a2432517e3..0000000000
--- a/meta/lib/oeqa/runtime/_ptest.py
+++ /dev/null
@@ -1,125 +0,0 @@
1import unittest, os, shutil
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4from oeqa.utils.logparser import *
5from oeqa.utils.httpserver import HTTPService
6import bb
7import glob
8from oe.package_manager import RpmPkgsList
9import subprocess
10
11def setUpModule():
12 if not oeRuntimeTest.hasFeature("package-management"):
13 skipModule("Image doesn't have package management feature")
14 if not oeRuntimeTest.hasPackage("smartpm"):
15 skipModule("Image doesn't have smart installed")
16 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES").split()[0]:
17 skipModule("Rpm is not the primary package manager")
18
19class PtestRunnerTest(oeRuntimeTest):
20
21 # a ptest log parser
22 def parse_ptest(self, logfile):
23 parser = Lparser(test_0_pass_regex="^PASS:(.+)", test_0_fail_regex="^FAIL:(.+)", section_0_begin_regex="^BEGIN: .*/(.+)/ptest", section_0_end_regex="^END: .*/(.+)/ptest")
24 parser.init()
25 result = Result()
26
27 with open(logfile) as f:
28 for line in f:
29 result_tuple = parser.parse_line(line)
30 if not result_tuple:
31 continue
32 result_tuple = line_type, category, status, name = parser.parse_line(line)
33
34 if line_type == 'section' and status == 'begin':
35 current_section = name
36 continue
37
38 if line_type == 'section' and status == 'end':
39 current_section = None
40 continue
41
42 if line_type == 'test' and status == 'pass':
43 result.store(current_section, name, status)
44 continue
45
46 if line_type == 'test' and status == 'fail':
47 result.store(current_section, name, status)
48 continue
49
50 result.sort_tests()
51 return result
52
53 @classmethod
54 def setUpClass(self):
55 #note the existing channels that are on the board before creating new ones
56# self.existingchannels = set()
57# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
58# for x in result.split("\n"):
59# self.existingchannels.add(x)
60 self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR'), oeRuntimeTest.tc.target.server_ip)
61 self.repo_server.start()
62
63 @classmethod
64 def tearDownClass(self):
65 self.repo_server.stop()
66 #remove created channels to be able to repeat the tests on same image
67# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
68# for x in result.split("\n"):
69# if x not in self.existingchannels:
70# oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0)
71
72 def add_smart_channel(self):
73 image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE')
74 deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
75 pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-","_").split()
76 for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
77 if arch in pkgarchs:
78 self.target.run('smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url), 0)
79 self.target.run('smart update', 0)
80
81 def install_complementary(self, globs=None):
82 installed_pkgs_file = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'),
83 "installed_pkgs.txt")
84 self.pkgs_list = RpmPkgsList(oeRuntimeTest.tc.d, oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS'), oeRuntimeTest.tc.d.getVar('arch_var'), oeRuntimeTest.tc.d.getVar('os_var'))
85 with open(installed_pkgs_file, "w+") as installed_pkgs:
86 installed_pkgs.write(self.pkgs_list.list("arch"))
87
88 cmd = [bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"),
89 "-p", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR'), "glob", installed_pkgs_file,
90 globs]
91 try:
92 bb.note("Installing complementary packages ...")
93 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
94 except subprocess.CalledProcessError as e:
95 bb.fatal("Could not compute complementary packages list. Command "
96 "'%s' returned %d:\n%s" %
97 (' '.join(cmd), e.returncode, e.output))
98
99 return complementary_pkgs.split()
100
101 def setUpLocal(self):
102 self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR"), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME'))
103
104 @skipUnlessPassed('test_ssh')
105 def test_ptestrunner(self):
106 self.add_smart_channel()
107 (runnerstatus, result) = self.target.run('which ptest-runner', 0)
108 cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0)
109 if cond:
110 self.install_packages(self.install_complementary("*-ptest"))
111 self.install_packages(['ptest-runner'])
112
113 (runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
114 #exit code is !=0 even if ptest-runner executes because some ptest tests fail.
115 self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!")
116 self.target.copy_from('/tmp/ptest.log', self.ptest_log)
117 shutil.copyfile(self.ptest_log, "ptest.log")
118
119 result = self.parse_ptest("ptest.log")
120 log_results_to_location = "./results"
121 if os.path.exists(log_results_to_location):
122 shutil.rmtree(log_results_to_location)
123 os.makedirs(log_results_to_location)
124
125 result.log_as_files(log_results_to_location, test_status = ['pass','fail'])
diff --git a/meta/lib/oeqa/runtime/_qemutiny.py b/meta/lib/oeqa/runtime/_qemutiny.py
deleted file mode 100644
index a3c29f3572..0000000000
--- a/meta/lib/oeqa/runtime/_qemutiny.py
+++ /dev/null
@@ -1,9 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest
3from oeqa.utils.qemutinyrunner import *
4
5class QemuTinyTest(oeRuntimeTest):
6
7 def test_boot_tiny(self):
8 (status, output) = self.target.run_serial('uname -a')
9 self.assertTrue("yocto-tiny" in output, msg="Cannot detect poky tiny boot!") \ No newline at end of file
diff --git a/meta/lib/oeqa/runtime/buildcvs.py b/meta/lib/oeqa/runtime/buildcvs.py
deleted file mode 100644
index a5ca3a5b37..0000000000
--- a/meta/lib/oeqa/runtime/buildcvs.py
+++ /dev/null
@@ -1,32 +0,0 @@
1from oeqa.oetest import oeRuntimeTest, skipModule
2from oeqa.utils.decorators import *
3from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
4
5def setUpModule():
6 if not oeRuntimeTest.hasFeature("tools-sdk"):
7 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
8
9class BuildCvsTest(oeRuntimeTest):
10
11 @classmethod
12 def setUpClass(self):
13 dl_dir = oeRuntimeTest.tc.d.getVar('DL_DIR', True)
14 self.project = TargetBuildProject(oeRuntimeTest.tc.target,
15 "http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2",
16 dl_dir=dl_dir)
17
18 @testcase(205)
19 @skipUnlessPassed("test_ssh")
20 def test_cvs(self):
21 self.assertEqual(self.project.run_configure(), 0,
22 msg="Running configure failed")
23
24 self.assertEqual(self.project.run_make(), 0,
25 msg="Running make failed")
26
27 self.assertEqual(self.project.run_install(), 0,
28 msg="Running make install failed")
29
30 @classmethod
31 def tearDownClass(self):
32 self.project.clean()
diff --git a/meta/lib/oeqa/runtime/buildgalculator.py b/meta/lib/oeqa/runtime/buildgalculator.py
deleted file mode 100644
index 20f0a79367..0000000000
--- a/meta/lib/oeqa/runtime/buildgalculator.py
+++ /dev/null
@@ -1,26 +0,0 @@
1from oeqa.oetest import oeRuntimeTest, skipModule
2from oeqa.utils.decorators import *
3from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
4
5def setUpModule():
6 if not oeRuntimeTest.hasFeature("tools-sdk"):
7 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
8
9class GalculatorTest(oeRuntimeTest):
10 @testcase(1526)
11 @skipUnlessPassed("test_ssh")
12 def test_galculator(self):
13 dl_dir = oeRuntimeTest.tc.d.getVar('DL_DIR', True)
14 try:
15 project = TargetBuildProject(oeRuntimeTest.tc.target,
16 "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2",
17 dl_dir=dl_dir)
18 project.download_archive()
19
20 self.assertEqual(project.run_configure(), 0,
21 msg="Running configure failed")
22
23 self.assertEqual(project.run_make(), 0,
24 msg="Running make failed")
25 finally:
26 project.clean()
diff --git a/meta/lib/oeqa/runtime/buildiptables.py b/meta/lib/oeqa/runtime/buildiptables.py
deleted file mode 100644
index a0e82f0dde..0000000000
--- a/meta/lib/oeqa/runtime/buildiptables.py
+++ /dev/null
@@ -1,33 +0,0 @@
1from oeqa.oetest import oeRuntimeTest, skipModule
2from oeqa.utils.decorators import *
3from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
4
5def setUpModule():
6 if not oeRuntimeTest.hasFeature("tools-sdk"):
7 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
8
9class BuildIptablesTest(oeRuntimeTest):
10
11 @classmethod
12 def setUpClass(self):
13 dl_dir = oeRuntimeTest.tc.d.getVar('DL_DIR', True)
14 self.project = TargetBuildProject(oeRuntimeTest.tc.target,
15 "http://downloads.yoctoproject.org/mirror/sources/iptables-1.4.13.tar.bz2",
16 dl_dir=dl_dir)
17 self.project.download_archive()
18
19 @testcase(206)
20 @skipUnlessPassed("test_ssh")
21 def test_iptables(self):
22 self.assertEqual(self.project.run_configure(), 0,
23 msg="Running configure failed")
24
25 self.assertEqual(self.project.run_make(), 0,
26 msg="Running make failed")
27
28 self.assertEqual(self.project.run_install(), 0,
29 msg="Running make install failed")
30
31 @classmethod
32 def tearDownClass(self):
33 self.project.clean()
diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py
deleted file mode 100644
index 003fefe2ce..0000000000
--- a/meta/lib/oeqa/runtime/connman.py
+++ /dev/null
@@ -1,31 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not oeRuntimeTest.hasPackage("connman"):
7 skipModule("No connman package in image")
8
9
10class ConnmanTest(oeRuntimeTest):
11
12 def service_status(self, service):
13 if oeRuntimeTest.hasFeature("systemd"):
14 (status, output) = self.target.run('systemctl status -l %s' % service)
15 return output
16 else:
17 return "Unable to get status or logs for %s" % service
18
19 @testcase(961)
20 @skipUnlessPassed('test_ssh')
21 def test_connmand_help(self):
22 (status, output) = self.target.run('/usr/sbin/connmand --help')
23 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
24
25 @testcase(221)
26 @skipUnlessPassed('test_connmand_help')
27 def test_connmand_running(self):
28 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand')
29 if status != 0:
30 print(self.service_status("connman"))
31 self.fail("No connmand process running")
diff --git a/meta/lib/oeqa/runtime/date.py b/meta/lib/oeqa/runtime/date.py
deleted file mode 100644
index 6f3516a92f..0000000000
--- a/meta/lib/oeqa/runtime/date.py
+++ /dev/null
@@ -1,31 +0,0 @@
1from oeqa.oetest import oeRuntimeTest
2from oeqa.utils.decorators import *
3import re
4
5class DateTest(oeRuntimeTest):
6
7 def setUpLocal(self):
8 if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager") == "systemd":
9 self.target.run('systemctl stop systemd-timesyncd')
10
11 def tearDownLocal(self):
12 if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager") == "systemd":
13 self.target.run('systemctl start systemd-timesyncd')
14
15 @testcase(211)
16 @skipUnlessPassed("test_ssh")
17 def test_date(self):
18 (status, output) = self.target.run('date +"%Y-%m-%d %T"')
19 self.assertEqual(status, 0, msg="Failed to get initial date, output: %s" % output)
20 oldDate = output
21
22 sampleDate = '"2016-08-09 10:00:00"'
23 (status, output) = self.target.run("date -s %s" % sampleDate)
24 self.assertEqual(status, 0, msg="Date set failed, output: %s" % output)
25
26 (status, output) = self.target.run("date -R")
27 p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
28 self.assertTrue(p, msg="The date was not set correctly, output: %s" % output)
29
30 (status, output) = self.target.run('date -s "%s"' % oldDate)
31 self.assertEqual(status, 0, msg="Failed to reset date, output: %s" % output)
diff --git a/meta/lib/oeqa/runtime/df.py b/meta/lib/oeqa/runtime/df.py
deleted file mode 100644
index 09569d5ff6..0000000000
--- a/meta/lib/oeqa/runtime/df.py
+++ /dev/null
@@ -1,12 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest
3from oeqa.utils.decorators import *
4
5
6class DfTest(oeRuntimeTest):
7
8 @testcase(234)
9 @skipUnlessPassed("test_ssh")
10 def test_df(self):
11 (status,output) = self.target.run("df / | sed -n '2p' | awk '{print $4}'")
12 self.assertTrue(int(output)>5120, msg="Not enough space on image. Current size is %s" % output)
diff --git a/meta/lib/oeqa/runtime/files/hellomod.c b/meta/lib/oeqa/runtime/files/hellomod.c
deleted file mode 100644
index a383397e93..0000000000
--- a/meta/lib/oeqa/runtime/files/hellomod.c
+++ /dev/null
@@ -1,19 +0,0 @@
1#include <linux/module.h>
2#include <linux/kernel.h>
3#include <linux/init.h>
4
5static int __init hello_init(void)
6{
7 printk(KERN_INFO "Hello world!\n");
8 return 0;
9}
10
11static void __exit hello_cleanup(void)
12{
13 printk(KERN_INFO "Cleaning up hellomod.\n");
14}
15
16module_init(hello_init);
17module_exit(hello_cleanup);
18
19MODULE_LICENSE("GPL");
diff --git a/meta/lib/oeqa/runtime/files/hellomod_makefile b/meta/lib/oeqa/runtime/files/hellomod_makefile
deleted file mode 100644
index b92d5c8fe0..0000000000
--- a/meta/lib/oeqa/runtime/files/hellomod_makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1obj-m := hellomod.o
2KDIR := /usr/src/kernel
3
4all:
5 $(MAKE) -C $(KDIR) M=$(PWD) modules
6
7clean:
8 $(MAKE) -C $(KDIR) M=$(PWD) clean
diff --git a/meta/lib/oeqa/runtime/files/testmakefile b/meta/lib/oeqa/runtime/files/testmakefile
deleted file mode 100644
index ca1844e930..0000000000
--- a/meta/lib/oeqa/runtime/files/testmakefile
+++ /dev/null
@@ -1,5 +0,0 @@
1test: test.o
2 gcc -o test test.o -lm
3test.o: test.c
4 gcc -c test.c
5
diff --git a/meta/lib/oeqa/runtime/gcc.py b/meta/lib/oeqa/runtime/gcc.py
deleted file mode 100644
index 6edb89f6f2..0000000000
--- a/meta/lib/oeqa/runtime/gcc.py
+++ /dev/null
@@ -1,47 +0,0 @@
1import unittest
2import os
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasFeature("tools-sdk"):
8 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
9
10
11class GccCompileTest(oeRuntimeTest):
12
13 @classmethod
14 def setUpClass(self):
15 oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.corefilesdir, "test.c"), "/tmp/test.c")
16 oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "testmakefile"), "/tmp/testmakefile")
17 oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.corefilesdir, "test.cpp"), "/tmp/test.cpp")
18
19 @testcase(203)
20 def test_gcc_compile(self):
21 (status, output) = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
22 self.assertEqual(status, 0, msg="gcc compile failed, output: %s" % output)
23 (status, output) = self.target.run('/tmp/test')
24 self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
25
26 @testcase(200)
27 def test_gpp_compile(self):
28 (status, output) = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
29 self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output)
30 (status, output) = self.target.run('/tmp/test')
31 self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
32
33 @testcase(1142)
34 def test_gpp2_compile(self):
35 (status, output) = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
36 self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output)
37 (status, output) = self.target.run('/tmp/test')
38 self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
39
40 @testcase(204)
41 def test_make(self):
42 (status, output) = self.target.run('cd /tmp; make -f testmakefile')
43 self.assertEqual(status, 0, msg="running make failed, output %s" % output)
44
45 @classmethod
46 def tearDownClass(self):
47 oeRuntimeTest.tc.target.run("rm /tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile")
diff --git a/meta/lib/oeqa/runtime/kernelmodule.py b/meta/lib/oeqa/runtime/kernelmodule.py
deleted file mode 100644
index 2ac1bc93d4..0000000000
--- a/meta/lib/oeqa/runtime/kernelmodule.py
+++ /dev/null
@@ -1,34 +0,0 @@
1import unittest
2import os
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasFeature("tools-sdk"):
8 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
9
10
11class KernelModuleTest(oeRuntimeTest):
12
13 def setUpLocal(self):
14 self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod.c"), "/tmp/hellomod.c")
15 self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod_makefile"), "/tmp/Makefile")
16
17 @testcase('1541')
18 @skipUnlessPassed('test_ssh')
19 @skipUnlessPassed('test_gcc_compile')
20 def test_kernel_module(self):
21 cmds = [
22 'cd /usr/src/kernel && make scripts',
23 'cd /tmp && make',
24 'cd /tmp && insmod hellomod.ko',
25 'lsmod | grep hellomod',
26 'dmesg | grep Hello',
27 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"'
28 ]
29 for cmd in cmds:
30 (status, output) = self.target.run(cmd, 900)
31 self.assertEqual(status, 0, msg="\n".join([cmd, output]))
32
33 def tearDownLocal(self):
34 self.target.run('rm -f /tmp/Makefile /tmp/hellomod.c')
diff --git a/meta/lib/oeqa/runtime/ldd.py b/meta/lib/oeqa/runtime/ldd.py
deleted file mode 100644
index 47b3885df2..0000000000
--- a/meta/lib/oeqa/runtime/ldd.py
+++ /dev/null
@@ -1,21 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not oeRuntimeTest.hasFeature("tools-sdk"):
7 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
8
9class LddTest(oeRuntimeTest):
10
11 @testcase(962)
12 @skipUnlessPassed('test_ssh')
13 def test_ldd_exists(self):
14 (status, output) = self.target.run('which ldd')
15 self.assertEqual(status, 0, msg = "ldd does not exist in PATH: which ldd: %s" % output)
16
17 @testcase(239)
18 @skipUnlessPassed('test_ldd_exists')
19 def test_ldd_rtldlist_check(self):
20 (status, output) = self.target.run('for i in $(which ldd | xargs cat | grep "^RTLDLIST"|cut -d\'=\' -f2|tr -d \'"\'); do test -f $i && echo $i && break; done')
21 self.assertEqual(status, 0, msg = "ldd path not correct or RTLDLIST files don't exist. ")
diff --git a/meta/lib/oeqa/runtime/logrotate.py b/meta/lib/oeqa/runtime/logrotate.py
deleted file mode 100644
index 063280b5f7..0000000000
--- a/meta/lib/oeqa/runtime/logrotate.py
+++ /dev/null
@@ -1,30 +0,0 @@
1# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=289 testcase
2# Note that the image under test must have logrotate installed
3
4import unittest
5from oeqa.oetest import oeRuntimeTest, skipModule
6from oeqa.utils.decorators import *
7
8def setUpModule():
9 if not oeRuntimeTest.hasPackage("logrotate"):
10 skipModule("No logrotate package in image")
11
12
13class LogrotateTest(oeRuntimeTest):
14
15 @testcase(1544)
16 @skipUnlessPassed("test_ssh")
17 def test_1_logrotate_setup(self):
18 (status, output) = self.target.run('mkdir $HOME/logrotate_dir')
19 self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output)
20 (status, output) = self.target.run("sed -i \"s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#\" /etc/logrotate.conf")
21 self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output))
22
23 @testcase(1542)
24 @skipUnlessPassed("test_1_logrotate_setup")
25 def test_2_logrotate(self):
26 (status, output) = self.target.run('logrotate -f /etc/logrotate.conf')
27 self.assertEqual(status, 0, msg = "logrotate service could not be reloaded. Status and output: %s and %s" % (status, output))
28 output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')[1]
29 self.assertTrue(int(output)>=3, msg = "new logfile could not be created. List of files within log directory: %s" %(self.target.run('ls -la $HOME/logrotate_dir')[1]))
30 self.target.run('rm -rf $HOME/logrotate_dir')
diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py
deleted file mode 100644
index 5cce24f5f4..0000000000
--- a/meta/lib/oeqa/runtime/multilib.py
+++ /dev/null
@@ -1,42 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 multilibs = oeRuntimeTest.tc.d.getVar("MULTILIBS") or ""
7 if "multilib:lib32" not in multilibs:
8 skipModule("this isn't a multilib:lib32 image")
9
10
11class MultilibTest(oeRuntimeTest):
12
13 def archtest(self, binary, arch):
14 """
15 Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
16 """
17
18 (status, output) = self.target.run("readelf -h %s" % binary)
19 self.assertEqual(status, 0, "Failed to readelf %s" % binary)
20
21 l = [l.split()[1] for l in output.split('\n') if "Class:" in l]
22 if l:
23 theclass = l[0]
24 else:
25 self.fail("Cannot parse readelf output\n" + s)
26
27 self.assertEqual(theclass, arch, msg="%s isn't %s (is %s)" % (binary, arch, theclass))
28
29 @skipUnlessPassed('test_ssh')
30 def test_check_multilib_libc(self):
31 """
32 Check that a multilib image has both 32-bit and 64-bit libc in.
33 """
34 self.archtest("/lib/libc.so.6", "ELF32")
35 self.archtest("/lib64/libc.so.6", "ELF64")
36
37 @testcase('279')
38 @skipUnlessPassed('test_check_multilib_libc')
39 def test_file_connman(self):
40 self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed")
41
42 self.archtest("/usr/sbin/connmand", "ELF32")
diff --git a/meta/lib/oeqa/runtime/pam.py b/meta/lib/oeqa/runtime/pam.py
deleted file mode 100644
index b7f2dfa49b..0000000000
--- a/meta/lib/oeqa/runtime/pam.py
+++ /dev/null
@@ -1,25 +0,0 @@
1# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=287 testcase
2# Note that the image under test must have "pam" in DISTRO_FEATURES
3
4import unittest
5from oeqa.oetest import oeRuntimeTest, skipModule
6from oeqa.utils.decorators import *
7
8def setUpModule():
9 if not oeRuntimeTest.hasFeature("pam"):
10 skipModule("target doesn't have 'pam' in DISTRO_FEATURES")
11
12
13class PamBasicTest(oeRuntimeTest):
14
15 @testcase(1543)
16 @skipUnlessPassed('test_ssh')
17 def test_pam(self):
18 (status, output) = self.target.run('login --help')
19 self.assertEqual(status, 1, msg = "login command does not work as expected. Status and output:%s and %s" %(status, output))
20 (status, output) = self.target.run('passwd --help')
21 self.assertEqual(status, 0, msg = "passwd command does not work as expected. Status and output:%s and %s" %(status, output))
22 (status, output) = self.target.run('su --help')
23 self.assertEqual(status, 0, msg = "su command does not work as expected. Status and output:%s and %s" %(status, output))
24 (status, output) = self.target.run('useradd --help')
25 self.assertEqual(status, 0, msg = "useradd command does not work as expected. Status and output:%s and %s" %(status, output))
diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py
deleted file mode 100644
index cc2d0617f5..0000000000
--- a/meta/lib/oeqa/runtime/parselogs.py
+++ /dev/null
@@ -1,325 +0,0 @@
1import os
2import unittest
3import subprocess
4from oeqa.oetest import oeRuntimeTest
5from oeqa.utils.decorators import *
6
7#in the future these lists could be moved outside of module
8errors = ["error", "cannot", "can\'t", "failed"]
9
10common_errors = [
11 "(WW) warning, (EE) error, (NI) not implemented, (??) unknown.",
12 "dma timeout",
13 "can\'t add hid device:",
14 "usbhid: probe of ",
15 "_OSC failed (AE_ERROR)",
16 "_OSC failed (AE_SUPPORT)",
17 "AE_ALREADY_EXISTS",
18 "ACPI _OSC request failed (AE_SUPPORT)",
19 "can\'t disable ASPM",
20 "Failed to load module \"vesa\"",
21 "Failed to load module vesa",
22 "Failed to load module \"modesetting\"",
23 "Failed to load module modesetting",
24 "Failed to load module \"glx\"",
25 "Failed to load module \"fbdev\"",
26 "Failed to load module fbdev",
27 "Failed to load module glx",
28 "[drm] Cannot find any crtc or sizes - going 1024x768",
29 "_OSC failed (AE_NOT_FOUND); disabling ASPM",
30 "Open ACPI failed (/var/run/acpid.socket) (No such file or directory)",
31 "NX (Execute Disable) protection cannot be enabled: non-PAE kernel!",
32 "hd.: possibly failed opcode",
33 'NETLINK INITIALIZATION FAILED',
34 'kernel: Cannot find map file',
35 'omap_hwmod: debugss: _wait_target_disable failed',
36 'VGA arbiter: cannot open kernel arbiter, no multi-card support',
37 'Failed to find URL:http://ipv4.connman.net/online/status.html',
38 'Online check failed for',
39 'netlink init failed',
40 'Fast TSC calibration',
41 "BAR 0-9",
42 "Failed to load module \"ati\"",
43 "controller can't do DEVSLP, turning off",
44 "stmmac_dvr_probe: warning: cannot get CSR clock",
45 "error: couldn\'t mount because of unsupported optional features",
46 "GPT: Use GNU Parted to correct GPT errors",
47 ]
48
49video_related = [
50 "uvesafb",
51]
52
53x86_common = [
54 '[drm:psb_do_init] *ERROR* Debug is',
55 'wrong ELF class',
56 'Could not enable PowerButton event',
57 'probe of LNXPWRBN:00 failed with error -22',
58 'pmd_set_huge: Cannot satisfy',
59 'failed to setup card detect gpio',
60 'amd_nb: Cannot enumerate AMD northbridges',
61 'failed to retrieve link info, disabling eDP',
62 'Direct firmware load for iwlwifi',
63] + common_errors
64
65qemux86_common = [
66 'wrong ELF class',
67 "fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
68 "can't claim BAR ",
69 'amd_nb: Cannot enumerate AMD northbridges',
70 'uvesafb: 5000 ms task timeout, infinitely waiting',
71 'tsc: HPET/PMTIMER calibration failed',
72] + common_errors
73
74ignore_errors = {
75 'default' : common_errors,
76 'qemux86' : [
77 'Failed to access perfctr msr (MSR',
78 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
79 ] + qemux86_common,
80 'qemux86-64' : qemux86_common,
81 'qemumips' : [
82 'Failed to load module "glx"',
83 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
84 ] + common_errors,
85 'qemumips64' : [
86 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
87 ] + common_errors,
88 'qemuppc' : [
89 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]',
90 'host side 80-wire cable detection failed, limiting max speed',
91 'mode "640x480" test failed',
92 'Failed to load module "glx"',
93 'can\'t handle BAR above 4GB',
94 'Cannot reserve Legacy IO',
95 ] + common_errors,
96 'qemuarm' : [
97 'mmci-pl18x: probe of fpga:05 failed with error -22',
98 'mmci-pl18x: probe of fpga:0b failed with error -22',
99 'Failed to load module "glx"',
100 'OF: amba_device_add() failed (-19) for /amba/smc@10100000',
101 'OF: amba_device_add() failed (-19) for /amba/mpmc@10110000',
102 'OF: amba_device_add() failed (-19) for /amba/sctl@101e0000',
103 'OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000',
104 'OF: amba_device_add() failed (-19) for /amba/sci@101f0000',
105 'OF: amba_device_add() failed (-19) for /amba/ssp@101f4000',
106 'OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000',
107 'Failed to initialize \'/amba/timer@101e3000\': -22',
108 'jitterentropy: Initialization failed with host not compliant with requirements: 2',
109 ] + common_errors,
110 'qemuarm64' : [
111 'Fatal server error:',
112 '(EE) Server terminated with error (1). Closing log file.',
113 'dmi: Firmware registration failed.',
114 'irq: type mismatch, failed to map hwirq-27 for /intc',
115 ] + common_errors,
116 'emenlow' : [
117 '[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
118 '(EE) Failed to load module "psb"',
119 '(EE) Failed to load module psb',
120 '(EE) Failed to load module "psbdrv"',
121 '(EE) Failed to load module psbdrv',
122 '(EE) open /dev/fb0: No such file or directory',
123 '(EE) AIGLX: reverting to software rendering',
124 ] + x86_common,
125 'intel-core2-32' : [
126 'ACPI: No _BQC method, cannot determine initial brightness',
127 '[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
128 '(EE) Failed to load module "psb"',
129 '(EE) Failed to load module psb',
130 '(EE) Failed to load module "psbdrv"',
131 '(EE) Failed to load module psbdrv',
132 '(EE) open /dev/fb0: No such file or directory',
133 '(EE) AIGLX: reverting to software rendering',
134 'dmi: Firmware registration failed.',
135 'ioremap error for 0x78',
136 ] + x86_common,
137 'intel-corei7-64' : [
138 'can\'t set Max Payload Size to 256',
139 'intel_punit_ipc: can\'t request region for resource',
140 '[drm] parse error at position 4 in video mode \'efifb\'',
141 'ACPI Error: Could not enable RealTimeClock event',
142 'ACPI Warning: Could not enable fixed event - RealTimeClock',
143 'hci_intel INT33E1:00: Unable to retrieve gpio',
144 'hci_intel: probe of INT33E1:00 failed',
145 'can\'t derive routing for PCI INT A',
146 'failed to read out thermal zone',
147 'Bluetooth: hci0: Setting Intel event mask failed',
148 'ttyS2 - failed to request DMA',
149 ] + x86_common,
150 'crownbay' : x86_common,
151 'genericx86' : x86_common,
152 'genericx86-64' : [
153 'Direct firmware load for i915',
154 'Failed to load firmware i915',
155 'Failed to fetch GuC',
156 'Failed to initialize GuC',
157 'Failed to load DMC firmware',
158 'The driver is built-in, so to load the firmware you need to',
159 ] + x86_common,
160 'edgerouter' : [
161 'Fatal server error:',
162 ] + common_errors,
163 'jasperforest' : [
164 'Activated service \'org.bluez\' failed:',
165 'Unable to find NFC netlink family',
166 ] + common_errors,
167}
168
169log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"]
170
171class ParseLogsTest(oeRuntimeTest):
172
173 @classmethod
174 def setUpClass(self):
175 self.errors = errors
176
177 # When systemd is enabled we need to notice errors on
178 # circular dependencies in units.
179 if self.hasFeature("systemd"):
180 self.errors.extend([
181 'Found ordering cycle on',
182 'Breaking ordering cycle by deleting job',
183 'deleted to break ordering cycle',
184 'Ordering cycle found, skipping',
185 ])
186
187 self.ignore_errors = ignore_errors
188 self.log_locations = log_locations
189 self.msg = ""
190 (is_lsb, location) = oeRuntimeTest.tc.target.run("which LSB_Test.sh")
191 if is_lsb == 0:
192 for machine in self.ignore_errors:
193 self.ignore_errors[machine] = self.ignore_errors[machine] + video_related
194
195 def getMachine(self):
196 return oeRuntimeTest.tc.d.getVar("MACHINE")
197
198 def getWorkdir(self):
199 return oeRuntimeTest.tc.d.getVar("WORKDIR")
200
201 #get some information on the CPU of the machine to display at the beginning of the output. This info might be useful in some cases.
202 def getHardwareInfo(self):
203 hwi = ""
204 (status, cpu_name) = self.target.run("cat /proc/cpuinfo | grep \"model name\" | head -n1 | awk 'BEGIN{FS=\":\"}{print $2}'")
205 (status, cpu_physical_cores) = self.target.run("cat /proc/cpuinfo | grep \"cpu cores\" | head -n1 | awk {'print $4'}")
206 (status, cpu_logical_cores) = self.target.run("cat /proc/cpuinfo | grep \"processor\" | wc -l")
207 (status, cpu_arch) = self.target.run("uname -m")
208 hwi += "Machine information: \n"
209 hwi += "*******************************\n"
210 hwi += "Machine name: "+self.getMachine()+"\n"
211 hwi += "CPU: "+str(cpu_name)+"\n"
212 hwi += "Arch: "+str(cpu_arch)+"\n"
213 hwi += "Physical cores: "+str(cpu_physical_cores)+"\n"
214 hwi += "Logical cores: "+str(cpu_logical_cores)+"\n"
215 hwi += "*******************************\n"
216 return hwi
217
218 #go through the log locations provided and if it's a folder create a list with all the .log files in it, if it's a file just add
219 #it to that list
220 def getLogList(self, log_locations):
221 logs = []
222 for location in log_locations:
223 (status, output) = self.target.run("test -f "+str(location))
224 if (status == 0):
225 logs.append(str(location))
226 else:
227 (status, output) = self.target.run("test -d "+str(location))
228 if (status == 0):
229 (status, output) = self.target.run("find "+str(location)+"/*.log -maxdepth 1 -type f")
230 if (status == 0):
231 output = output.splitlines()
232 for logfile in output:
233 logs.append(os.path.join(location,str(logfile)))
234 return logs
235
236 #copy the log files to be parsed locally
237 def transfer_logs(self, log_list):
238 workdir = self.getWorkdir()
239 self.target_logs = workdir + '/' + 'target_logs'
240 target_logs = self.target_logs
241 if not os.path.exists(target_logs):
242 os.makedirs(target_logs)
243 bb.utils.remove(self.target_logs + "/*")
244 for f in log_list:
245 self.target.copy_from(f, target_logs)
246
247 #get the local list of logs
248 def get_local_log_list(self, log_locations):
249 self.transfer_logs(self.getLogList(log_locations))
250 logs = [ os.path.join(self.target_logs, f) for f in os.listdir(self.target_logs) if os.path.isfile(os.path.join(self.target_logs, f)) ]
251 return logs
252
253 #build the grep command to be used with filters and exclusions
254 def build_grepcmd(self, errors, ignore_errors, log):
255 grepcmd = "grep "
256 grepcmd +="-Ei \""
257 for error in errors:
258 grepcmd += error+"|"
259 grepcmd = grepcmd[:-1]
260 grepcmd += "\" "+str(log)+" | grep -Eiv \'"
261 try:
262 errorlist = ignore_errors[self.getMachine()]
263 except KeyError:
264 self.msg += "No ignore list found for this machine, using default\n"
265 errorlist = ignore_errors['default']
266 for ignore_error in errorlist:
267 ignore_error = ignore_error.replace("(", "\(")
268 ignore_error = ignore_error.replace(")", "\)")
269 ignore_error = ignore_error.replace("'", ".")
270 ignore_error = ignore_error.replace("?", "\?")
271 ignore_error = ignore_error.replace("[", "\[")
272 ignore_error = ignore_error.replace("]", "\]")
273 ignore_error = ignore_error.replace("*", "\*")
274 ignore_error = ignore_error.replace("0-9", "[0-9]")
275 grepcmd += ignore_error+"|"
276 grepcmd = grepcmd[:-1]
277 grepcmd += "\'"
278 return grepcmd
279
280 #grep only the errors so that their context could be collected. Default context is 10 lines before and after the error itself
281 def parse_logs(self, errors, ignore_errors, logs, lines_before = 10, lines_after = 10):
282 results = {}
283 rez = []
284 grep_output = ''
285 for log in logs:
286 result = None
287 thegrep = self.build_grepcmd(errors, ignore_errors, log)
288 try:
289 result = subprocess.check_output(thegrep, shell=True).decode("utf-8")
290 except:
291 pass
292 if (result is not None):
293 results[log.replace('target_logs/','')] = {}
294 rez = result.splitlines()
295 for xrez in rez:
296 try:
297 grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]).decode("utf-8")
298 except:
299 pass
300 results[log.replace('target_logs/','')][xrez]=grep_output
301 return results
302
303 #get the output of dmesg and write it in a file. This file is added to log_locations.
304 def write_dmesg(self):
305 (status, dmesg) = self.target.run("dmesg > /tmp/dmesg_output.log")
306
307 @testcase(1059)
308 @skipUnlessPassed('test_ssh')
309 def test_parselogs(self):
310 self.write_dmesg()
311 log_list = self.get_local_log_list(self.log_locations)
312 result = self.parse_logs(self.errors, self.ignore_errors, log_list)
313 print(self.getHardwareInfo())
314 errcount = 0
315 for log in result:
316 self.msg += "Log: "+log+"\n"
317 self.msg += "-----------------------\n"
318 for error in result[log]:
319 errcount += 1
320 self.msg += "Central error: "+str(error)+"\n"
321 self.msg += "***********************\n"
322 self.msg += result[str(log)][str(error)]+"\n"
323 self.msg += "***********************\n"
324 self.msg += "%s errors found in logs." % errcount
325 self.assertEqual(errcount, 0, msg=self.msg)
diff --git a/meta/lib/oeqa/runtime/perl.py b/meta/lib/oeqa/runtime/perl.py
deleted file mode 100644
index 6bf98f1ccb..0000000000
--- a/meta/lib/oeqa/runtime/perl.py
+++ /dev/null
@@ -1,30 +0,0 @@
1import unittest
2import os
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasPackage("perl"):
8 skipModule("No perl package in the image")
9
10
11class PerlTest(oeRuntimeTest):
12
13 @classmethod
14 def setUpClass(self):
15 oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.corefilesdir, "test.pl"), "/tmp/test.pl")
16
17 @testcase(1141)
18 def test_perl_exists(self):
19 (status, output) = self.target.run('which perl')
20 self.assertEqual(status, 0, msg="Perl binary not in PATH or not on target.")
21
22 @testcase(208)
23 def test_perl_works(self):
24 (status, output) = self.target.run('perl /tmp/test.pl')
25 self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output)
26 self.assertEqual(output, "the value of a is 0.01", msg="Incorrect output: %s" % output)
27
28 @classmethod
29 def tearDownClass(self):
30 oeRuntimeTest.tc.target.run("rm /tmp/test.pl")
diff --git a/meta/lib/oeqa/runtime/ping.py b/meta/lib/oeqa/runtime/ping.py
deleted file mode 100644
index 0f27447926..0000000000
--- a/meta/lib/oeqa/runtime/ping.py
+++ /dev/null
@@ -1,22 +0,0 @@
1import subprocess
2import unittest
3import sys
4import time
5from oeqa.oetest import oeRuntimeTest
6from oeqa.utils.decorators import *
7
8class PingTest(oeRuntimeTest):
9
10 @testcase(964)
11 def test_ping(self):
12 output = ''
13 count = 0
14 endtime = time.time() + 60
15 while count < 5 and time.time() < endtime:
16 proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE)
17 output += proc.communicate()[0].decode("utf-8")
18 if proc.poll() == 0:
19 count += 1
20 else:
21 count = 0
22 self.assertEqual(count, 5, msg = "Expected 5 consecutive replies, got %d.\nping output is:\n%s" % (count,output))
diff --git a/meta/lib/oeqa/runtime/python.py b/meta/lib/oeqa/runtime/python.py
deleted file mode 100644
index 93e822c71c..0000000000
--- a/meta/lib/oeqa/runtime/python.py
+++ /dev/null
@@ -1,35 +0,0 @@
1import unittest
2import os
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasPackage("python-core"):
8 skipModule("No python package in the image")
9
10
11class PythonTest(oeRuntimeTest):
12
13 @classmethod
14 def setUpClass(self):
15 oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.corefilesdir, "test.py"), "/tmp/test.py")
16
17 @testcase(1145)
18 def test_python_exists(self):
19 (status, output) = self.target.run('which python')
20 self.assertEqual(status, 0, msg="Python binary not in PATH or not on target.")
21
22 @testcase(965)
23 def test_python_stdout(self):
24 (status, output) = self.target.run('python /tmp/test.py')
25 self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output)
26 self.assertEqual(output, "the value of a is 0.01", msg="Incorrect output: %s" % output)
27
28 @testcase(1146)
29 def test_python_testfile(self):
30 (status, output) = self.target.run('ls /tmp/testfile.python')
31 self.assertEqual(status, 0, msg="Python test file generate failed.")
32
33 @classmethod
34 def tearDownClass(self):
35 oeRuntimeTest.tc.target.run("rm /tmp/test.py /tmp/testfile.python")
diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py
deleted file mode 100644
index f1c4763fc0..0000000000
--- a/meta/lib/oeqa/runtime/rpm.py
+++ /dev/null
@@ -1,120 +0,0 @@
1import unittest
2import os
3import fnmatch
4from oeqa.oetest import oeRuntimeTest, skipModule
5from oeqa.utils.decorators import *
6
7def setUpModule():
8 if not oeRuntimeTest.hasFeature("package-management"):
9 skipModule("rpm module skipped: target doesn't have package-management in IMAGE_FEATURES")
10 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES").split()[0]:
11 skipModule("rpm module skipped: target doesn't have rpm as primary package manager")
12
13
14class RpmBasicTest(oeRuntimeTest):
15
16 @testcase(960)
17 @skipUnlessPassed('test_ssh')
18 def test_rpm_help(self):
19 (status, output) = self.target.run('rpm --help')
20 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
21
22 @testcase(191)
23 @skipUnlessPassed('test_rpm_help')
24 def test_rpm_query(self):
25 (status, output) = self.target.run('rpm -q rpm')
26 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
27
28class RpmInstallRemoveTest(oeRuntimeTest):
29
30 @classmethod
31 def setUpClass(self):
32 pkgarch = oeRuntimeTest.tc.d.getVar('TUNE_PKGARCH').replace("-", "_")
33 rpmdir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR'), "rpm", pkgarch)
34 # pick rpm-doc as a test file to get installed, because it's small and it will always be built for standard targets
35 for f in fnmatch.filter(os.listdir(rpmdir), "rpm-doc-*.%s.rpm" % pkgarch):
36 testrpmfile = f
37 oeRuntimeTest.tc.target.copy_to(os.path.join(rpmdir,testrpmfile), "/tmp/rpm-doc.rpm")
38
39 @testcase(192)
40 @skipUnlessPassed('test_rpm_help')
41 def test_rpm_install(self):
42 (status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
43 self.assertEqual(status, 0, msg="Failed to install rpm-doc package: %s" % output)
44
45 @testcase(194)
46 @skipUnlessPassed('test_rpm_install')
47 def test_rpm_remove(self):
48 (status,output) = self.target.run('rpm -e rpm-doc')
49 self.assertEqual(status, 0, msg="Failed to remove rpm-doc package: %s" % output)
50
51 @testcase(1096)
52 @skipUnlessPassed('test_ssh')
53 def test_rpm_query_nonroot(self):
54
55 def set_up_test_user(u):
56 (status, output) = self.target.run("id -u %s" % u)
57 if status == 0:
58 pass
59 else:
60 (status, output) = self.target.run("useradd %s" % u)
61 self.assertTrue(status == 0, msg="Failed to create new user: " + output)
62
63 def exec_as_test_user(u):
64 (status, output) = self.target.run("su -c id %s" % u)
65 self.assertTrue("({0})".format(u) in output, msg="Failed to execute as new user")
66 (status, output) = self.target.run("su -c \"rpm -qa\" %s " % u)
67 self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output))
68
69 def unset_up_test_user(u):
70 (status, output) = self.target.run("userdel -r %s" % u)
71 self.assertTrue(status == 0, msg="Failed to erase user: %s" % output)
72
73 tuser = 'test1'
74
75 try:
76 set_up_test_user(tuser)
77 exec_as_test_user(tuser)
78 finally:
79 unset_up_test_user(tuser)
80
81 @testcase(195)
82 @skipUnlessPassed('test_rpm_install')
83 def test_check_rpm_install_removal_log_file_size(self):
84 """
85 Summary: Check rpm install/removal log file size
86 Expected: There should be some method to keep rpm log in a small size .
87 Product: BSPs
88 Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
89 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
90 """
91 db_files_cmd = 'ls /var/lib/rpm/__db.*'
92 get_log_size_cmd = "du /var/lib/rpm/log/log.* | awk '{print $1}'"
93
94 # Make sure that some database files are under /var/lib/rpm as '__db.xxx'
95 (status, output) = self.target.run(db_files_cmd)
96 self.assertEqual(0, status, 'Failed to find database files under /var/lib/rpm/ as __db.xxx')
97
98 # Remove the package just in case
99 self.target.run('rpm -e rpm-doc')
100
101 # Install/Remove a package 10 times
102 for i in range(10):
103 (status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
104 self.assertEqual(0, status, "Failed to install rpm-doc package. Reason: {}".format(output))
105
106 (status, output) = self.target.run('rpm -e rpm-doc')
107 self.assertEqual(0, status, "Failed to remove rpm-doc package. Reason: {}".format(output))
108
109 # Get the size of log file
110 (status, output) = self.target.run(get_log_size_cmd)
111 self.assertEqual(0, status, 'Failed to get the final size of the log file.')
112
113 # Compare each log size
114 for log_file_size in output:
115 self.assertLessEqual(int(log_file_size), 11264,
116 'Log file size is greater that expected (~10MB), found {} bytes'.format(log_file_size))
117
118 @classmethod
119 def tearDownClass(self):
120 oeRuntimeTest.tc.target.run('rm -f /tmp/rpm-doc.rpm')
diff --git a/meta/lib/oeqa/runtime/scanelf.py b/meta/lib/oeqa/runtime/scanelf.py
deleted file mode 100644
index 67e02ff455..0000000000
--- a/meta/lib/oeqa/runtime/scanelf.py
+++ /dev/null
@@ -1,28 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not oeRuntimeTest.hasPackage("pax-utils"):
7 skipModule("pax-utils package not installed")
8
9class ScanelfTest(oeRuntimeTest):
10
11 def setUpLocal(self):
12 self.scancmd = 'scanelf --quiet --recursive --mount --ldpath --path'
13
14 @testcase(966)
15 @skipUnlessPassed('test_ssh')
16 def test_scanelf_textrel(self):
17 # print TEXTREL information
18 self.scancmd += " --textrel"
19 (status, output) = self.target.run(self.scancmd)
20 self.assertEqual(output.strip(), "", "\n".join([self.scancmd, output]))
21
22 @testcase(967)
23 @skipUnlessPassed('test_ssh')
24 def test_scanelf_rpath(self):
25 # print RPATH information
26 self.scancmd += " --rpath"
27 (status, output) = self.target.run(self.scancmd)
28 self.assertEqual(output.strip(), "", "\n".join([self.scancmd, output]))
diff --git a/meta/lib/oeqa/runtime/scp.py b/meta/lib/oeqa/runtime/scp.py
deleted file mode 100644
index cf36cfa5d5..0000000000
--- a/meta/lib/oeqa/runtime/scp.py
+++ /dev/null
@@ -1,22 +0,0 @@
1import os
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import skipUnlessPassed, testcase
4
5def setUpModule():
6 if not (oeRuntimeTest.hasPackage("dropbear") or oeRuntimeTest.hasPackage("openssh-sshd")):
7 skipModule("No ssh package in image")
8
9class ScpTest(oeRuntimeTest):
10
11 @testcase(220)
12 @skipUnlessPassed('test_ssh')
13 def test_scp_file(self):
14 test_log_dir = oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR")
15 test_file_path = os.path.join(test_log_dir, 'test_scp_file')
16 with open(test_file_path, 'w') as test_scp_file:
17 test_scp_file.seek(2 ** 22 - 1)
18 test_scp_file.write(os.linesep)
19 (status, output) = self.target.copy_to(test_file_path, '/tmp/test_scp_file')
20 self.assertEqual(status, 0, msg = "File could not be copied. Output: %s" % output)
21 (status, output) = self.target.run("ls -la /tmp/test_scp_file")
22 self.assertEqual(status, 0, msg = "SCP test failed")
diff --git a/meta/lib/oeqa/runtime/skeletoninit.py b/meta/lib/oeqa/runtime/skeletoninit.py
deleted file mode 100644
index cb0cb9b4cf..0000000000
--- a/meta/lib/oeqa/runtime/skeletoninit.py
+++ /dev/null
@@ -1,29 +0,0 @@
1# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=284 testcase
2# Note that the image under test must have meta-skeleton layer in bblayers and IMAGE_INSTALL_append = " service" in local.conf
3
4import unittest
5from oeqa.oetest import oeRuntimeTest, skipModule
6from oeqa.utils.decorators import *
7
8def setUpModule():
9 if not oeRuntimeTest.hasPackage("service"):
10 skipModule("No service package in image")
11
12
13class SkeletonBasicTest(oeRuntimeTest):
14
15 @skipUnlessPassed('test_ssh')
16 @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
17 def test_skeleton_availability(self):
18 (status, output) = self.target.run('ls /etc/init.d/skeleton')
19 self.assertEqual(status, 0, msg = "skeleton init script not found. Output:\n%s " % output)
20 (status, output) = self.target.run('ls /usr/sbin/skeleton-test')
21 self.assertEqual(status, 0, msg = "skeleton-test not found. Output:\n%s" % output)
22
23 @testcase(284)
24 @skipUnlessPassed('test_skeleton_availability')
25 @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
26 def test_skeleton_script(self):
27 output1 = self.target.run("/etc/init.d/skeleton start")[1]
28 (status, output2) = self.target.run(oeRuntimeTest.pscmd + ' | grep [s]keleton-test')
29 self.assertEqual(status, 0, msg = "Skeleton script could not be started:\n%s\n%s" % (output1, output2))
diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py
deleted file mode 100644
index dde1c4d792..0000000000
--- a/meta/lib/oeqa/runtime/smart.py
+++ /dev/null
@@ -1,218 +0,0 @@
1import unittest
2import re
3import oe
4import subprocess
5from oeqa.oetest import oeRuntimeTest, skipModule
6from oeqa.utils.decorators import *
7from oeqa.utils.httpserver import HTTPService
8
9def setUpModule():
10 if not oeRuntimeTest.hasFeature("package-management"):
11 skipModule("Image doesn't have package management feature")
12 if not oeRuntimeTest.hasPackage("smartpm"):
13 skipModule("Image doesn't have smart installed")
14 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES").split()[0]:
15 skipModule("Rpm is not the primary package manager")
16
17class SmartTest(oeRuntimeTest):
18
19 @skipUnlessPassed('test_smart_help')
20 def smart(self, command, expected = 0):
21 command = 'smart %s' % command
22 status, output = self.target.run(command, 1500)
23 message = os.linesep.join([command, output])
24 self.assertEqual(status, expected, message)
25 self.assertFalse("Cannot allocate memory" in output, message)
26 return output
27
28class SmartBasicTest(SmartTest):
29
30 @testcase(716)
31 @skipUnlessPassed('test_ssh')
32 def test_smart_help(self):
33 self.smart('--help')
34
35 @testcase(968)
36 def test_smart_version(self):
37 self.smart('--version')
38
39 @testcase(721)
40 def test_smart_info(self):
41 self.smart('info python-smartpm')
42
43 @testcase(421)
44 def test_smart_query(self):
45 self.smart('query python-smartpm')
46
47 @testcase(720)
48 def test_smart_search(self):
49 self.smart('search python-smartpm')
50
51 @testcase(722)
52 def test_smart_stats(self):
53 self.smart('stats')
54
55class SmartRepoTest(SmartTest):
56
57 @classmethod
58 def create_index(self, arg):
59 index_cmd = arg
60 try:
61 bb.note("Executing '%s' ..." % index_cmd)
62 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
63 except subprocess.CalledProcessError as e:
64 return("Index creation command '%s' failed with return code %d:\n%s" %
65 (e.cmd, e.returncode, e.output.decode("utf-8")))
66 if result:
67 bb.note(result)
68 return None
69
70 @classmethod
71 def setUpClass(self):
72 self.repolist = []
73
74 # Index RPMs
75 rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo")
76 index_cmds = []
77 rpm_dirs_found = False
78 archs = (oeRuntimeTest.tc.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS') or "").replace('-', '_').split()
79 for arch in archs:
80 rpm_dir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM'), arch)
81 idx_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'), 'rpm', arch)
82 db_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'), 'rpmdb', arch)
83 if not os.path.isdir(rpm_dir):
84 continue
85 if os.path.exists(db_path):
86 bb.utils.remove(dbpath, True)
87 lockfilename = oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM') + "/rpm.lock"
88 lf = bb.utils.lockfile(lockfilename, False)
89 oe.path.copyhardlinktree(rpm_dir, idx_path)
90 # Full indexes overload a 256MB image so reduce the number of rpms
91 # in the feed. Filter to p* since we use the psplash packages and
92 # this leaves some allarch and machine arch packages too.
93 bb.utils.remove(idx_path + "*/[a-oq-z]*.rpm")
94 bb.utils.unlockfile(lf)
95 index_cmds.append("%s --dbpath %s --update -q %s" % (rpm_createrepo, db_path, idx_path))
96 rpm_dirs_found = True
97 # Create repodata¬
98 result = oe.utils.multiprocess_exec(index_cmds, self.create_index)
99 if result:
100 bb.fatal('%s' % ('\n'.join(result)))
101 self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('WORKDIR'), oeRuntimeTest.tc.target.server_ip)
102 self.repo_server.start()
103
104 @classmethod
105 def tearDownClass(self):
106 self.repo_server.stop()
107 for i in self.repolist:
108 oeRuntimeTest.tc.target.run('smart channel -y --remove '+str(i))
109
110 @testcase(1143)
111 def test_smart_channel(self):
112 self.smart('channel', 1)
113
114 @testcase(719)
115 def test_smart_channel_add(self):
116 image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE')
117 deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
118 pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-","_").split()
119 for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
120 if arch in pkgarchs:
121 self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url))
122 self.repolist.append(arch)
123 self.smart('update')
124
125 @testcase(969)
126 def test_smart_channel_help(self):
127 self.smart('channel --help')
128
129 @testcase(970)
130 def test_smart_channel_list(self):
131 self.smart('channel --list')
132
133 @testcase(971)
134 def test_smart_channel_show(self):
135 self.smart('channel --show')
136
137 @testcase(717)
138 def test_smart_channel_rpmsys(self):
139 self.smart('channel --show rpmsys')
140 self.smart('channel --disable rpmsys')
141 self.smart('channel --enable rpmsys')
142
143 @testcase(1144)
144 @skipUnlessPassed('test_smart_channel_add')
145 def test_smart_install(self):
146 self.smart('remove -y psplash-default')
147 self.smart('install -y psplash-default')
148
149 @testcase(728)
150 @skipUnlessPassed('test_smart_install')
151 def test_smart_install_dependency(self):
152 self.smart('remove -y psplash')
153 self.smart('install -y psplash-default')
154
155 @testcase(723)
156 @skipUnlessPassed('test_smart_channel_add')
157 def test_smart_install_from_disk(self):
158 self.smart('remove -y psplash-default')
159 self.smart('download psplash-default')
160 self.smart('install -y ./psplash-default*')
161
162 @testcase(725)
163 @skipUnlessPassed('test_smart_channel_add')
164 def test_smart_install_from_http(self):
165 output = self.smart('download --urls psplash-default')
166 url = re.search('(http://.*/psplash-default.*\.rpm)', output)
167 self.assertTrue(url, msg="Couln't find download url in %s" % output)
168 self.smart('remove -y psplash-default')
169 self.smart('install -y %s' % url.group(0))
170
171 @testcase(729)
172 @skipUnlessPassed('test_smart_install')
173 def test_smart_reinstall(self):
174 self.smart('reinstall -y psplash-default')
175
176 @testcase(727)
177 @skipUnlessPassed('test_smart_channel_add')
178 def test_smart_remote_repo(self):
179 self.smart('update')
180 self.smart('install -y psplash')
181 self.smart('remove -y psplash')
182
183 @testcase(726)
184 def test_smart_local_dir(self):
185 self.target.run('mkdir /tmp/myrpmdir')
186 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
187 self.target.run('cd /tmp/myrpmdir')
188 self.smart('download psplash')
189 output = self.smart('channel --list')
190 for i in output.split("\n"):
191 if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
192 self.smart('channel --disable '+str(i))
193 self.target.run('cd $HOME')
194 self.smart('install psplash')
195 for i in output.split("\n"):
196 if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
197 self.smart('channel --enable '+str(i))
198 self.smart('channel --remove myrpmdir -y')
199 self.target.run("rm -rf /tmp/myrpmdir")
200
201 @testcase(718)
202 def test_smart_add_rpmdir(self):
203 self.target.run('mkdir /tmp/myrpmdir')
204 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
205 self.smart('channel --disable myrpmdir -y')
206 output = self.smart('channel --show myrpmdir')
207 self.assertTrue("disabled = yes" in output, msg="Failed to disable rpm dir")
208 self.smart('channel --enable myrpmdir -y')
209 output = self.smart('channel --show myrpmdir')
210 self.assertFalse("disabled = yes" in output, msg="Failed to enable rpm dir")
211 self.smart('channel --remove myrpmdir -y')
212 self.target.run("rm -rf /tmp/myrpmdir")
213
214 @testcase(731)
215 @skipUnlessPassed('test_smart_channel_add')
216 def test_smart_remove_package(self):
217 self.smart('install -y psplash')
218 self.smart('remove -y psplash')
diff --git a/meta/lib/oeqa/runtime/ssh.py b/meta/lib/oeqa/runtime/ssh.py
deleted file mode 100644
index 0e76d5d512..0000000000
--- a/meta/lib/oeqa/runtime/ssh.py
+++ /dev/null
@@ -1,19 +0,0 @@
1import subprocess
2import unittest
3import sys
4from oeqa.oetest import oeRuntimeTest, skipModule
5from oeqa.utils.decorators import *
6
7def setUpModule():
8 if not (oeRuntimeTest.hasPackage("dropbear") or oeRuntimeTest.hasPackage("openssh")):
9 skipModule("No ssh package in image")
10
11class SshTest(oeRuntimeTest):
12
13 @testcase(224)
14 @skipUnlessPassed('test_ping')
15 def test_ssh(self):
16 (status, output) = self.target.run('uname -a')
17 self.assertEqual(status, 0, msg="SSH Test failed: %s" % output)
18 (status, output) = self.target.run('cat /etc/masterimage')
19 self.assertEqual(status, 1, msg="This isn't the right image - /etc/masterimage shouldn't be here %s" % output)
diff --git a/meta/lib/oeqa/runtime/syslog.py b/meta/lib/oeqa/runtime/syslog.py
deleted file mode 100644
index 8f550329e7..0000000000
--- a/meta/lib/oeqa/runtime/syslog.py
+++ /dev/null
@@ -1,52 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not (oeRuntimeTest.hasPackage("busybox-syslog") or oeRuntimeTest.hasPackage("sysklogd")):
7 skipModule("No syslog package in image")
8
9class SyslogTest(oeRuntimeTest):
10
11 @testcase(201)
12 def test_syslog_running(self):
13 (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
14 self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
15
16class SyslogTestConfig(oeRuntimeTest):
17
18 @testcase(1149)
19 @skipUnlessPassed("test_syslog_running")
20 def test_syslog_logger(self):
21 (status, output) = self.target.run('logger foobar')
22 self.assertEqual(status, 0, msg="Can't log into syslog. Output: %s " % output)
23
24 (status, output) = self.target.run('grep foobar /var/log/messages')
25 if status != 0:
26 if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", "") == "systemd":
27 (status, output) = self.target.run('journalctl -o cat | grep foobar')
28 else:
29 (status, output) = self.target.run('logread | grep foobar')
30 self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages or logread. Output: %s " % output)
31
32 @testcase(1150)
33 @skipUnlessPassed("test_syslog_running")
34 def test_syslog_restart(self):
35 if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False):
36 (status,output) = self.target.run('/etc/init.d/syslog restart')
37 else:
38 (status,output) = self.target.run('systemctl restart syslog.service')
39
40 @testcase(202)
41 @skipUnlessPassed("test_syslog_restart")
42 @skipUnlessPassed("test_syslog_logger")
43 @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
44 @unittest.skipIf(oeRuntimeTest.hasPackage("sysklogd") or not oeRuntimeTest.hasPackage("busybox"), "Non-busybox syslog")
45 def test_syslog_startup_config(self):
46 self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
47 (status,output) = self.target.run('/etc/init.d/syslog restart')
48 self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
49 (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
50 self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
51 self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")
52 self.target.run('/etc/init.d/syslog restart')
diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py
deleted file mode 100644
index 52feb1b31e..0000000000
--- a/meta/lib/oeqa/runtime/systemd.py
+++ /dev/null
@@ -1,178 +0,0 @@
1import unittest
2import re
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasFeature("systemd"):
8 skipModule("target doesn't have systemd in DISTRO_FEATURES")
9 if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"):
10 skipModule("systemd is not the init manager for this image")
11
12
13class SystemdTest(oeRuntimeTest):
14
15 def systemctl(self, action = '', target = '', expected = 0, verbose = False):
16 command = 'systemctl %s %s' % (action, target)
17 status, output = self.target.run(command)
18 message = '\n'.join([command, output])
19 if status != expected and verbose:
20 message += self.target.run('systemctl status --full %s' % target)[1]
21 self.assertEqual(status, expected, message)
22 return output
23
24 #TODO: use pyjournalctl instead
25 def journalctl(self, args='',l_match_units=[]):
26 """
27 Request for the journalctl output to the current target system
28
29 Arguments:
30 -args, an optional argument pass through argument
31 -l_match_units, an optional list of units to filter the output
32 Returns:
33 -string output of the journalctl command
34 Raises:
35 -AssertionError, on remote commands that fail
36 -ValueError, on a journalctl call with filtering by l_match_units that
37 returned no entries
38 """
39 query_units=""
40 if len(l_match_units):
41 query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units]
42 query_units = " ".join(query_units)
43 command = 'journalctl %s %s' %(args, query_units)
44 status, output = self.target.run(command)
45 if status:
46 raise AssertionError("Command '%s' returned non-zero exit \
47 code %d:\n%s" % (command, status, output))
48 if len(output) == 1 and "-- No entries --" in output:
49 raise ValueError("List of units to match: %s, returned no entries"
50 % l_match_units)
51 return output
52
53class SystemdBasicTests(SystemdTest):
54
55 @skipUnlessPassed('test_ssh')
56 def test_systemd_basic(self):
57 self.systemctl('--version')
58
59 @testcase(551)
60 @skipUnlessPassed('test_systemd_basic')
61 def test_systemd_list(self):
62 self.systemctl('list-unit-files')
63
64 def settle(self):
65 """
66 Block until systemd has finished activating any units being activated,
67 or until two minutes has elapsed.
68
69 Returns a tuple, either (True, '') if all units have finished
70 activating, or (False, message string) if there are still units
71 activating (generally, failing units that restart).
72 """
73 import time
74 endtime = time.time() + (60 * 2)
75 while True:
76 status, output = self.target.run('systemctl --state=activating')
77 if "0 loaded units listed" in output:
78 return (True, '')
79 if time.time() >= endtime:
80 return (False, output)
81 time.sleep(10)
82
83 @testcase(550)
84 @skipUnlessPassed('test_systemd_basic')
85 def test_systemd_failed(self):
86 settled, output = self.settle()
87 self.assertTrue(settled, msg="Timed out waiting for systemd to settle:\n" + output)
88
89 output = self.systemctl('list-units', '--failed')
90 match = re.search("0 loaded units listed", output)
91 if not match:
92 output += self.systemctl('status --full --failed')
93 self.assertTrue(match, msg="Some systemd units failed:\n%s" % output)
94
95
96class SystemdServiceTests(SystemdTest):
97
98 def check_for_avahi(self):
99 if not self.hasPackage('avahi-daemon'):
100 raise unittest.SkipTest("Testcase dependency not met: need avahi-daemon installed on target")
101
102 @skipUnlessPassed('test_systemd_basic')
103 def test_systemd_status(self):
104 self.check_for_avahi()
105 self.systemctl('status --full', 'avahi-daemon.service')
106
107 @testcase(695)
108 @skipUnlessPassed('test_systemd_status')
109 def test_systemd_stop_start(self):
110 self.check_for_avahi()
111 self.systemctl('stop', 'avahi-daemon.service')
112 self.systemctl('is-active', 'avahi-daemon.service', expected=3, verbose=True)
113 self.systemctl('start','avahi-daemon.service')
114 self.systemctl('is-active', 'avahi-daemon.service', verbose=True)
115
116 @testcase(696)
117 @skipUnlessPassed('test_systemd_basic')
118 def test_systemd_disable_enable(self):
119 self.check_for_avahi()
120 self.systemctl('disable', 'avahi-daemon.service')
121 self.systemctl('is-enabled', 'avahi-daemon.service', expected=1)
122 self.systemctl('enable', 'avahi-daemon.service')
123 self.systemctl('is-enabled', 'avahi-daemon.service')
124
125class SystemdJournalTests(SystemdTest):
126 @skipUnlessPassed('test_ssh')
127 def test_systemd_journal(self):
128 (status, output) = self.target.run('journalctl')
129 self.assertEqual(status, 0, output)
130
131 @skipUnlessPassed('test_systemd_basic')
132 def test_systemd_boot_time(self, systemd_TimeoutStartSec=90):
133 """
134 Get the target boot time from journalctl and log it
135
136 Arguments:
137 -systemd_TimeoutStartSec, an optional argument containing systemd's
138 unit start timeout to compare against
139 """
140
141 # the expression chain that uniquely identifies the time boot message
142 expr_items=["Startup finished","kernel", "userspace","\.$"]
143 try:
144 output = self.journalctl(args="-o cat --reverse")
145 except AssertionError:
146 self.fail("Error occurred while calling journalctl")
147 if not len(output):
148 self.fail("Error, unable to get startup time from systemd journal")
149
150 # check for the regular expression items that match the startup time
151 for line in output.split('\n'):
152 check_match = "".join(re.findall(".*".join(expr_items), line))
153 if check_match: break
154 # put the startup time in the test log
155 if check_match:
156 print("%s" % check_match)
157 else:
158 self.skipTest("Error at obtaining the boot time from journalctl")
159 boot_time_sec = 0
160
161 # get the numeric values from the string and convert them to seconds
162 # same data will be placed in list and string for manipulation
163 l_boot_time = check_match.split(" ")[-2:]
164 s_boot_time = " ".join(l_boot_time)
165 try:
166 # Obtain the minutes it took to boot
167 if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
168 boot_time_min = s_boot_time.split("min")[0]
169 # convert to seconds and accumulate it
170 boot_time_sec += int(boot_time_min) * 60
171 # Obtain the seconds it took to boot and accumulate
172 boot_time_sec += float(l_boot_time[1].split("s")[0])
173 except ValueError:
174 self.skipTest("Error when parsing time from boot string")
175 #Assert the target boot time against systemd's unit start timeout
176 if boot_time_sec > systemd_TimeoutStartSec:
177 print("Target boot time %s exceeds systemd's TimeoutStartSec %s"\
178 %(boot_time_sec, systemd_TimeoutStartSec))
diff --git a/meta/lib/oeqa/runtime/x32lib.py b/meta/lib/oeqa/runtime/x32lib.py
deleted file mode 100644
index 2f98dbf71e..0000000000
--- a/meta/lib/oeqa/runtime/x32lib.py
+++ /dev/null
@@ -1,18 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 #check if DEFAULTTUNE is set and it's value is: x86-64-x32
7 defaulttune = oeRuntimeTest.tc.d.getVar("DEFAULTTUNE")
8 if "x86-64-x32" not in defaulttune:
9 skipModule("DEFAULTTUNE is not set to x86-64-x32")
10
11class X32libTest(oeRuntimeTest):
12
13 @testcase(281)
14 @skipUnlessPassed("test_ssh")
15 def test_x32_file(self):
16 status1 = self.target.run("readelf -h /bin/ls | grep Class | grep ELF32")[0]
17 status2 = self.target.run("readelf -h /bin/ls | grep Machine | grep X86-64")[0]
18 self.assertTrue(status1 == 0 and status2 == 0, msg="/bin/ls isn't an X86-64 ELF32 binary. readelf says: %s" % self.target.run("readelf -h /bin/ls")[1])
diff --git a/meta/lib/oeqa/runtime/xorg.py b/meta/lib/oeqa/runtime/xorg.py
deleted file mode 100644
index 12bcd371af..0000000000
--- a/meta/lib/oeqa/runtime/xorg.py
+++ /dev/null
@@ -1,16 +0,0 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not oeRuntimeTest.hasFeature("x11-base"):
7 skipModule("target doesn't have x11 in IMAGE_FEATURES")
8
9
10class XorgTest(oeRuntimeTest):
11
12 @testcase(1151)
13 @skipUnlessPassed('test_ssh')
14 def test_xorg_running(self):
15 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -v xinit | grep [X]org')
16 self.assertEqual(status, 0, msg="Xorg does not appear to be running %s" % self.target.run(oeRuntimeTest.pscmd)[1])