summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r--meta/lib/oeqa/runtime/__init__.py3
-rw-r--r--meta/lib/oeqa/runtime/_ptest.py124
-rw-r--r--meta/lib/oeqa/runtime/buildcvs.py31
-rw-r--r--meta/lib/oeqa/runtime/buildiptables.py31
-rw-r--r--meta/lib/oeqa/runtime/buildsudoku.py28
-rw-r--r--meta/lib/oeqa/runtime/connman.py30
-rw-r--r--meta/lib/oeqa/runtime/date.py23
-rw-r--r--meta/lib/oeqa/runtime/df.py12
-rw-r--r--meta/lib/oeqa/runtime/dmesg.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/test.c26
-rw-r--r--meta/lib/oeqa/runtime/files/test.cpp3
-rw-r--r--meta/lib/oeqa/runtime/files/test.pl2
-rw-r--r--meta/lib/oeqa/runtime/files/test.py6
-rw-r--r--meta/lib/oeqa/runtime/files/testmakefile5
-rw-r--r--meta/lib/oeqa/runtime/gcc.py46
-rw-r--r--meta/lib/oeqa/runtime/kernelmodule.py34
-rw-r--r--meta/lib/oeqa/runtime/ldd.py20
-rw-r--r--meta/lib/oeqa/runtime/logrotate.py28
-rw-r--r--meta/lib/oeqa/runtime/multilib.py18
-rw-r--r--meta/lib/oeqa/runtime/pam.py25
-rw-r--r--meta/lib/oeqa/runtime/parselogs.py178
-rw-r--r--meta/lib/oeqa/runtime/perl.py29
-rw-r--r--meta/lib/oeqa/runtime/ping.py20
-rw-r--r--meta/lib/oeqa/runtime/python.py34
-rw-r--r--meta/lib/oeqa/runtime/rpm.py53
-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.py121
-rw-r--r--meta/lib/oeqa/runtime/ssh.py19
-rw-r--r--meta/lib/oeqa/runtime/syslog.py48
-rw-r--r--meta/lib/oeqa/runtime/systemd.py88
-rw-r--r--meta/lib/oeqa/runtime/vnc.py20
-rw-r--r--meta/lib/oeqa/runtime/x32lib.py18
-rw-r--r--meta/lib/oeqa/runtime/xorg.py17
37 files changed, 1258 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/__init__.py b/meta/lib/oeqa/runtime/__init__.py
new file mode 100644
index 0000000000..4cf3fa76b6
--- /dev/null
+++ b/meta/lib/oeqa/runtime/__init__.py
@@ -0,0 +1,3 @@
1# Enable other layers to have tests in the same named directory
2from pkgutil import extend_path
3__path__ = extend_path(__path__, __name__)
diff --git a/meta/lib/oeqa/runtime/_ptest.py b/meta/lib/oeqa/runtime/_ptest.py
new file mode 100644
index 0000000000..4c58dc1d7f
--- /dev/null
+++ b/meta/lib/oeqa/runtime/_ptest.py
@@ -0,0 +1,124 @@
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("smart"):
15 skipModule("Image doesn't have smart installed")
16 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).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', True), 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', True)
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', True).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', True),
83 "installed_pkgs.txt")
84 self.pkgs_list = RpmPkgsList(oeRuntimeTest.tc.d, oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS', True), oeRuntimeTest.tc.d.getVar('arch_var', True), oeRuntimeTest.tc.d.getVar('os_var', True))
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 "glob", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR', True), 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 setUp(self):
102 self.buildhist_dir = oeRuntimeTest.tc.d.getVar("BUILDHISTORY_DIR_IMAGE", True)
103 self.assertTrue(os.path.exists(self.buildhist_dir))
104 self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR",True), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME', True))
105
106 @skipUnlessPassed('test_ssh')
107 def test_ptestrunner(self):
108 self.add_smart_channel()
109 cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackage("-ptest")
110 if not cond:
111 self.install_packages(self.install_complementary("*-ptest"))
112 self.install_packages(['ptest-runner'])
113
114 self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
115 self.target.copy_from('/tmp/ptest.log', self.ptest_log)
116 shutil.copyfile(self.ptest_log, os.path.join(self.buildhist_dir, "ptest.log"))
117
118 result = self.parse_ptest(os.path.join(self.buildhist_dir, "ptest.log"))
119 log_results_to_location = "./results"
120 if os.path.exists(log_results_to_location):
121 shutil.rmtree(log_results_to_location)
122 os.makedirs(log_results_to_location)
123
124 result.log_as_files(log_results_to_location, test_status = ['fail'])
diff --git a/meta/lib/oeqa/runtime/buildcvs.py b/meta/lib/oeqa/runtime/buildcvs.py
new file mode 100644
index 0000000000..fe6cbfbcd5
--- /dev/null
+++ b/meta/lib/oeqa/runtime/buildcvs.py
@@ -0,0 +1,31 @@
1from oeqa.oetest import oeRuntimeTest, skipModule
2from oeqa.utils.decorators import *
3from oeqa.utils.targetbuild 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 self.project = TargetBuildProject(oeRuntimeTest.tc.target, oeRuntimeTest.tc.d,
14 "http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2")
15 self.project.download_archive()
16
17 @testcase(205)
18 @skipUnlessPassed("test_ssh")
19 def test_cvs(self):
20 self.assertEqual(self.project.run_configure(), 0,
21 msg="Running configure failed")
22
23 self.assertEqual(self.project.run_make(), 0,
24 msg="Running make failed")
25
26 self.assertEqual(self.project.run_install(), 0,
27 msg="Running make install failed")
28
29 @classmethod
30 def tearDownClass(self):
31 self.project.clean()
diff --git a/meta/lib/oeqa/runtime/buildiptables.py b/meta/lib/oeqa/runtime/buildiptables.py
new file mode 100644
index 0000000000..09e252df8c
--- /dev/null
+++ b/meta/lib/oeqa/runtime/buildiptables.py
@@ -0,0 +1,31 @@
1from oeqa.oetest import oeRuntimeTest, skipModule
2from oeqa.utils.decorators import *
3from oeqa.utils.targetbuild 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 self.project = TargetBuildProject(oeRuntimeTest.tc.target, oeRuntimeTest.tc.d,
14 "http://netfilter.org/projects/iptables/files/iptables-1.4.13.tar.bz2")
15 self.project.download_archive()
16
17 @testcase(206)
18 @skipUnlessPassed("test_ssh")
19 def test_iptables(self):
20 self.assertEqual(self.project.run_configure(), 0,
21 msg="Running configure failed")
22
23 self.assertEqual(self.project.run_make(), 0,
24 msg="Running make failed")
25
26 self.assertEqual(self.project.run_install(), 0,
27 msg="Running make install failed")
28
29 @classmethod
30 def tearDownClass(self):
31 self.project.clean()
diff --git a/meta/lib/oeqa/runtime/buildsudoku.py b/meta/lib/oeqa/runtime/buildsudoku.py
new file mode 100644
index 0000000000..802b060010
--- /dev/null
+++ b/meta/lib/oeqa/runtime/buildsudoku.py
@@ -0,0 +1,28 @@
1from oeqa.oetest import oeRuntimeTest, skipModule
2from oeqa.utils.decorators import *
3from oeqa.utils.targetbuild 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 SudokuTest(oeRuntimeTest):
10
11 @classmethod
12 def setUpClass(self):
13 self.project = TargetBuildProject(oeRuntimeTest.tc.target, oeRuntimeTest.tc.d,
14 "http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2")
15 self.project.download_archive()
16
17 @testcase(207)
18 @skipUnlessPassed("test_ssh")
19 def test_sudoku(self):
20 self.assertEqual(self.project.run_configure(), 0,
21 msg="Running configure failed")
22
23 self.assertEqual(self.project.run_make(), 0,
24 msg="Running make failed")
25
26 @classmethod
27 def tearDownClass(self):
28 self.project.clean()
diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py
new file mode 100644
index 0000000000..cc537f7766
--- /dev/null
+++ b/meta/lib/oeqa/runtime/connman.py
@@ -0,0 +1,30 @@
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 @skipUnlessPassed('test_ssh')
20 def test_connmand_help(self):
21 (status, output) = self.target.run('/usr/sbin/connmand --help')
22 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
23
24 @testcase(221)
25 @skipUnlessPassed('test_connmand_help')
26 def test_connmand_running(self):
27 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand')
28 if status != 0:
29 print self.service_status("connman")
30 self.fail("No connmand process running")
diff --git a/meta/lib/oeqa/runtime/date.py b/meta/lib/oeqa/runtime/date.py
new file mode 100644
index 0000000000..97e8ee42ad
--- /dev/null
+++ b/meta/lib/oeqa/runtime/date.py
@@ -0,0 +1,23 @@
1from oeqa.oetest import oeRuntimeTest
2from oeqa.utils.decorators import *
3import re
4
5class DateTest(oeRuntimeTest):
6
7 @testcase(211)
8 @skipUnlessPassed("test_ssh")
9 def test_date(self):
10 (status, output) = self.target.run('date +"%Y-%m-%d %T"')
11 self.assertEqual(status, 0, msg="Failed to get initial date, output: %s" % output)
12 oldDate = output
13
14 sampleDate = '"2016-08-09 10:00:00"'
15 (status, output) = self.target.run("date -s %s" % sampleDate)
16 self.assertEqual(status, 0, msg="Date set failed, output: %s" % output)
17
18 (status, output) = self.target.run("date -R")
19 p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
20 self.assertTrue(p, msg="The date was not set correctly, output: %s" % output)
21
22 (status, output) = self.target.run('date -s "%s"' % oldDate)
23 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
new file mode 100644
index 0000000000..09569d5ff6
--- /dev/null
+++ b/meta/lib/oeqa/runtime/df.py
@@ -0,0 +1,12 @@
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/dmesg.py b/meta/lib/oeqa/runtime/dmesg.py
new file mode 100644
index 0000000000..5831471e50
--- /dev/null
+++ b/meta/lib/oeqa/runtime/dmesg.py
@@ -0,0 +1,12 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest
3from oeqa.utils.decorators import *
4
5
6class DmesgTest(oeRuntimeTest):
7
8 @testcase(215)
9 @skipUnlessPassed('test_ssh')
10 def test_dmesg(self):
11 (status, output) = self.target.run('dmesg | grep -v mmci-pl18x | grep -v "error changing net interface name" | grep -iv "dma timeout" | grep -v usbhid | grep -i error')
12 self.assertEqual(status, 1, msg = "Error messages in dmesg log: %s" % output)
diff --git a/meta/lib/oeqa/runtime/files/hellomod.c b/meta/lib/oeqa/runtime/files/hellomod.c
new file mode 100644
index 0000000000..a383397e93
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/hellomod.c
@@ -0,0 +1,19 @@
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
new file mode 100644
index 0000000000..b92d5c8fe0
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/hellomod_makefile
@@ -0,0 +1,8 @@
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/test.c b/meta/lib/oeqa/runtime/files/test.c
new file mode 100644
index 0000000000..2d8389c92e
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/test.c
@@ -0,0 +1,26 @@
1#include <stdio.h>
2#include <math.h>
3#include <stdlib.h>
4
5double convert(long long l)
6{
7 return (double)l;
8}
9
10int main(int argc, char * argv[]) {
11
12 long long l = 10;
13 double f;
14 double check = 10.0;
15
16 f = convert(l);
17 printf("convert: %lld => %f\n", l, f);
18 if ( f != check ) exit(1);
19
20 f = 1234.67;
21 check = 1234.0;
22 printf("floorf(%f) = %f\n", f, floorf(f));
23 if ( floorf(f) != check) exit(1);
24
25 return 0;
26}
diff --git a/meta/lib/oeqa/runtime/files/test.cpp b/meta/lib/oeqa/runtime/files/test.cpp
new file mode 100644
index 0000000000..9e1a76473d
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/test.cpp
@@ -0,0 +1,3 @@
1#include <limits>
2
3int main() {} \ No newline at end of file
diff --git a/meta/lib/oeqa/runtime/files/test.pl b/meta/lib/oeqa/runtime/files/test.pl
new file mode 100644
index 0000000000..689c8f1635
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/test.pl
@@ -0,0 +1,2 @@
1$a = 9.01e+21 - 9.01e+21 + 0.01;
2print ("the value of a is ", $a, "\n");
diff --git a/meta/lib/oeqa/runtime/files/test.py b/meta/lib/oeqa/runtime/files/test.py
new file mode 100644
index 0000000000..f3a2273c52
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/test.py
@@ -0,0 +1,6 @@
1import os
2
3os.system('touch /tmp/testfile.python')
4
5a = 9.01e+21 - 9.01e+21 + 0.01
6print "the value of a is %s" % a
diff --git a/meta/lib/oeqa/runtime/files/testmakefile b/meta/lib/oeqa/runtime/files/testmakefile
new file mode 100644
index 0000000000..ca1844e930
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/testmakefile
@@ -0,0 +1,5 @@
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
new file mode 100644
index 0000000000..a7f62e1758
--- /dev/null
+++ b/meta/lib/oeqa/runtime/gcc.py
@@ -0,0 +1,46 @@
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.filesdir, "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.filesdir, "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 def test_gpp2_compile(self):
34 (status, output) = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
35 self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output)
36 (status, output) = self.target.run('/tmp/test')
37 self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
38
39 @testcase(204)
40 def test_make(self):
41 (status, output) = self.target.run('cd /tmp; make -f testmakefile')
42 self.assertEqual(status, 0, msg="running make failed, output %s" % output)
43
44 @classmethod
45 def tearDownClass(self):
46 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
new file mode 100644
index 0000000000..2e81720327
--- /dev/null
+++ b/meta/lib/oeqa/runtime/kernelmodule.py
@@ -0,0 +1,34 @@
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 setUp(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('316')
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 tearDown(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
new file mode 100644
index 0000000000..bce56c4270
--- /dev/null
+++ b/meta/lib/oeqa/runtime/ldd.py
@@ -0,0 +1,20 @@
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 @skipUnlessPassed('test_ssh')
12 def test_ldd_exists(self):
13 (status, output) = self.target.run('which ldd')
14 self.assertEqual(status, 0, msg = "ldd does not exist in PATH: which ldd: %s" % output)
15
16 @testcase(239)
17 @skipUnlessPassed('test_ldd_exists')
18 def test_ldd_rtldlist_check(self):
19 (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')
20 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
new file mode 100644
index 0000000000..86d791c300
--- /dev/null
+++ b/meta/lib/oeqa/runtime/logrotate.py
@@ -0,0 +1,28 @@
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 @skipUnlessPassed("test_ssh")
16 def test_1_logrotate_setup(self):
17 (status, output) = self.target.run('mkdir /home/root/logrotate_dir')
18 self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output)
19 (status, output) = self.target.run("sed -i 's#wtmp {#wtmp {\\n olddir /home/root/logrotate_dir#' /etc/logrotate.conf")
20 self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output))
21
22 @testcase(289)
23 @skipUnlessPassed("test_1_logrotate_setup")
24 def test_2_logrotate(self):
25 (status, output) = self.target.run('logrotate -f /etc/logrotate.conf')
26 self.assertEqual(status, 0, msg = "logrotate service could not be reloaded. Status and output: %s and %s" % (status, output))
27 output = self.target.run('ls -la /home/root/logrotate_dir/ | wc -l')[1]
28 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/root/logrotate_dir')[1]))
diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py
new file mode 100644
index 0000000000..ab0a6ccd69
--- /dev/null
+++ b/meta/lib/oeqa/runtime/multilib.py
@@ -0,0 +1,18 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 multilibs = oeRuntimeTest.tc.d.getVar("MULTILIBS", True) or ""
7 if "multilib:lib32" not in multilibs:
8 skipModule("this isn't a multilib:lib32 image")
9
10
11class MultilibTest(oeRuntimeTest):
12
13 @testcase('279')
14 @skipUnlessPassed('test_ssh')
15 def test_file_connman(self):
16 self.assertTrue(oeRuntimeTest.hasPackage('connman-gnome'), msg="This test assumes connman-gnome is installed")
17 (status, output) = self.target.run("readelf -h /usr/bin/connman-applet | sed -n '3p' | awk '{print $2}'")
18 self.assertEqual(output, "ELF32", msg="connman-applet isn't an ELF32 binary. readelf says: %s" % self.target.run("readelf -h /usr/bin/connman-applet")[1])
diff --git a/meta/lib/oeqa/runtime/pam.py b/meta/lib/oeqa/runtime/pam.py
new file mode 100644
index 0000000000..c8205c9abc
--- /dev/null
+++ b/meta/lib/oeqa/runtime/pam.py
@@ -0,0 +1,25 @@
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(287)
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
new file mode 100644
index 0000000000..42cb1b5e6f
--- /dev/null
+++ b/meta/lib/oeqa/runtime/parselogs.py
@@ -0,0 +1,178 @@
1import os
2import unittest
3from oeqa.oetest import oeRuntimeTest
4from oeqa.utils.decorators import *
5
6#in the future these lists could be moved outside of module
7errors = ["error", "cannot", "can\'t", "failed"]
8
9common_errors = [
10 '(WW) warning, (EE) error, (NI) not implemented, (??) unknown.',
11 'dma timeout',
12 'can\'t add hid device:',
13 'usbhid: probe of ',
14 ]
15
16x86_common = [
17 '[drm:psb_do_init] *ERROR* Debug is',
18 'wrong ELF class',
19 'Could not enable PowerButton event',
20 'probe of LNXPWRBN:00 failed with error -22',
21] + common_errors
22
23qemux86_common = [
24 'Fast TSC calibration',
25 '_OSC failed (AE_NOT_FOUND); disabling ASPM',
26 'Open ACPI failed (/var/run/acpid.socket) (No such file or directory)',
27 'Failed to load module "vesa"',
28 'Failed to load module "modesetting"',
29 'Failed to load module "glx"',
30 'wrong ELF class',
31] + common_errors
32
33ignore_errors = {
34 'default' : common_errors,
35 'qemux86' : [
36 'Failed to access perfctr msr (MSR c1 is 0)',
37 "fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
38 ] + qemux86_common,
39 'qemux86-64' : qemux86_common,
40 'qemumips' : [
41 'Failed to load module "glx"',
42 ] + common_errors,
43 'qemuppc' : [
44 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]',
45 'mode "640x480" test failed',
46 'Failed to load module "glx"',
47 ] + common_errors,
48 'qemuarm' : [
49 'mmci-pl18x: probe of fpga:05 failed with error -22',
50 'mmci-pl18x: probe of fpga:0b failed with error -22',
51 'Failed to load module "glx"'
52 ] + common_errors,
53 'emenlow' : x86_common,
54 'crownbay' : x86_common,
55 'genericx86' : x86_common,
56 'genericx86-64' : x86_common,
57}
58
59log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"]
60
61class ParseLogsTest(oeRuntimeTest):
62
63 @classmethod
64 def setUpClass(self):
65 self.errors = errors
66 self.ignore_errors = ignore_errors
67 self.log_locations = log_locations
68 self.msg = ""
69
70 def getMachine(self):
71 (status, output) = self.target.run("uname -n")
72 return output
73
74 #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.
75 def getHardwareInfo(self):
76 hwi = ""
77 (status, cpu_name) = self.target.run("cat /proc/cpuinfo | grep \"model name\" | head -n1 | awk 'BEGIN{FS=\":\"}{print $2}'")
78 (status, cpu_physical_cores) = self.target.run("cat /proc/cpuinfo | grep \"cpu cores\" | head -n1 | awk {'print $4'}")
79 (status, cpu_logical_cores) = self.target.run("cat /proc/cpuinfo | grep \"processor\" | wc -l")
80 (status, cpu_arch) = self.target.run("uname -m")
81 hwi += "Machine information: \n"
82 hwi += "*******************************\n"
83 hwi += "Machine name: "+self.getMachine()+"\n"
84 hwi += "CPU: "+str(cpu_name)+"\n"
85 hwi += "Arch: "+str(cpu_arch)+"\n"
86 hwi += "Physical cores: "+str(cpu_physical_cores)+"\n"
87 hwi += "Logical cores: "+str(cpu_logical_cores)+"\n"
88 hwi += "*******************************\n"
89 return hwi
90
91 #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
92 #it to that list
93 def getLogList(self, log_locations):
94 logs = []
95 for location in log_locations:
96 (status, output) = self.target.run("test -f "+str(location))
97 if (status == 0):
98 logs.append(str(location))
99 else:
100 (status, output) = self.target.run("test -d "+str(location))
101 if (status == 0):
102 (status, output) = self.target.run("find "+str(location)+"/*.log -maxdepth 1 -type f")
103 output = output.splitlines()
104 for logfile in output:
105 logs.append(os.path.join(location,str(logfile)))
106 return logs
107
108 #build the grep command to be used with filters and exclusions
109 def build_grepcmd(self, errors, ignore_errors, log):
110 grepcmd = "grep "
111 grepcmd +="-Ei \""
112 for error in errors:
113 grepcmd += error+"|"
114 grepcmd = grepcmd[:-1]
115 grepcmd += "\" "+str(log)+" | grep -Eiv \'"
116 try:
117 errorlist = ignore_errors[self.getMachine()]
118 except KeyError:
119 self.msg += "No ignore list found for this machine, using default\n"
120 errorlist = ignore_errors['default']
121 for ignore_error in errorlist:
122 ignore_error = ignore_error.replace("(", "\(")
123 ignore_error = ignore_error.replace(")", "\)")
124 ignore_error = ignore_error.replace("'", ".")
125 ignore_error = ignore_error.replace("?", "\?")
126 ignore_error = ignore_error.replace("[", "\[")
127 ignore_error = ignore_error.replace("]", "\]")
128 ignore_error = ignore_error.replace("*", "\*")
129 grepcmd += ignore_error+"|"
130 grepcmd = grepcmd[:-1]
131 grepcmd += "\'"
132 return grepcmd
133
134 #grep only the errors so that their context could be collected. Default context is 10 lines before and after the error itself
135 def parse_logs(self, errors, ignore_errors, logs, lines_before = 10, lines_after = 10):
136 results = {}
137 rez = []
138 for log in logs:
139 thegrep = self.build_grepcmd(errors, ignore_errors, log)
140 try:
141 (status, result) = self.target.run(thegrep)
142 except:
143 pass
144 if result:
145 results[log] = {}
146 rez = result.splitlines()
147 for xrez in rez:
148 command = "grep \"\\"+str(xrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log)
149 try:
150 (status, yrez) = self.target.run(command)
151 except:
152 pass
153 results[log][xrez]=yrez
154 return results
155
156 #get the output of dmesg and write it in a file. This file is added to log_locations.
157 def write_dmesg(self):
158 (status, dmesg) = self.target.run("dmesg")
159 (status, dmesg2) = self.target.run("echo \""+str(dmesg)+"\" > /tmp/dmesg_output.log")
160
161 @skipUnlessPassed('test_ssh')
162 def test_parselogs(self):
163 self.write_dmesg()
164 log_list = self.getLogList(self.log_locations)
165 result = self.parse_logs(self.errors, self.ignore_errors, log_list)
166 print self.getHardwareInfo()
167 errcount = 0
168 for log in result:
169 self.msg += "Log: "+log+"\n"
170 self.msg += "-----------------------\n"
171 for error in result[log]:
172 errcount += 1
173 self.msg += "Central error: "+str(error)+"\n"
174 self.msg += "***********************\n"
175 self.msg += result[str(log)][str(error)]+"\n"
176 self.msg += "***********************\n"
177 self.msg += "%s errors found in logs." % errcount
178 self.assertEqual(errcount, 0, msg=self.msg)
diff --git a/meta/lib/oeqa/runtime/perl.py b/meta/lib/oeqa/runtime/perl.py
new file mode 100644
index 0000000000..65da028d4b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/perl.py
@@ -0,0 +1,29 @@
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.filesdir, "test.pl"), "/tmp/test.pl")
16
17 def test_perl_exists(self):
18 (status, output) = self.target.run('which perl')
19 self.assertEqual(status, 0, msg="Perl binary not in PATH or not on target.")
20
21 @testcase(208)
22 def test_perl_works(self):
23 (status, output) = self.target.run('perl /tmp/test.pl')
24 self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output)
25 self.assertEqual(output, "the value of a is 0.01", msg="Incorrect output: %s" % output)
26
27 @classmethod
28 def tearDownClass(self):
29 oeRuntimeTest.tc.target.run("rm /tmp/test.pl")
diff --git a/meta/lib/oeqa/runtime/ping.py b/meta/lib/oeqa/runtime/ping.py
new file mode 100644
index 0000000000..a73c72402a
--- /dev/null
+++ b/meta/lib/oeqa/runtime/ping.py
@@ -0,0 +1,20 @@
1import subprocess
2import unittest
3import sys
4import time
5from oeqa.oetest import oeRuntimeTest
6
7class PingTest(oeRuntimeTest):
8
9 def test_ping(self):
10 output = ''
11 count = 0
12 endtime = time.time() + 60
13 while count < 5 and time.time() < endtime:
14 proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE)
15 output += proc.communicate()[0]
16 if proc.poll() == 0:
17 count += 1
18 else:
19 count = 0
20 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
new file mode 100644
index 0000000000..0387b9a03e
--- /dev/null
+++ b/meta/lib/oeqa/runtime/python.py
@@ -0,0 +1,34 @@
1import unittest
2import os
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasPackage("python"):
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.filesdir, "test.py"), "/tmp/test.py")
16
17 def test_python_exists(self):
18 (status, output) = self.target.run('which python')
19 self.assertEqual(status, 0, msg="Python binary not in PATH or not on target.")
20
21 @testcase(965)
22 def test_python_stdout(self):
23 (status, output) = self.target.run('python /tmp/test.py')
24 self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output)
25 self.assertEqual(output, "the value of a is 0.01", msg="Incorrect output: %s" % output)
26
27 def test_python_testfile(self):
28 (status, output) = self.target.run('ls /tmp/testfile.python')
29 self.assertEqual(status, 0, msg="Python test file generate failed.")
30
31
32 @classmethod
33 def tearDownClass(self):
34 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
new file mode 100644
index 0000000000..b17e8b46a8
--- /dev/null
+++ b/meta/lib/oeqa/runtime/rpm.py
@@ -0,0 +1,53 @@
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", True).split()[0]:
11 skipModule("rpm module skipped: target doesn't have rpm as primary package manager")
12
13
14class RpmBasicTest(oeRuntimeTest):
15
16 @skipUnlessPassed('test_ssh')
17 def test_rpm_help(self):
18 (status, output) = self.target.run('rpm --help')
19 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
20
21 @testcase(191)
22 @skipUnlessPassed('test_rpm_help')
23 def test_rpm_query(self):
24 (status, output) = self.target.run('rpm -q rpm')
25 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
26
27class RpmInstallRemoveTest(oeRuntimeTest):
28
29 @classmethod
30 def setUpClass(self):
31 pkgarch = oeRuntimeTest.tc.d.getVar('TUNE_PKGARCH', True).replace("-", "_")
32 rpmdir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), "rpm", pkgarch)
33 # pick rpm-doc as a test file to get installed, because it's small and it will always be built for standard targets
34 for f in fnmatch.filter(os.listdir(rpmdir), "rpm-doc-*.%s.rpm" % pkgarch):
35 testrpmfile = f
36 oeRuntimeTest.tc.target.copy_to(os.path.join(rpmdir,testrpmfile), "/tmp/rpm-doc.rpm")
37
38 @testcase(192)
39 @skipUnlessPassed('test_rpm_help')
40 def test_rpm_install(self):
41 (status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
42 self.assertEqual(status, 0, msg="Failed to install rpm-doc package: %s" % output)
43
44 @testcase(194)
45 @skipUnlessPassed('test_rpm_install')
46 def test_rpm_remove(self):
47 (status,output) = self.target.run('rpm -e rpm-doc')
48 self.assertEqual(status, 0, msg="Failed to remove rpm-doc package: %s" % output)
49
50 @classmethod
51 def tearDownClass(self):
52 oeRuntimeTest.tc.target.run('rm -f /tmp/rpm-doc.rpm')
53
diff --git a/meta/lib/oeqa/runtime/scanelf.py b/meta/lib/oeqa/runtime/scanelf.py
new file mode 100644
index 0000000000..43a024ab9a
--- /dev/null
+++ b/meta/lib/oeqa/runtime/scanelf.py
@@ -0,0 +1,28 @@
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 setUp(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
new file mode 100644
index 0000000000..48e87d2d0b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/scp.py
@@ -0,0 +1,22 @@
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", True)
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
new file mode 100644
index 0000000000..7c7f402e5d
--- /dev/null
+++ b/meta/lib/oeqa/runtime/skeletoninit.py
@@ -0,0 +1,29 @@
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"), "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"), "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
new file mode 100644
index 0000000000..3b49314df7
--- /dev/null
+++ b/meta/lib/oeqa/runtime/smart.py
@@ -0,0 +1,121 @@
1import unittest
2import re
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5from oeqa.utils.httpserver import HTTPService
6
7def setUpModule():
8 if not oeRuntimeTest.hasFeature("package-management"):
9 skipModule("Image doesn't have package management feature")
10 if not oeRuntimeTest.hasPackage("smart"):
11 skipModule("Image doesn't have smart installed")
12 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
13 skipModule("Rpm is not the primary package manager")
14
15class SmartTest(oeRuntimeTest):
16
17 @skipUnlessPassed('test_smart_help')
18 def smart(self, command, expected = 0):
19 command = 'smart %s' % command
20 status, output = self.target.run(command, 1500)
21 message = os.linesep.join([command, output])
22 self.assertEqual(status, expected, message)
23 self.assertFalse("Cannot allocate memory" in output, message)
24 return output
25
26class SmartBasicTest(SmartTest):
27
28 @testcase(716)
29 @skipUnlessPassed('test_ssh')
30 def test_smart_help(self):
31 self.smart('--help')
32
33 def test_smart_version(self):
34 self.smart('--version')
35
36 @testcase(721)
37 def test_smart_info(self):
38 self.smart('info python-smartpm')
39
40 @testcase(421)
41 def test_smart_query(self):
42 self.smart('query python-smartpm')
43
44 @testcase(720)
45 def test_smart_search(self):
46 self.smart('search python-smartpm')
47
48 @testcase(722)
49 def test_smart_stats(self):
50 self.smart('stats')
51
52class SmartRepoTest(SmartTest):
53
54 @classmethod
55 def setUpClass(self):
56 self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), oeRuntimeTest.tc.target.server_ip)
57 self.repo_server.start()
58
59 @classmethod
60 def tearDownClass(self):
61 self.repo_server.stop()
62
63 def test_smart_channel(self):
64 self.smart('channel', 1)
65
66 @testcase(719)
67 def test_smart_channel_add(self):
68 image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
69 deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
70 pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split()
71 for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
72 if arch in pkgarchs:
73 self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url))
74 self.smart('update')
75
76 def test_smart_channel_help(self):
77 self.smart('channel --help')
78
79 def test_smart_channel_list(self):
80 self.smart('channel --list')
81
82 def test_smart_channel_show(self):
83 self.smart('channel --show')
84
85 @testcase(717)
86 def test_smart_channel_rpmsys(self):
87 self.smart('channel --show rpmsys')
88 self.smart('channel --disable rpmsys')
89 self.smart('channel --enable rpmsys')
90
91 @skipUnlessPassed('test_smart_channel_add')
92 def test_smart_install(self):
93 self.smart('remove -y psplash-default')
94 self.smart('install -y psplash-default')
95
96 @testcase(728)
97 @skipUnlessPassed('test_smart_install')
98 def test_smart_install_dependency(self):
99 self.smart('remove -y psplash')
100 self.smart('install -y psplash-default')
101
102 @testcase(723)
103 @skipUnlessPassed('test_smart_channel_add')
104 def test_smart_install_from_disk(self):
105 self.smart('remove -y psplash-default')
106 self.smart('download psplash-default')
107 self.smart('install -y ./psplash-default*')
108
109 @testcase(725)
110 @skipUnlessPassed('test_smart_channel_add')
111 def test_smart_install_from_http(self):
112 output = self.smart('download --urls psplash-default')
113 url = re.search('(http://.*/psplash-default.*\.rpm)', output)
114 self.assertTrue(url, msg="Couln't find download url in %s" % output)
115 self.smart('remove -y psplash-default')
116 self.smart('install -y %s' % url.group(0))
117
118 @testcase(729)
119 @skipUnlessPassed('test_smart_install')
120 def test_smart_reinstall(self):
121 self.smart('reinstall -y psplash-default')
diff --git a/meta/lib/oeqa/runtime/ssh.py b/meta/lib/oeqa/runtime/ssh.py
new file mode 100644
index 0000000000..0e76d5d512
--- /dev/null
+++ b/meta/lib/oeqa/runtime/ssh.py
@@ -0,0 +1,19 @@
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
new file mode 100644
index 0000000000..7fa018e97f
--- /dev/null
+++ b/meta/lib/oeqa/runtime/syslog.py
@@ -0,0 +1,48 @@
1import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not oeRuntimeTest.hasPackage("syslog"):
7 skipModule("No syslog package in image")
8
9class SyslogTest(oeRuntimeTest):
10
11 @skipUnlessPassed("test_ssh")
12 def test_syslog_help(self):
13 (status,output) = self.target.run('/sbin/syslogd --help')
14 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
15
16 @testcase(201)
17 @skipUnlessPassed("test_syslog_help")
18 def test_syslog_running(self):
19 (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
20 self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
21
22
23class SyslogTestConfig(oeRuntimeTest):
24
25 @skipUnlessPassed("test_syslog_running")
26 def test_syslog_logger(self):
27 (status,output) = self.target.run('logger foobar && test -e /var/log/messages && grep foobar /var/log/messages || logread | grep foobar')
28 self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages. Output: %s " % output)
29
30 @skipUnlessPassed("test_syslog_running")
31 def test_syslog_restart(self):
32 if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"):
33 (status,output) = self.target.run('/etc/init.d/syslog restart')
34 else:
35 (status,output) = self.target.run('systemctl restart syslog.service')
36
37 @testcase(202)
38 @skipUnlessPassed("test_syslog_restart")
39 @skipUnlessPassed("test_syslog_logger")
40 @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"), "Not appropiate for systemd image")
41 def test_syslog_startup_config(self):
42 self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
43 (status,output) = self.target.run('/etc/init.d/syslog restart')
44 self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
45 (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
46 self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
47 self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")
48 self.target.run('/etc/init.d/syslog restart')
diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py
new file mode 100644
index 0000000000..1451698bb3
--- /dev/null
+++ b/meta/lib/oeqa/runtime/systemd.py
@@ -0,0 +1,88 @@
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", True):
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
25class SystemdBasicTests(SystemdTest):
26
27 @skipUnlessPassed('test_ssh')
28 def test_systemd_basic(self):
29 self.systemctl('--version')
30
31 @testcase(551)
32 @skipUnlessPassed('test_system_basic')
33 def test_systemd_list(self):
34 self.systemctl('list-unit-files')
35
36 def settle(self):
37 """
38 Block until systemd has finished activating any units being activated,
39 or until two minutes has elapsed.
40
41 Returns a tuple, either (True, '') if all units have finished
42 activating, or (False, message string) if there are still units
43 activating (generally, failing units that restart).
44 """
45 import time
46 endtime = time.time() + (60 * 2)
47 while True:
48 status, output = self.target.run('systemctl --state=activating')
49 if "0 loaded units listed" in output:
50 return (True, '')
51 if time.time() >= endtime:
52 return (False, output)
53 time.sleep(10)
54
55 @testcase(550)
56 @skipUnlessPassed('test_systemd_basic')
57 def test_systemd_failed(self):
58 settled, output = self.settle()
59 self.assertTrue(settled, msg="Timed out waiting for systemd to settle:\n" + output)
60
61 output = self.systemctl('list-units', '--failed')
62 match = re.search("0 loaded units listed", output)
63 if not match:
64 output += self.systemctl('status --full --failed')
65 self.assertTrue(match, msg="Some systemd units failed:\n%s" % output)
66
67
68class SystemdServiceTests(SystemdTest):
69
70 @skipUnlessPassed('test_systemd_basic')
71 def test_systemd_status(self):
72 self.systemctl('status --full', 'avahi-daemon.service')
73
74 @testcase(695)
75 @skipUnlessPassed('test_systemd_status')
76 def test_systemd_stop_start(self):
77 self.systemctl('stop', 'avahi-daemon.service')
78 self.systemctl('is-active', 'avahi-daemon.service', expected=3, verbose=True)
79 self.systemctl('start','avahi-daemon.service')
80 self.systemctl('is-active', 'avahi-daemon.service', verbose=True)
81
82 @testcase(696)
83 @skipUnlessPassed('test_systemd_basic')
84 def test_systemd_disable_enable(self):
85 self.systemctl('disable', 'avahi-daemon.service')
86 self.systemctl('is-enabled', 'avahi-daemon.service', expected=1)
87 self.systemctl('enable', 'avahi-daemon.service')
88 self.systemctl('is-enabled', 'avahi-daemon.service')
diff --git a/meta/lib/oeqa/runtime/vnc.py b/meta/lib/oeqa/runtime/vnc.py
new file mode 100644
index 0000000000..f31deff306
--- /dev/null
+++ b/meta/lib/oeqa/runtime/vnc.py
@@ -0,0 +1,20 @@
1from oeqa.oetest import oeRuntimeTest, skipModuleUnless
2from oeqa.utils.decorators import *
3import re
4
5def setUpModule():
6 skipModuleUnless(oeRuntimeTest.hasPackage('x11vnc'), "No x11vnc package in image")
7
8class VNCTest(oeRuntimeTest):
9
10 @testcase(213)
11 @skipUnlessPassed('test_ssh')
12 def test_vnc(self):
13 (status, output) = self.target.run('x11vnc -display :0 -bg -o x11vnc.log')
14 self.assertEqual(status, 0, msg="x11vnc server failed to start: %s" % output)
15 port = re.search('PORT=[0-9]*', output)
16 self.assertTrue(port, msg="Listening port not specified in command output: %s" %output)
17
18 vncport = port.group(0).split('=')[1]
19 (status, output) = self.target.run('netstat -ntl | grep ":%s"' % vncport)
20 self.assertEqual(status, 0, msg="x11vnc server not running on port %s\n\n%s" % (vncport, self.target.run('netstat -ntl; cat x11vnc.log')[1]))
diff --git a/meta/lib/oeqa/runtime/x32lib.py b/meta/lib/oeqa/runtime/x32lib.py
new file mode 100644
index 0000000000..ce5e214035
--- /dev/null
+++ b/meta/lib/oeqa/runtime/x32lib.py
@@ -0,0 +1,18 @@
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", True)
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
new file mode 100644
index 0000000000..a07031e5c8
--- /dev/null
+++ b/meta/lib/oeqa/runtime/xorg.py
@@ -0,0 +1,17 @@
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 @skipUnlessPassed('test_ssh')
13 def test_xorg_running(self):
14 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -v xinit | grep [X]org')
15 self.assertEqual(status, 0, msg="Xorg does not appear to be running %s" % self.target.run(oeRuntimeTest.pscmd)[1])
16
17