summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-11-01 07:48:16 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:20 +0000
commitb569aa0e0056a97b29577f5bda611ef3dd539db3 (patch)
tree64f4d7856959435abfc7c49258688f64861f6d7c
parent3857e5c91da678d7bdc07712a1df9daa14354986 (diff)
downloadpoky-b569aa0e0056a97b29577f5bda611ef3dd539db3.tar.gz
oeqa/runtime/cases: Migrate runtime tests.
This migrates current runtime test suite to be used with the new framework. [YOCTO #10234] (From OE-Core rev: b39c61f2d442c79d03b73e8ffd104996fcb2177e) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/runtime/cases/_ptest.py (renamed from meta/lib/oeqa/runtime_cases/_ptest.py)0
-rw-r--r--meta/lib/oeqa/runtime/cases/_qemutiny.py (renamed from meta/lib/oeqa/runtime_cases/_qemutiny.py)0
-rw-r--r--meta/lib/oeqa/runtime/cases/buildcvs.py35
-rw-r--r--meta/lib/oeqa/runtime/cases/buildgalculator.py31
-rw-r--r--meta/lib/oeqa/runtime/cases/buildiptables.py39
-rw-r--r--meta/lib/oeqa/runtime/cases/connman.py30
-rw-r--r--meta/lib/oeqa/runtime/cases/date.py38
-rw-r--r--meta/lib/oeqa/runtime/cases/df.py13
-rw-r--r--meta/lib/oeqa/runtime/cases/gcc.py76
-rw-r--r--meta/lib/oeqa/runtime/cases/kernelmodule.py40
-rw-r--r--meta/lib/oeqa/runtime/cases/ldd.py25
-rw-r--r--meta/lib/oeqa/runtime/cases/logrotate.py42
-rw-r--r--meta/lib/oeqa/runtime/cases/multilib.py41
-rw-r--r--meta/lib/oeqa/runtime/cases/pam.py33
-rw-r--r--meta/lib/oeqa/runtime/cases/parselogs.py (renamed from meta/lib/oeqa/runtime_cases/parselogs.py)187
-rw-r--r--meta/lib/oeqa/runtime/cases/perl.py37
-rw-r--r--meta/lib/oeqa/runtime/cases/ping.py24
-rw-r--r--meta/lib/oeqa/runtime/cases/python.py43
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py141
-rw-r--r--meta/lib/oeqa/runtime/cases/scanelf.py26
-rw-r--r--meta/lib/oeqa/runtime/cases/scp.py33
-rw-r--r--meta/lib/oeqa/runtime/cases/skeletoninit.py33
-rw-r--r--meta/lib/oeqa/runtime/cases/smart.py (renamed from meta/lib/oeqa/runtime_cases/smart.py)0
-rw-r--r--meta/lib/oeqa/runtime/cases/ssh.py15
-rw-r--r--meta/lib/oeqa/runtime/cases/syslog.py57
-rw-r--r--meta/lib/oeqa/runtime/cases/systemd.py (renamed from meta/lib/oeqa/runtime_cases/systemd.py)151
-rw-r--r--meta/lib/oeqa/runtime/cases/x32lib.py19
-rw-r--r--meta/lib/oeqa/runtime/cases/xorg.py17
-rw-r--r--meta/lib/oeqa/runtime_cases/buildcvs.py32
-rw-r--r--meta/lib/oeqa/runtime_cases/buildgalculator.py26
-rw-r--r--meta/lib/oeqa/runtime_cases/buildiptables.py33
-rw-r--r--meta/lib/oeqa/runtime_cases/connman.py31
-rw-r--r--meta/lib/oeqa/runtime_cases/date.py31
-rw-r--r--meta/lib/oeqa/runtime_cases/df.py12
-rw-r--r--meta/lib/oeqa/runtime_cases/gcc.py47
-rw-r--r--meta/lib/oeqa/runtime_cases/kernelmodule.py34
-rw-r--r--meta/lib/oeqa/runtime_cases/ldd.py21
-rw-r--r--meta/lib/oeqa/runtime_cases/logrotate.py30
-rw-r--r--meta/lib/oeqa/runtime_cases/multilib.py42
-rw-r--r--meta/lib/oeqa/runtime_cases/pam.py25
-rw-r--r--meta/lib/oeqa/runtime_cases/perl.py30
-rw-r--r--meta/lib/oeqa/runtime_cases/ping.py22
-rw-r--r--meta/lib/oeqa/runtime_cases/python.py35
-rw-r--r--meta/lib/oeqa/runtime_cases/rpm.py120
-rw-r--r--meta/lib/oeqa/runtime_cases/scanelf.py28
-rw-r--r--meta/lib/oeqa/runtime_cases/scp.py22
-rw-r--r--meta/lib/oeqa/runtime_cases/skeletoninit.py29
-rw-r--r--meta/lib/oeqa/runtime_cases/ssh.py19
-rw-r--r--meta/lib/oeqa/runtime_cases/syslog.py52
-rw-r--r--meta/lib/oeqa/runtime_cases/x32lib.py18
-rw-r--r--meta/lib/oeqa/runtime_cases/xorg.py16
51 files changed, 1075 insertions, 906 deletions
diff --git a/meta/lib/oeqa/runtime_cases/_ptest.py b/meta/lib/oeqa/runtime/cases/_ptest.py
index a2432517e3..a2432517e3 100644
--- a/meta/lib/oeqa/runtime_cases/_ptest.py
+++ b/meta/lib/oeqa/runtime/cases/_ptest.py
diff --git a/meta/lib/oeqa/runtime_cases/_qemutiny.py b/meta/lib/oeqa/runtime/cases/_qemutiny.py
index a3c29f3572..a3c29f3572 100644
--- a/meta/lib/oeqa/runtime_cases/_qemutiny.py
+++ b/meta/lib/oeqa/runtime/cases/_qemutiny.py
diff --git a/meta/lib/oeqa/runtime/cases/buildcvs.py b/meta/lib/oeqa/runtime/cases/buildcvs.py
new file mode 100644
index 0000000000..341eb4959d
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/buildcvs.py
@@ -0,0 +1,35 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotFeature
5
6from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
7
8class BuildCvsTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 uri = 'http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13'
13 uri = '%s/cvs-1.12.13.tar.bz2' % uri
14 cls.project = TargetBuildProject(cls.tc.target,
15 uri,
16 dl_dir = cls.tc.td['DL_DIR'])
17 cls.project.download_archive()
18
19 @classmethod
20 def tearDownClass(cls):
21 cls.project.clean()
22
23 @OETestID(205)
24 @skipIfNotFeature('tools-sdk',
25 'Test requires tools-sdk to be in IMAGE_FEATURES')
26 @OETestDepends(['ssh.SSHTest.test_ssh'])
27 def test_cvs(self):
28 self.assertEqual(self.project.run_configure(), 0,
29 msg="Running configure failed")
30
31 self.assertEqual(self.project.run_make(), 0,
32 msg="Running make failed")
33
34 self.assertEqual(self.project.run_install(), 0,
35 msg="Running make install failed")
diff --git a/meta/lib/oeqa/runtime/cases/buildgalculator.py b/meta/lib/oeqa/runtime/cases/buildgalculator.py
new file mode 100644
index 0000000000..0bd76f9ea2
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/buildgalculator.py
@@ -0,0 +1,31 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotFeature
5
6from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
7
8class GalculatorTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 uri = 'http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2'
13 cls.project = TargetBuildProject(cls.tc.target,
14 uri,
15 dl_dir = cls.tc.td['DL_DIR'])
16 cls.project.download_archive()
17
18 @classmethod
19 def tearDownClass(cls):
20 cls.project.clean()
21
22 @OETestID(1526)
23 @skipIfNotFeature('tools-sdk',
24 'Test requires tools-sdk to be in IMAGE_FEATURES')
25 @OETestDepends(['ssh.SSHTest.test_ssh'])
26 def test_galculator(self):
27 self.assertEqual(self.project.run_configure(), 0,
28 msg="Running configure failed")
29
30 self.assertEqual(self.project.run_make(), 0,
31 msg="Running make failed")
diff --git a/meta/lib/oeqa/runtime/cases/buildiptables.py b/meta/lib/oeqa/runtime/cases/buildiptables.py
new file mode 100644
index 0000000000..bae80392d9
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/buildiptables.py
@@ -0,0 +1,39 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotFeature
5
6from oeqa.runtime.utils.targetbuildproject import TargetBuildProject
7
8class BuildIptablesTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 uri = 'http://downloads.yoctoproject.org/mirror/sources'
13 uri = '%s/iptables-1.4.13.tar.bz2' % uri
14 cls.project = TargetBuildProject(cls.tc.target,
15 uri,
16 dl_dir = cls.tc.td['DL_DIR'])
17 cls.project.download_archive()
18
19 @classmethod
20 def tearDownClass(cls):
21 cls.project.clean()
22
23 @OETestID(206)
24 @skipIfNotFeature('tools-sdk',
25 'Test requires tools-sdk to be in IMAGE_FEATURES')
26 @OETestDepends(['ssh.SSHTest.test_ssh'])
27 def test_iptables(self):
28 self.assertEqual(self.project.run_configure(), 0,
29 msg="Running configure failed")
30
31 self.assertEqual(self.project.run_make(), 0,
32 msg="Running make failed")
33
34 self.assertEqual(self.project.run_install(), 0,
35 msg="Running make install failed")
36
37 @classmethod
38 def tearDownClass(self):
39 self.project.clean()
diff --git a/meta/lib/oeqa/runtime/cases/connman.py b/meta/lib/oeqa/runtime/cases/connman.py
new file mode 100644
index 0000000000..8b47108a37
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/connman.py
@@ -0,0 +1,30 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.runtime.decorator.package import OEHasPackage
5
6class ConnmanTest(OERuntimeTestCase):
7
8 def service_status(self, service):
9 if oeRuntimeTest.hasFeature("systemd"):
10 (_, output) = self.target.run('systemctl status -l %s' % service)
11 return output
12 else:
13 return "Unable to get status or logs for %s" % service
14
15 @OETestID(961)
16 @OETestDepends(['ssh.SSHTest.test_ssh'])
17 @OEHasPackage(["connman"])
18 def test_connmand_help(self):
19 (status, output) = self.target.run('/usr/sbin/connmand --help')
20 msg = 'Failed to get connman help. Output: %s' % output
21 self.assertEqual(status, 0, msg=msg)
22
23 @OETestID(221)
24 @OETestDepends(['connman.ConnmanTest.test_connmand_help'])
25 def test_connmand_running(self):
26 cmd = '%s | grep [c]onnmand' % self.tc.target_cmds['ps']
27 (status, output) = self.target.run(cmd)
28 if status != 0:
29 self.logger.info(self.service_status("connman"))
30 self.fail("No connmand process running")
diff --git a/meta/lib/oeqa/runtime/cases/date.py b/meta/lib/oeqa/runtime/cases/date.py
new file mode 100644
index 0000000000..ece7338de7
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/date.py
@@ -0,0 +1,38 @@
1import re
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6
7class DateTest(OERuntimeTestCase):
8
9 def setUp(self):
10 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
11 self.logger.debug('Stopping systemd-timesyncd daemon')
12 self.target.run('systemctl stop systemd-timesyncd')
13
14 def tearDown(self):
15 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
16 self.logger.debug('Starting systemd-timesyncd daemon')
17 self.target.run('systemctl start systemd-timesyncd')
18
19 @OETestID(211)
20 @OETestDepends(['ssh.SSHTest.test_ssh'])
21 def test_date(self):
22 (status, output) = self.target.run('date +"%Y-%m-%d %T"')
23 msg = 'Failed to get initial date, output: %s' % output
24 self.assertEqual(status, 0, msg=msg)
25 oldDate = output
26
27 sampleDate = '"2016-08-09 10:00:00"'
28 (status, output) = self.target.run("date -s %s" % sampleDate)
29 self.assertEqual(status, 0, msg='Date set failed, output: %s' % output)
30
31 (status, output) = self.target.run("date -R")
32 p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
33 msg = 'The date was not set correctly, output: %s' % output
34 self.assertTrue(p, msg=msg)
35
36 (status, output) = self.target.run('date -s "%s"' % oldDate)
37 msg = 'Failed to reset date, output: %s' % output
38 self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/df.py b/meta/lib/oeqa/runtime/cases/df.py
new file mode 100644
index 0000000000..aecc32d7ce
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/df.py
@@ -0,0 +1,13 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4
5class DfTest(OERuntimeTestCase):
6
7 @OETestID(234)
8 @OETestDepends(['ssh.SSHTest.test_ssh'])
9 def test_df(self):
10 cmd = "df / | sed -n '2p' | awk '{print $4}'"
11 (status,output) = self.target.run(cmd)
12 msg = 'Not enough space on image. Current size is %s' % output
13 self.assertTrue(int(output)>5120, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/gcc.py b/meta/lib/oeqa/runtime/cases/gcc.py
new file mode 100644
index 0000000000..064fa49af1
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/gcc.py
@@ -0,0 +1,76 @@
1import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.core.decorator.data import skipIfNotFeature
7
8class GccCompileTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 dst = '/tmp/'
13 src = os.path.join(cls.tc.files_dir, 'test.c')
14 #dst = '/tmp/test.c'
15 cls.tc.target.copyTo(src, dst)
16
17 src = os.path.join(cls.tc.runtime_files_dir, 'testmakefile')
18 #dst = '/tmp/testmakefile'
19 cls.tc.target.copyTo(src, dst)
20
21 src = os.path.join(cls.tc.files_dir, 'test.cpp')
22 #dst = '/tmp/test.cpp'
23 cls.tc.target.copyTo(src, dst)
24
25 @classmethod
26 def tearDownClass(cls):
27 files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
28 cls.tc.target.run('rm %s' % files)
29
30 @OETestID(203)
31 @skipIfNotFeature('tools-sdk',
32 'Test requires tools-sdk to be in IMAGE_FEATURES')
33 @OETestDepends(['ssh.SSHTest.test_ssh'])
34 def test_gcc_compile(self):
35 status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
36 msg = 'gcc compile failed, output: %s' % output
37 self.assertEqual(status, 0, msg=msg)
38
39 status, output = self.target.run('/tmp/test')
40 msg = 'running compiled file failed, output: %s' % output
41 self.assertEqual(status, 0, msg=msg)
42
43 @OETestID(200)
44 @skipIfNotFeature('tools-sdk',
45 'Test requires tools-sdk to be in IMAGE_FEATURES')
46 @OETestDepends(['ssh.SSHTest.test_ssh'])
47 def test_gpp_compile(self):
48 status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
49 msg = 'g++ compile failed, output: %s' % output
50 self.assertEqual(status, 0, msg=msg)
51
52 status, output = self.target.run('/tmp/test')
53 msg = 'running compiled file failed, output: %s' % output
54 self.assertEqual(status, 0, msg=msg)
55
56 @OETestID(1142)
57 @skipIfNotFeature('tools-sdk',
58 'Test requires tools-sdk to be in IMAGE_FEATURES')
59 @OETestDepends(['ssh.SSHTest.test_ssh'])
60 def test_gpp2_compile(self):
61 status, output = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
62 msg = 'g++ compile failed, output: %s' % output
63 self.assertEqual(status, 0, msg=msg)
64
65 status, output = self.target.run('/tmp/test')
66 msg = 'running compiled file failed, output: %s' % output
67 self.assertEqual(status, 0, msg=msg)
68
69 @OETestID(204)
70 @skipIfNotFeature('tools-sdk',
71 'Test requires tools-sdk to be in IMAGE_FEATURES')
72 @OETestDepends(['ssh.SSHTest.test_ssh'])
73 def test_make(self):
74 status, output = self.target.run('cd /tmp; make -f testmakefile')
75 msg = 'running make failed, output %s' % output
76 self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/kernelmodule.py b/meta/lib/oeqa/runtime/cases/kernelmodule.py
new file mode 100644
index 0000000000..11ad7b7f01
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/kernelmodule.py
@@ -0,0 +1,40 @@
1import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.core.decorator.data import skipIfNotFeature
7
8class KernelModuleTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c')
13 dst = '/tmp/hellomod.c'
14 cls.tc.target.copyTo(src, dst)
15
16 src = os.path.join(cls.tc.runtime_files_dir, 'hellomod_makefile')
17 dst = '/tmp/Makefile'
18 cls.tc.target.copyTo(src, dst)
19
20 @classmethod
21 def tearDownClass(cls):
22 files = '/tmp/Makefile /tmp/hellomod.c'
23 cls.tc.target.run('rm %s' % files)
24
25 @OETestID(1541)
26 @skipIfNotFeature('tools-sdk',
27 'Test requires tools-sdk to be in IMAGE_FEATURES')
28 @OETestDepends(['gcc.GccCompileTest.test_gcc_compile'])
29 def test_kernel_module(self):
30 cmds = [
31 'cd /usr/src/kernel && make scripts',
32 'cd /tmp && make',
33 'cd /tmp && insmod hellomod.ko',
34 'lsmod | grep hellomod',
35 'dmesg | grep Hello',
36 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"'
37 ]
38 for cmd in cmds:
39 status, output = self.target.run(cmd, 900)
40 self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
diff --git a/meta/lib/oeqa/runtime/cases/ldd.py b/meta/lib/oeqa/runtime/cases/ldd.py
new file mode 100644
index 0000000000..c6d92fd5af
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ldd.py
@@ -0,0 +1,25 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotFeature
5
6class LddTest(OERuntimeTestCase):
7
8 @OETestID(962)
9 @skipIfNotFeature('tools-sdk',
10 'Test requires tools-sdk to be in IMAGE_FEATURES')
11 @OETestDepends(['ssh.SSHTest.test_ssh'])
12 def test_ldd_exists(self):
13 status, output = self.target.run('which ldd')
14 msg = 'ldd does not exist in PATH: which ldd: %s' % output
15 self.assertEqual(status, 0, msg=msg)
16
17 @OETestID(239)
18 @OETestDepends(['ldd.LddTest.test_ldd_exists'])
19 def test_ldd_rtldlist_check(self):
20 cmd = ('for i in $(which ldd | xargs cat | grep "^RTLDLIST"| '
21 'cut -d\'=\' -f2|tr -d \'"\'); '
22 'do test -f $i && echo $i && break; done')
23 status, output = self.target.run(cmd)
24 msg = "ldd path not correct or RTLDLIST files don't exist."
25 self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py
new file mode 100644
index 0000000000..992fef2989
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/logrotate.py
@@ -0,0 +1,42 @@
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
4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID
7from oeqa.runtime.decorator.package import OEHasPackage
8
9class LogrotateTest(OERuntimeTestCase):
10
11 @classmethod
12 def tearDownClass(cls):
13 cls.tc.target.run('rm -rf $HOME/logrotate_dir')
14
15 @OETestID(1544)
16 @OETestDepends(['ssh.SSHTest.test_ssh'])
17 @OEHasPackage(['logrotate'])
18 def test_1_logrotate_setup(self):
19 status, output = self.target.run('mkdir $HOME/logrotate_dir')
20 msg = 'Could not create logrotate_dir. Output: %s' % output
21 self.assertEqual(status, 0, msg = msg)
22
23 cmd = ('sed -i "s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#"'
24 ' /etc/logrotate.conf')
25 status, output = self.target.run(cmd)
26 msg = ('Could not write to logrotate.conf file. Status and output: '
27 ' %s and %s' % (status, output))
28 self.assertEqual(status, 0, msg = msg)
29
30 @OETestID(1542)
31 @OETestDepends(['logrotate.LogrotateTest.test_1_logrotate_setup'])
32 def test_2_logrotate(self):
33 status, output = self.target.run('logrotate -f /etc/logrotate.conf')
34 msg = ('logrotate service could not be reloaded. Status and output: '
35 '%s and %s' % (status, output))
36 self.assertEqual(status, 0, msg = msg)
37
38 _, output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')
39 msg = ('new logfile could not be created. List of files within log '
40 'directory: %s' % (
41 self.target.run('ls -la $HOME/logrotate_dir')[1]))
42 self.assertTrue(int(output)>=3, msg = msg)
diff --git a/meta/lib/oeqa/runtime/cases/multilib.py b/meta/lib/oeqa/runtime/cases/multilib.py
new file mode 100644
index 0000000000..8f6d2b24a6
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/multilib.py
@@ -0,0 +1,41 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotInDataVar
5from oeqa.runtime.decorator.package import OEHasPackage
6
7class MultilibTest(OERuntimeTestCase):
8
9 def archtest(self, binary, arch):
10 """
11 Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
12 """
13
14 status, output = self.target.run('readelf -h %s' % binary)
15 self.assertEqual(status, 0, 'Failed to readelf %s' % binary)
16
17 l = [l.split()[1] for l in output.split('\n') if "Class:" in l]
18 if l:
19 theclass = l[0]
20 else:
21 self.fail('Cannot parse readelf. Output:\n%s' % output)
22
23 msg = "%s isn't %s (is %s)" % (binary, arch, theclass)
24 self.assertEqual(theclass, arch, msg=msg)
25
26 @skipIfNotInDataVar('MULTILIBS', 'multilib:lib32',
27 "This isn't a multilib:lib32 image")
28 @OETestID(201)
29 @OETestDepends(['ssh.SSHTest.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 @OETestID(279)
38 @OETestDepends(['multilib.MultilibTest.test_check_multilib_libc'])
39 @OEHasPackage(['lib32-connman'])
40 def test_file_connman(self):
41 self.archtest("/usr/sbin/connmand", "ELF32")
diff --git a/meta/lib/oeqa/runtime/cases/pam.py b/meta/lib/oeqa/runtime/cases/pam.py
new file mode 100644
index 0000000000..3654cdc946
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/pam.py
@@ -0,0 +1,33 @@
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
4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID
7from oeqa.core.decorator.data import skipIfNotFeature
8
9class PamBasicTest(OERuntimeTestCase):
10
11 @OETestID(1543)
12 @skipIfNotFeature('pam', 'Test requires pam to be in DISTRO_FEATURES')
13 @OETestDepends(['ssh.SSHTest.test_ssh'])
14 def test_pam(self):
15 status, output = self.target.run('login --help')
16 msg = ('login command does not work as expected. '
17 'Status and output:%s and %s' % (status, output))
18 self.assertEqual(status, 1, msg = msg)
19
20 status, output = self.target.run('passwd --help')
21 msg = ('passwd command does not work as expected. '
22 'Status and output:%s and %s' % (status, output))
23 self.assertEqual(status, 0, msg = msg)
24
25 status, output = self.target.run('su --help')
26 msg = ('su command does not work as expected. '
27 'Status and output:%s and %s' % (status, output))
28 self.assertEqual(status, 0, msg = msg)
29
30 status, output = self.target.run('useradd --help')
31 msg = ('useradd command does not work as expected. '
32 'Status and output:%s and %s' % (status, output))
33 self.assertEqual(status, 0, msg = msg)
diff --git a/meta/lib/oeqa/runtime_cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py
index cc2d0617f5..a53a3608bd 100644
--- a/meta/lib/oeqa/runtime_cases/parselogs.py
+++ b/meta/lib/oeqa/runtime/cases/parselogs.py
@@ -1,8 +1,12 @@
1import os 1import os
2import unittest 2
3import subprocess 3from subprocess import check_output
4from oeqa.oetest import oeRuntimeTest 4from shutil import rmtree
5from oeqa.utils.decorators import * 5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.core.decorator.oeid import OETestID
8from oeqa.core.decorator.data import skipIfDataVar
9from oeqa.runtime.decorator.package import OEHasPackage
6 10
7#in the future these lists could be moved outside of module 11#in the future these lists could be moved outside of module
8errors = ["error", "cannot", "can\'t", "failed"] 12errors = ["error", "cannot", "can\'t", "failed"]
@@ -168,144 +172,173 @@ ignore_errors = {
168 172
169log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"] 173log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"]
170 174
171class ParseLogsTest(oeRuntimeTest): 175class ParseLogsTest(OERuntimeTestCase):
172 176
173 @classmethod 177 @classmethod
174 def setUpClass(self): 178 def setUpClass(cls):
175 self.errors = errors 179 cls.errors = errors
176 180
177 # When systemd is enabled we need to notice errors on 181 # When systemd is enabled we need to notice errors on
178 # circular dependencies in units. 182 # circular dependencies in units.
179 if self.hasFeature("systemd"): 183 if 'systemd' in cls.td.get('DISTRO_FEATURES', ''):
180 self.errors.extend([ 184 cls.errors.extend([
181 'Found ordering cycle on', 185 'Found ordering cycle on',
182 'Breaking ordering cycle by deleting job', 186 'Breaking ordering cycle by deleting job',
183 'deleted to break ordering cycle', 187 'deleted to break ordering cycle',
184 'Ordering cycle found, skipping', 188 'Ordering cycle found, skipping',
185 ]) 189 ])
186 190
187 self.ignore_errors = ignore_errors 191 cls.ignore_errors = ignore_errors
188 self.log_locations = log_locations 192 cls.log_locations = log_locations
189 self.msg = "" 193 cls.msg = ''
190 (is_lsb, location) = oeRuntimeTest.tc.target.run("which LSB_Test.sh") 194 is_lsb, _ = cls.tc.target.run("which LSB_Test.sh")
191 if is_lsb == 0: 195 if is_lsb == 0:
192 for machine in self.ignore_errors: 196 for machine in cls.ignore_errors:
193 self.ignore_errors[machine] = self.ignore_errors[machine] + video_related 197 cls.ignore_errors[machine] = cls.ignore_errors[machine] \
198 + video_related
194 199
195 def getMachine(self): 200 def getMachine(self):
196 return oeRuntimeTest.tc.d.getVar("MACHINE") 201 return self.td.get('MACHINE', '')
197 202
198 def getWorkdir(self): 203 def getWorkdir(self):
199 return oeRuntimeTest.tc.d.getVar("WORKDIR") 204 return self.td.get('WORKDIR', '')
200 205
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. 206 # Get some information on the CPU of the machine to display at the
207 # beginning of the output. This info might be useful in some cases.
202 def getHardwareInfo(self): 208 def getHardwareInfo(self):
203 hwi = "" 209 hwi = ""
204 (status, cpu_name) = self.target.run("cat /proc/cpuinfo | grep \"model name\" | head -n1 | awk 'BEGIN{FS=\":\"}{print $2}'") 210 cmd = ('cat /proc/cpuinfo | grep "model name" | head -n1 | '
205 (status, cpu_physical_cores) = self.target.run("cat /proc/cpuinfo | grep \"cpu cores\" | head -n1 | awk {'print $4'}") 211 " awk 'BEGIN{FS=\":\"}{print $2}'")
206 (status, cpu_logical_cores) = self.target.run("cat /proc/cpuinfo | grep \"processor\" | wc -l") 212 _, cpu_name = self.target.run(cmd)
207 (status, cpu_arch) = self.target.run("uname -m") 213
208 hwi += "Machine information: \n" 214 cmd = ('cat /proc/cpuinfo | grep "cpu cores" | head -n1 | '
209 hwi += "*******************************\n" 215 "awk {'print $4'}")
210 hwi += "Machine name: "+self.getMachine()+"\n" 216 _, cpu_physical_cores = self.target.run(cmd)
211 hwi += "CPU: "+str(cpu_name)+"\n" 217
212 hwi += "Arch: "+str(cpu_arch)+"\n" 218 cmd = 'cat /proc/cpuinfo | grep "processor" | wc -l'
213 hwi += "Physical cores: "+str(cpu_physical_cores)+"\n" 219 _, cpu_logical_cores = self.target.run(cmd)
214 hwi += "Logical cores: "+str(cpu_logical_cores)+"\n" 220
215 hwi += "*******************************\n" 221 _, cpu_arch = self.target.run('uname -m')
222
223 hwi += 'Machine information: \n'
224 hwi += '*******************************\n'
225 hwi += 'Machine name: ' + self.getMachine() + '\n'
226 hwi += 'CPU: ' + str(cpu_name) + '\n'
227 hwi += 'Arch: ' + str(cpu_arch)+ '\n'
228 hwi += 'Physical cores: ' + str(cpu_physical_cores) + '\n'
229 hwi += 'Logical cores: ' + str(cpu_logical_cores) + '\n'
230 hwi += '*******************************\n'
231
216 return hwi 232 return hwi
217 233
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 234 # Go through the log locations provided and if it's a folder
219 #it to that list 235 # create a list with all the .log files in it, if it's a file
236 # just add it to that list.
220 def getLogList(self, log_locations): 237 def getLogList(self, log_locations):
221 logs = [] 238 logs = []
222 for location in log_locations: 239 for location in log_locations:
223 (status, output) = self.target.run("test -f "+str(location)) 240 status, _ = self.target.run('test -f ' + str(location))
224 if (status == 0): 241 if status == 0:
225 logs.append(str(location)) 242 logs.append(str(location))
226 else: 243 else:
227 (status, output) = self.target.run("test -d "+str(location)) 244 status, _ = self.target.run('test -d ' + str(location))
228 if (status == 0): 245 if status == 0:
229 (status, output) = self.target.run("find "+str(location)+"/*.log -maxdepth 1 -type f") 246 cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f'
230 if (status == 0): 247 status, output = self.target.run(cmd)
248 if status == 0:
231 output = output.splitlines() 249 output = output.splitlines()
232 for logfile in output: 250 for logfile in output:
233 logs.append(os.path.join(location,str(logfile))) 251 logs.append(os.path.join(location, str(logfile)))
234 return logs 252 return logs
235 253
236 #copy the log files to be parsed locally 254 # Copy the log files to be parsed locally
237 def transfer_logs(self, log_list): 255 def transfer_logs(self, log_list):
238 workdir = self.getWorkdir() 256 workdir = self.getWorkdir()
239 self.target_logs = workdir + '/' + 'target_logs' 257 self.target_logs = workdir + '/' + 'target_logs'
240 target_logs = self.target_logs 258 target_logs = self.target_logs
241 if not os.path.exists(target_logs): 259 if os.path.exists(target_logs):
242 os.makedirs(target_logs) 260 rmtree(self.target_logs)
243 bb.utils.remove(self.target_logs + "/*") 261 os.makedirs(target_logs)
244 for f in log_list: 262 for f in log_list:
245 self.target.copy_from(f, target_logs) 263 self.target.copyFrom(str(f), target_logs)
246 264
247 #get the local list of logs 265 # Get the local list of logs
248 def get_local_log_list(self, log_locations): 266 def get_local_log_list(self, log_locations):
249 self.transfer_logs(self.getLogList(log_locations)) 267 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)) ] 268 list_dir = os.listdir(self.target_logs)
269 dir_files = [os.path.join(self.target_logs, f) for f in list_dir]
270 logs = [f for f in dir_files if os.path.isfile(f)]
251 return logs 271 return logs
252 272
253 #build the grep command to be used with filters and exclusions 273 # Build the grep command to be used with filters and exclusions
254 def build_grepcmd(self, errors, ignore_errors, log): 274 def build_grepcmd(self, errors, ignore_errors, log):
255 grepcmd = "grep " 275 grepcmd = 'grep '
256 grepcmd +="-Ei \"" 276 grepcmd += '-Ei "'
257 for error in errors: 277 for error in errors:
258 grepcmd += error+"|" 278 grepcmd += error + '|'
259 grepcmd = grepcmd[:-1] 279 grepcmd = grepcmd[:-1]
260 grepcmd += "\" "+str(log)+" | grep -Eiv \'" 280 grepcmd += '" ' + str(log) + " | grep -Eiv \'"
281
261 try: 282 try:
262 errorlist = ignore_errors[self.getMachine()] 283 errorlist = ignore_errors[self.getMachine()]
263 except KeyError: 284 except KeyError:
264 self.msg += "No ignore list found for this machine, using default\n" 285 self.msg += 'No ignore list found for this machine, using default\n'
265 errorlist = ignore_errors['default'] 286 errorlist = ignore_errors['default']
287
266 for ignore_error in errorlist: 288 for ignore_error in errorlist:
267 ignore_error = ignore_error.replace("(", "\(") 289 ignore_error = ignore_error.replace('(', '\(')
268 ignore_error = ignore_error.replace(")", "\)") 290 ignore_error = ignore_error.replace(')', '\)')
269 ignore_error = ignore_error.replace("'", ".") 291 ignore_error = ignore_error.replace("'", '.')
270 ignore_error = ignore_error.replace("?", "\?") 292 ignore_error = ignore_error.replace('?', '\?')
271 ignore_error = ignore_error.replace("[", "\[") 293 ignore_error = ignore_error.replace('[', '\[')
272 ignore_error = ignore_error.replace("]", "\]") 294 ignore_error = ignore_error.replace(']', '\]')
273 ignore_error = ignore_error.replace("*", "\*") 295 ignore_error = ignore_error.replace('*', '\*')
274 ignore_error = ignore_error.replace("0-9", "[0-9]") 296 ignore_error = ignore_error.replace('0-9', '[0-9]')
275 grepcmd += ignore_error+"|" 297 grepcmd += ignore_error + '|'
276 grepcmd = grepcmd[:-1] 298 grepcmd = grepcmd[:-1]
277 grepcmd += "\'" 299 grepcmd += "\'"
300
278 return grepcmd 301 return grepcmd
279 302
280 #grep only the errors so that their context could be collected. Default context is 10 lines before and after the error itself 303 # Grep only the errors so that their context could be collected.
281 def parse_logs(self, errors, ignore_errors, logs, lines_before = 10, lines_after = 10): 304 # Default context is 10 lines before and after the error itself
305 def parse_logs(self, errors, ignore_errors, logs,
306 lines_before = 10, lines_after = 10):
282 results = {} 307 results = {}
283 rez = [] 308 rez = []
284 grep_output = '' 309 grep_output = ''
310
285 for log in logs: 311 for log in logs:
286 result = None 312 result = None
287 thegrep = self.build_grepcmd(errors, ignore_errors, log) 313 thegrep = self.build_grepcmd(errors, ignore_errors, log)
314
288 try: 315 try:
289 result = subprocess.check_output(thegrep, shell=True).decode("utf-8") 316 result = check_output(thegrep, shell=True).decode('utf-8')
290 except: 317 except:
291 pass 318 pass
292 if (result is not None): 319
320 if result is not None:
293 results[log.replace('target_logs/','')] = {} 321 results[log.replace('target_logs/','')] = {}
294 rez = result.splitlines() 322 rez = result.splitlines()
323
295 for xrez in rez: 324 for xrez in rez:
296 try: 325 try:
297 grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]).decode("utf-8") 326 cmd = ['grep', '-F', xrez, '-B', str(lines_before)]
327 cmd += ['-A', str(lines_after), log]
328 grep_output = check_output(cmd).decode('utf-8')
298 except: 329 except:
299 pass 330 pass
300 results[log.replace('target_logs/','')][xrez]=grep_output 331 results[log.replace('target_logs/','')][xrez]=grep_output
332
301 return results 333 return results
302 334
303 #get the output of dmesg and write it in a file. This file is added to log_locations. 335 # Get the output of dmesg and write it in a file.
336 # This file is added to log_locations.
304 def write_dmesg(self): 337 def write_dmesg(self):
305 (status, dmesg) = self.target.run("dmesg > /tmp/dmesg_output.log") 338 (status, dmesg) = self.target.run('dmesg > /tmp/dmesg_output.log')
306 339
307 @testcase(1059) 340 @OETestID(1059)
308 @skipUnlessPassed('test_ssh') 341 @OETestDepends(['ssh.SSHTest.test_ssh'])
309 def test_parselogs(self): 342 def test_parselogs(self):
310 self.write_dmesg() 343 self.write_dmesg()
311 log_list = self.get_local_log_list(self.log_locations) 344 log_list = self.get_local_log_list(self.log_locations)
@@ -313,13 +346,13 @@ class ParseLogsTest(oeRuntimeTest):
313 print(self.getHardwareInfo()) 346 print(self.getHardwareInfo())
314 errcount = 0 347 errcount = 0
315 for log in result: 348 for log in result:
316 self.msg += "Log: "+log+"\n" 349 self.msg += 'Log: ' + log + '\n'
317 self.msg += "-----------------------\n" 350 self.msg += '-----------------------\n'
318 for error in result[log]: 351 for error in result[log]:
319 errcount += 1 352 errcount += 1
320 self.msg += "Central error: "+str(error)+"\n" 353 self.msg += 'Central error: ' + str(error) + '\n'
321 self.msg += "***********************\n" 354 self.msg += '***********************\n'
322 self.msg += result[str(log)][str(error)]+"\n" 355 self.msg += result[str(log)][str(error)] + '\n'
323 self.msg += "***********************\n" 356 self.msg += '***********************\n'
324 self.msg += "%s errors found in logs." % errcount 357 self.msg += '%s errors found in logs.' % errcount
325 self.assertEqual(errcount, 0, msg=self.msg) 358 self.assertEqual(errcount, 0, msg=self.msg)
diff --git a/meta/lib/oeqa/runtime/cases/perl.py b/meta/lib/oeqa/runtime/cases/perl.py
new file mode 100644
index 0000000000..d0b7e8ed92
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/perl.py
@@ -0,0 +1,37 @@
1import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.runtime.decorator.package import OEHasPackage
7
8class PerlTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 src = os.path.join(cls.tc.files_dir, 'test.pl')
13 dst = '/tmp/test.pl'
14 cls.tc.target.copyTo(src, dst)
15
16 @classmethod
17 def tearDownClass(cls):
18 dst = '/tmp/test.pl'
19 cls.tc.target.run('rm %s' % dst)
20
21 @OETestID(1141)
22 @OETestDepends(['ssh.SSHTest.test_ssh'])
23 @OEHasPackage(['perl'])
24 def test_perl_exists(self):
25 status, output = self.target.run('which perl')
26 msg = 'Perl binary not in PATH or not on target.'
27 self.assertEqual(status, 0, msg=msg)
28
29 @OETestID(208)
30 @OETestDepends(['perl.PerlTest.test_perl_exists'])
31 def test_perl_works(self):
32 status, output = self.target.run('perl /tmp/test.pl')
33 msg = 'Exit status was not 0. Output: %s' % output
34 self.assertEqual(status, 0, msg=msg)
35
36 msg = 'Incorrect output: %s' % output
37 self.assertEqual(output, "the value of a is 0.01", msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py
new file mode 100644
index 0000000000..02f580abee
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -0,0 +1,24 @@
1from subprocess import Popen, PIPE
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.oeid import OETestID
5from oeqa.core.decorator.oetimeout import OETimeout
6
7class PingTest(OERuntimeTestCase):
8
9 @OETimeout(30)
10 @OETestID(964)
11 def test_ping(self):
12 output = ''
13 count = 0
14 while count < 5:
15 cmd = 'ping -c 1 %s' % self.target.ip
16 proc = Popen(cmd, shell=True, stdout=PIPE)
17 output += proc.communicate()[0].decode('utf-8')
18 if proc.poll() == 0:
19 count += 1
20 else:
21 count = 0
22 msg = ('Expected 5 consecutive, got %d.\n'
23 'ping output is:\n%s' % (count,output))
24 self.assertEqual(count, 5, msg = msg)
diff --git a/meta/lib/oeqa/runtime/cases/python.py b/meta/lib/oeqa/runtime/cases/python.py
new file mode 100644
index 0000000000..bf3e179163
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/python.py
@@ -0,0 +1,43 @@
1import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.runtime.decorator.package import OEHasPackage
7
8class PythonTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 src = os.path.join(cls.tc.files_dir, 'test.py')
13 dst = '/tmp/test.py'
14 cls.tc.target.copyTo(src, dst)
15
16 @classmethod
17 def tearDownClass(cls):
18 dst = '/tmp/test.py'
19 cls.tc.target.run('rm %s' % dst)
20
21 @OETestID(1145)
22 @OETestDepends(['ssh.SSHTest.test_ssh'])
23 @OEHasPackage(['python-core'])
24 def test_python_exists(self):
25 status, output = self.target.run('which python')
26 msg = 'Python binary not in PATH or not on target.'
27 self.assertEqual(status, 0, msg=msg)
28
29 @OETestID(965)
30 @OETestDepends(['python.PythonTest.test_python_exists'])
31 def test_python_stdout(self):
32 status, output = self.target.run('python /tmp/test.py')
33 msg = 'Exit status was not 0. Output: %s' % output
34 self.assertEqual(status, 0, msg=msg)
35
36 msg = 'Incorrect output: %s' % output
37 self.assertEqual(output, "the value of a is 0.01", msg=msg)
38
39 @OETestID(1146)
40 @OETestDepends(['python.PythonTest.test_python_stdout'])
41 def test_python_testfile(self):
42 status, output = self.target.run('ls /tmp/testfile.python')
43 self.assertEqual(status, 0, msg='Python test file generate failed.')
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
new file mode 100644
index 0000000000..532fbf82eb
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -0,0 +1,141 @@
1import os
2import fnmatch
3
4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID
7from oeqa.core.decorator.data import skipIfDataVar
8from oeqa.runtime.decorator.package import OEHasPackage
9from oeqa.core.utils.path import findFile
10
11class RpmBasicTest(OERuntimeTestCase):
12
13 @classmethod
14 def setUpClass(cls):
15 if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm':
16 cls.skipTest('Tests require image to be build from rpm')
17
18 @OETestID(960)
19 @OETestDepends(['ssh.SSHTest.test_ssh'])
20 def test_rpm_help(self):
21 status, output = self.target.run('rpm --help')
22 msg = 'status and output: %s and %s' % (status, output)
23 self.assertEqual(status, 0, msg=msg)
24
25 @OETestID(191)
26 @OETestDepends(['rpm.RpmBasicTest.test_rpm_help'])
27 def test_rpm_query(self):
28 status, output = self.target.run('rpm -q rpm')
29 msg = 'status and output: %s and %s' % (status, output)
30 self.assertEqual(status, 0, msg=msg)
31
32class RpmInstallRemoveTest(OERuntimeTestCase):
33
34 @classmethod
35 def setUpClass(cls):
36 if cls.tc.td['PACKAGE_CLASSES'].split()[0] != 'package_rpm':
37 cls.skipTest('Tests require image to be build from rpm')
38
39 pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_')
40 rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch)
41 # Pick rpm-doc as a test file to get installed, because it's small
42 # and it will always be built for standard targets
43 rpm_doc = 'rpm-doc-*.%s.rpm' % pkgarch
44 for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc):
45 test_file = os.path.join(rpmdir, f)
46 dst = '/tmp/rpm-doc.rpm'
47 cls.tc.target.copyTo(test_file, dst)
48
49 @classmethod
50 def tearDownClass(cls):
51 dst = '/tmp/rpm-doc.rpm'
52 cls.tc.target.run('rm -f %s' % dst)
53
54 @OETestID(192)
55 @OETestDepends(['rpm.RpmBasicTest.test_rpm_help'])
56 def test_rpm_install(self):
57 status, output = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
58 msg = 'Failed to install rpm-doc package: %s' % output
59 self.assertEqual(status, 0, msg=msg)
60
61 @OETestID(194)
62 @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install'])
63 def test_rpm_remove(self):
64 status,output = self.target.run('rpm -e rpm-doc')
65 msg = 'Failed to remove rpm-doc package: %s' % output
66 self.assertEqual(status, 0, msg=msg)
67
68 @OETestID(1096)
69 @OETestDepends(['rpm.RpmBasicTest.test_rpm_query'])
70 def test_rpm_query_nonroot(self):
71
72 def set_up_test_user(u):
73 status, output = self.target.run('id -u %s' % u)
74 if status:
75 status, output = self.target.run('useradd %s' % u)
76 msg = 'Failed to create new user: %s' % output
77 self.assertTrue(status == 0, msg=msg)
78
79 def exec_as_test_user(u):
80 status, output = self.target.run('su -c id %s' % u)
81 msg = 'Failed to execute as new user'
82 self.assertTrue("({0})".format(u) in output, msg=msg)
83
84 status, output = self.target.run('su -c "rpm -qa" %s ' % u)
85 msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output)
86 self.assertEqual(status, 0, msg=msg)
87
88 def unset_up_test_user(u):
89 status, output = self.target.run('userdel -r %s' % u)
90 msg = 'Failed to erase user: %s' % output
91 self.assertTrue(status == 0, msg=msg)
92
93 tuser = 'test1'
94
95 try:
96 set_up_test_user(tuser)
97 exec_as_test_user(tuser)
98 finally:
99 unset_up_test_user(tuser)
100
101 @OETestID(195)
102 @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove'])
103 def test_check_rpm_install_removal_log_file_size(self):
104 """
105 Summary: Check rpm install/removal log file size
106 Expected: There should be some method to keep rpm log in a small size .
107 Product: BSPs
108 Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
109 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
110 """
111 db_files_cmd = 'ls /var/lib/rpm/__db.*'
112 get_log_size_cmd = "du /var/lib/rpm/log/log.* | awk '{print $1}'"
113
114 # Make sure that some database files are under /var/lib/rpm as '__db.xxx'
115 status, output = self.target.run(db_files_cmd)
116 msg = 'Failed to find database files under /var/lib/rpm/ as __db.xxx'
117 self.assertEqual(0, status, msg=msg)
118
119 # Remove the package just in case
120 self.target.run('rpm -e rpm-doc')
121
122 # Install/Remove a package 10 times
123 for i in range(10):
124 status, output = self.target.run('rpm -ivh /tmp/rpm-doc.rpm')
125 msg = 'Failed to install rpm-doc package. Reason: {}'.format(output)
126 self.assertEqual(0, status, msg=msg)
127
128 status, output = self.target.run('rpm -e rpm-doc')
129 msg = 'Failed to remove rpm-doc package. Reason: {}'.format(output)
130 self.assertEqual(0, status, msg=msg)
131
132 # Get the size of log file
133 status, output = self.target.run(get_log_size_cmd)
134 msg = 'Failed to get the final size of the log file.'
135 self.assertEqual(0, status, msg=msg)
136
137 # Compare each log size
138 for log_file_size in output:
139 msg = ('Log file size is greater that expected (~10MB), '
140 'found {} bytes'.format(log_file_size))
141 self.assertLessEqual(int(log_file_size), 11264, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/scanelf.py b/meta/lib/oeqa/runtime/cases/scanelf.py
new file mode 100644
index 0000000000..3ba1f78af9
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/scanelf.py
@@ -0,0 +1,26 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.runtime.decorator.package import OEHasPackage
5
6class ScanelfTest(OERuntimeTestCase):
7 scancmd = 'scanelf --quiet --recursive --mount --ldpath --path'
8
9 @OETestID(966)
10 @OETestDepends(['ssh.SSHTest.test_ssh'])
11 @OEHasPackage(['pax-utils'])
12 def test_scanelf_textrel(self):
13 # print TEXTREL information
14 cmd = '%s --textrel' % self.scancmd
15 status, output = self.target.run(cmd)
16 msg = '\n'.join([cmd, output])
17 self.assertEqual(output.strip(), '', msg=msg)
18
19 @OETestID(967)
20 @OETestDepends(['scanelf.ScanelfTest.test_scanelf_textrel'])
21 def test_scanelf_rpath(self):
22 # print RPATH information
23 cmd = '%s --textrel --rpath' % self.scancmd
24 status, output = self.target.run(cmd)
25 msg = '\n'.join([cmd, output])
26 self.assertEqual(output.strip(), '', msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/scp.py b/meta/lib/oeqa/runtime/cases/scp.py
new file mode 100644
index 0000000000..f488a6175b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/scp.py
@@ -0,0 +1,33 @@
1import os
2from tempfile import mkstemp
3
4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID
7
8class ScpTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 cls.tmp_fd, cls.tmp_path = mkstemp()
13 with os.fdopen(cls.tmp_fd, 'w') as f:
14 f.seek(2 ** 22 -1)
15 f.write(os.linesep)
16
17 @classmethod
18 def tearDownClass(cls):
19 os.remove(cls.tmp_path)
20
21 @OETestID(220)
22 @OETestDepends(['ssh.SSHTest.test_ssh'])
23 def test_scp_file(self):
24 dst = '/tmp/test_scp_file'
25
26 (status, output) = self.target.copyTo(self.tmp_path, dst)
27 msg = 'File could not be copied. Output: %s' % output
28 self.assertEqual(status, 0, msg=msg)
29
30 (status, output) = self.target.run('ls -la %s' % dst)
31 self.assertEqual(status, 0, msg = 'SCP test failed')
32
33 self.target.run('rm %s' % dst)
diff --git a/meta/lib/oeqa/runtime/cases/skeletoninit.py b/meta/lib/oeqa/runtime/cases/skeletoninit.py
new file mode 100644
index 0000000000..4fdcf033a3
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/skeletoninit.py
@@ -0,0 +1,33 @@
1# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=284
2# testcase. Image under test must have meta-skeleton layer in bblayers and
3# IMAGE_INSTALL_append = " service" in local.conf
4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID
7from oeqa.core.decorator.data import skipIfDataVar
8from oeqa.runtime.decorator.package import OEHasPackage
9
10class SkeletonBasicTest(OERuntimeTestCase):
11
12 @OETestDepends(['ssh.SSHTest.test_ssh'])
13 @OEHasPackage(['service'])
14 @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
15 'Not appropiate for systemd image')
16 def test_skeleton_availability(self):
17 status, output = self.target.run('ls /etc/init.d/skeleton')
18 msg = 'skeleton init script not found. Output:\n%s' % output
19 self.assertEqual(status, 0, msg=msg)
20
21 status, output = self.target.run('ls /usr/sbin/skeleton-test')
22 msg = 'skeleton-test not found. Output:\n%s' % output
23 self.assertEqual(status, 0, msg=msg)
24
25 @OETestID(284)
26 @OETestDepends(['skeletoninit.SkeletonBasicTest.test_skeleton_availability'])
27 def test_skeleton_script(self):
28 output1 = self.target.run("/etc/init.d/skeleton start")[1]
29 cmd = '%s | grep [s]keleton-test' % self.tc.target_cmds['ps']
30 status, output2 = self.target.run(cmd)
31 msg = ('Skeleton script could not be started:'
32 '\n%s\n%s' % (output1, output2))
33 self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime_cases/smart.py b/meta/lib/oeqa/runtime/cases/smart.py
index dde1c4d792..dde1c4d792 100644
--- a/meta/lib/oeqa/runtime_cases/smart.py
+++ b/meta/lib/oeqa/runtime/cases/smart.py
diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py
new file mode 100644
index 0000000000..eca167969a
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ssh.py
@@ -0,0 +1,15 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4
5class SSHTest(OERuntimeTestCase):
6
7 @OETestID(224)
8 @OETestDepends(['ping.PingTest.test_ping'])
9 def test_ssh(self):
10 (status, output) = self.target.run('uname -a')
11 self.assertEqual(status, 0, msg='SSH Test failed: %s' % output)
12 (status, output) = self.target.run('cat /etc/masterimage')
13 msg = "This isn't the right image - /etc/masterimage " \
14 "shouldn't be here %s" % output
15 self.assertEqual(status, 1, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/syslog.py b/meta/lib/oeqa/runtime/cases/syslog.py
new file mode 100644
index 0000000000..1016e67e93
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/syslog.py
@@ -0,0 +1,57 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfDataVar
5from oeqa.runtime.decorator.package import OEHasPackage
6
7class SyslogTest(OERuntimeTestCase):
8
9 @OETestID(201)
10 @OETestDepends(['ssh.SSHTest.test_ssh'])
11 @OEHasPackage(["busybox-syslog", "sysklogd"])
12 def test_syslog_running(self):
13 cmd = '%s | grep -i [s]yslogd' % self.tc.target_cmds['ps']
14 status, output = self.target.run(cmd)
15 msg = "No syslogd process; ps output: %s" % output
16 self.assertEqual(status, 0, msg=msg)
17
18class SyslogTestConfig(OERuntimeTestCase):
19
20 @OETestID(1149)
21 @OETestDepends(['syslog.SyslogTest.test_syslog_running'])
22 def test_syslog_logger(self):
23 status, output = self.target.run('logger foobar')
24 msg = "Can't log into syslog. Output: %s " % output
25 self.assertEqual(status, 0, msg=msg)
26
27 status, output = self.target.run('grep foobar /var/log/messages')
28 if status != 0:
29 if self.tc.td.get("VIRTUAL-RUNTIME_init_manager") == "systemd":
30 status, output = self.target.run('journalctl -o cat | grep foobar')
31 else:
32 status, output = self.target.run('logread | grep foobar')
33 msg = ('Test log string not found in /var/log/messages or logread.'
34 ' Output: %s ' % output)
35 self.assertEqual(status, 0, msg=msg)
36
37 @OETestID(202)
38 @OETestDepends(['syslog.SyslogTestConfig.test_syslog_logger'])
39 @OEHasPackage(["!sysklogd", "busybox"])
40 @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
41 'Not appropiate for systemd image')
42 def test_syslog_startup_config(self):
43 cmd = 'echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf'
44 self.target.run(cmd)
45 status, output = self.target.run('/etc/init.d/syslog restart')
46 msg = ('Could not restart syslog service. Status and output:'
47 ' %s and %s' % (status,output))
48 self.assertEqual(status, 0, msg)
49
50 cmd = 'logger foobar && grep foobar /var/log/test'
51 status,output = self.target.run(cmd)
52 msg = 'Test log string not found. Output: %s ' % output
53 self.assertEqual(status, 0, msg=msg)
54
55 cmd = "sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf"
56 self.target.run(cmd)
57 self.target.run('/etc/init.d/syslog restart')
diff --git a/meta/lib/oeqa/runtime_cases/systemd.py b/meta/lib/oeqa/runtime/cases/systemd.py
index 52feb1b31e..db69384c8a 100644
--- a/meta/lib/oeqa/runtime_cases/systemd.py
+++ b/meta/lib/oeqa/runtime/cases/systemd.py
@@ -1,28 +1,27 @@
1import unittest
2import re 1import re
3from oeqa.oetest import oeRuntimeTest, skipModule 2import time
4from oeqa.utils.decorators import *
5 3
6def setUpModule(): 4from oeqa.runtime.case import OERuntimeTestCase
7 if not oeRuntimeTest.hasFeature("systemd"): 5from oeqa.core.decorator.depends import OETestDepends
8 skipModule("target doesn't have systemd in DISTRO_FEATURES") 6from oeqa.core.decorator.oeid import OETestID
9 if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"): 7from oeqa.core.decorator.data import skipIfDataVar, skipIfNotDataVar
10 skipModule("systemd is not the init manager for this image") 8from oeqa.runtime.decorator.package import OEHasPackage
9from oeqa.core.decorator.data import skipIfNotFeature
11 10
11class SystemdTest(OERuntimeTestCase):
12 12
13class SystemdTest(oeRuntimeTest): 13 def systemctl(self, action='', target='', expected=0, verbose=False):
14
15 def systemctl(self, action = '', target = '', expected = 0, verbose = False):
16 command = 'systemctl %s %s' % (action, target) 14 command = 'systemctl %s %s' % (action, target)
17 status, output = self.target.run(command) 15 status, output = self.target.run(command)
18 message = '\n'.join([command, output]) 16 message = '\n'.join([command, output])
19 if status != expected and verbose: 17 if status != expected and verbose:
20 message += self.target.run('systemctl status --full %s' % target)[1] 18 cmd = 'systemctl status --full %s' % target
19 message += self.target.run(cmd)[1]
21 self.assertEqual(status, expected, message) 20 self.assertEqual(status, expected, message)
22 return output 21 return output
23 22
24 #TODO: use pyjournalctl instead 23 #TODO: use pyjournalctl instead
25 def journalctl(self, args='',l_match_units=[]): 24 def journalctl(self, args='',l_match_units=None):
26 """ 25 """
27 Request for the journalctl output to the current target system 26 Request for the journalctl output to the current target system
28 27
@@ -36,31 +35,23 @@ class SystemdTest(oeRuntimeTest):
36 -ValueError, on a journalctl call with filtering by l_match_units that 35 -ValueError, on a journalctl call with filtering by l_match_units that
37 returned no entries 36 returned no entries
38 """ 37 """
39 query_units="" 38
40 if len(l_match_units): 39 query_units=''
40 if l_match_units:
41 query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units] 41 query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units]
42 query_units = " ".join(query_units) 42 query_units = ' '.join(query_units)
43 command = 'journalctl %s %s' %(args, query_units) 43 command = 'journalctl %s %s' %(args, query_units)
44 status, output = self.target.run(command) 44 status, output = self.target.run(command)
45 if status: 45 if status:
46 raise AssertionError("Command '%s' returned non-zero exit \ 46 raise AssertionError("Command '%s' returned non-zero exit "
47 code %d:\n%s" % (command, status, output)) 47 'code %d:\n%s' % (command, status, output))
48 if len(output) == 1 and "-- No entries --" in output: 48 if len(output) == 1 and "-- No entries --" in output:
49 raise ValueError("List of units to match: %s, returned no entries" 49 raise ValueError('List of units to match: %s, returned no entries'
50 % l_match_units) 50 % l_match_units)
51 return output 51 return output
52 52
53class SystemdBasicTests(SystemdTest): 53class SystemdBasicTests(SystemdTest):
54 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): 55 def settle(self):
65 """ 56 """
66 Block until systemd has finished activating any units being activated, 57 Block until systemd has finished activating any units being activated,
@@ -70,7 +61,6 @@ class SystemdBasicTests(SystemdTest):
70 activating, or (False, message string) if there are still units 61 activating, or (False, message string) if there are still units
71 activating (generally, failing units that restart). 62 activating (generally, failing units that restart).
72 """ 63 """
73 import time
74 endtime = time.time() + (60 * 2) 64 endtime = time.time() + (60 * 2)
75 while True: 65 while True:
76 status, output = self.target.run('systemctl --state=activating') 66 status, output = self.target.run('systemctl --state=activating')
@@ -80,55 +70,65 @@ class SystemdBasicTests(SystemdTest):
80 return (False, output) 70 return (False, output)
81 time.sleep(10) 71 time.sleep(10)
82 72
83 @testcase(550) 73 @skipIfNotFeature('systemd',
84 @skipUnlessPassed('test_systemd_basic') 74 'Test requires systemd to be in DISTRO_FEATURES')
75 @skipIfNotDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
76 'systemd is not the init manager for this image')
77 @OETestDepends(['ssh.SSHTest.test_ssh'])
78 def test_systemd_basic(self):
79 self.systemctl('--version')
80
81 @OETestID(551)
82 @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
83 def test_systemd_list(self):
84 self.systemctl('list-unit-files')
85
86 @OETestID(550)
87 @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
85 def test_systemd_failed(self): 88 def test_systemd_failed(self):
86 settled, output = self.settle() 89 settled, output = self.settle()
87 self.assertTrue(settled, msg="Timed out waiting for systemd to settle:\n" + output) 90 msg = "Timed out waiting for systemd to settle:\n%s" % output
91 self.assertTrue(settled, msg=msg)
88 92
89 output = self.systemctl('list-units', '--failed') 93 output = self.systemctl('list-units', '--failed')
90 match = re.search("0 loaded units listed", output) 94 match = re.search('0 loaded units listed', output)
91 if not match: 95 if not match:
92 output += self.systemctl('status --full --failed') 96 output += self.systemctl('status --full --failed')
93 self.assertTrue(match, msg="Some systemd units failed:\n%s" % output) 97 self.assertTrue(match, msg='Some systemd units failed:\n%s' % output)
94 98
95 99
96class SystemdServiceTests(SystemdTest): 100class SystemdServiceTests(SystemdTest):
97 101
98 def check_for_avahi(self): 102 @OEHasPackage(['avahi-daemon'])
99 if not self.hasPackage('avahi-daemon'): 103 @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
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 def test_systemd_status(self):
104 self.check_for_avahi()
105 self.systemctl('status --full', 'avahi-daemon.service') 105 self.systemctl('status --full', 'avahi-daemon.service')
106 106
107 @testcase(695) 107 @OETestID(695)
108 @skipUnlessPassed('test_systemd_status') 108 @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status'])
109 def test_systemd_stop_start(self): 109 def test_systemd_stop_start(self):
110 self.check_for_avahi()
111 self.systemctl('stop', 'avahi-daemon.service') 110 self.systemctl('stop', 'avahi-daemon.service')
112 self.systemctl('is-active', 'avahi-daemon.service', expected=3, verbose=True) 111 self.systemctl('is-active', 'avahi-daemon.service',
112 expected=3, verbose=True)
113 self.systemctl('start','avahi-daemon.service') 113 self.systemctl('start','avahi-daemon.service')
114 self.systemctl('is-active', 'avahi-daemon.service', verbose=True) 114 self.systemctl('is-active', 'avahi-daemon.service', verbose=True)
115 115
116 @testcase(696) 116 @OETestID(696)
117 @skipUnlessPassed('test_systemd_basic') 117 @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status'])
118 def test_systemd_disable_enable(self): 118 def test_systemd_disable_enable(self):
119 self.check_for_avahi()
120 self.systemctl('disable', 'avahi-daemon.service') 119 self.systemctl('disable', 'avahi-daemon.service')
121 self.systemctl('is-enabled', 'avahi-daemon.service', expected=1) 120 self.systemctl('is-enabled', 'avahi-daemon.service', expected=1)
122 self.systemctl('enable', 'avahi-daemon.service') 121 self.systemctl('enable', 'avahi-daemon.service')
123 self.systemctl('is-enabled', 'avahi-daemon.service') 122 self.systemctl('is-enabled', 'avahi-daemon.service')
124 123
125class SystemdJournalTests(SystemdTest): 124class SystemdJournalTests(SystemdTest):
126 @skipUnlessPassed('test_ssh') 125
126 @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
127 def test_systemd_journal(self): 127 def test_systemd_journal(self):
128 (status, output) = self.target.run('journalctl') 128 status, output = self.target.run('journalctl')
129 self.assertEqual(status, 0, output) 129 self.assertEqual(status, 0, output)
130 130
131 @skipUnlessPassed('test_systemd_basic') 131 @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic'])
132 def test_systemd_boot_time(self, systemd_TimeoutStartSec=90): 132 def test_systemd_boot_time(self, systemd_TimeoutStartSec=90):
133 """ 133 """
134 Get the target boot time from journalctl and log it 134 Get the target boot time from journalctl and log it
@@ -138,41 +138,44 @@ class SystemdJournalTests(SystemdTest):
138 unit start timeout to compare against 138 unit start timeout to compare against
139 """ 139 """
140 140
141 # the expression chain that uniquely identifies the time boot message 141 # The expression chain that uniquely identifies the time boot message.
142 expr_items=["Startup finished","kernel", "userspace","\.$"] 142 expr_items=['Startup finished', 'kernel', 'userspace','\.$']
143 try: 143 try:
144 output = self.journalctl(args="-o cat --reverse") 144 output = self.journalctl(args='-o cat --reverse')
145 except AssertionError: 145 except AssertionError:
146 self.fail("Error occurred while calling journalctl") 146 self.fail('Error occurred while calling journalctl')
147 if not len(output): 147 if not len(output):
148 self.fail("Error, unable to get startup time from systemd journal") 148 self.fail('Error, unable to get startup time from systemd journal')
149 149
150 # check for the regular expression items that match the startup time 150 # Check for the regular expression items that match the startup time.
151 for line in output.split('\n'): 151 for line in output.split('\n'):
152 check_match = "".join(re.findall(".*".join(expr_items), line)) 152 check_match = ''.join(re.findall('.*'.join(expr_items), line))
153 if check_match: break 153 if check_match:
154 # put the startup time in the test log 154 break
155 # Put the startup time in the test log
155 if check_match: 156 if check_match:
156 print("%s" % check_match) 157 self.tc.logger.info('%s' % check_match)
157 else: 158 else:
158 self.skipTest("Error at obtaining the boot time from journalctl") 159 self.skipTest('Error at obtaining the boot time from journalctl')
159 boot_time_sec = 0 160 boot_time_sec = 0
160 161
161 # get the numeric values from the string and convert them to seconds 162 # 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 # same data will be placed in list and string for manipulation.
163 l_boot_time = check_match.split(" ")[-2:] 164 l_boot_time = check_match.split(' ')[-2:]
164 s_boot_time = " ".join(l_boot_time) 165 s_boot_time = ' '.join(l_boot_time)
165 try: 166 try:
166 # Obtain the minutes it took to boot 167 # Obtain the minutes it took to boot.
167 if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit(): 168 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 boot_time_min = s_boot_time.split('min')[0]
169 # convert to seconds and accumulate it 170 # Convert to seconds and accumulate it.
170 boot_time_sec += int(boot_time_min) * 60 171 boot_time_sec += int(boot_time_min) * 60
171 # Obtain the seconds it took to boot and accumulate 172 # Obtain the seconds it took to boot and accumulate.
172 boot_time_sec += float(l_boot_time[1].split("s")[0]) 173 boot_time_sec += float(l_boot_time[1].split('s')[0])
173 except ValueError: 174 except ValueError:
174 self.skipTest("Error when parsing time from boot string") 175 self.skipTest('Error when parsing time from boot string')
175 #Assert the target boot time against systemd's unit start timeout 176
177 # Assert the target boot time against systemd's unit start timeout.
176 if boot_time_sec > systemd_TimeoutStartSec: 178 if boot_time_sec > systemd_TimeoutStartSec:
177 print("Target boot time %s exceeds systemd's TimeoutStartSec %s"\ 179 msg = ("Target boot time %s exceeds systemd's TimeoutStartSec %s"
178 %(boot_time_sec, systemd_TimeoutStartSec)) 180 % (boot_time_sec, systemd_TimeoutStartSec))
181 self.tc.logger.info(msg)
diff --git a/meta/lib/oeqa/runtime/cases/x32lib.py b/meta/lib/oeqa/runtime/cases/x32lib.py
new file mode 100644
index 0000000000..8da0154e7b
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/x32lib.py
@@ -0,0 +1,19 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotInDataVar
5
6class X32libTest(OERuntimeTestCase):
7
8 @skipIfNotInDataVar('DEFAULTTUNE', 'x86-64-x32',
9 'DEFAULTTUNE is not set to x86-64-x32')
10 @OETestID(281)
11 @OETestDepends(['ssh.SSHTest.test_ssh'])
12 def test_x32_file(self):
13 cmd = 'readelf -h /bin/ls | grep Class | grep ELF32'
14 status1 = self.target.run(cmd)[0]
15 cmd = 'readelf -h /bin/ls | grep Machine | grep X86-64'
16 status2 = self.target.run(cmd)[0]
17 msg = ("/bin/ls isn't an X86-64 ELF32 binary. readelf says: %s" %
18 self.target.run("readelf -h /bin/ls")[1])
19 self.assertTrue(status1 == 0 and status2 == 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/xorg.py b/meta/lib/oeqa/runtime/cases/xorg.py
new file mode 100644
index 0000000000..2124813e3c
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/xorg.py
@@ -0,0 +1,17 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.core.decorator.data import skipIfNotFeature
5
6class XorgTest(OERuntimeTestCase):
7
8 @OETestID(1151)
9 @skipIfNotFeature('x11-base',
10 'Test requires x11 to be in IMAGE_FEATURES')
11 @OETestDepends(['ssh.SSHTest.test_ssh'])
12 def test_xorg_running(self):
13 cmd ='%s | grep -v xinit | grep [X]org' % self.tc.target_cmds['ps']
14 status, output = self.target.run(cmd)
15 msg = ('Xorg does not appear to be running %s' %
16 self.target.run(self.tc.target_cmds['ps'])[1])
17 self.assertEqual(status, 0, msg=msg)
diff --git a/meta/lib/oeqa/runtime_cases/buildcvs.py b/meta/lib/oeqa/runtime_cases/buildcvs.py
deleted file mode 100644
index a5ca3a5b37..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/buildgalculator.py b/meta/lib/oeqa/runtime_cases/buildgalculator.py
deleted file mode 100644
index 20f0a79367..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/buildiptables.py b/meta/lib/oeqa/runtime_cases/buildiptables.py
deleted file mode 100644
index a0e82f0dde..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/connman.py b/meta/lib/oeqa/runtime_cases/connman.py
deleted file mode 100644
index 003fefe2ce..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/date.py b/meta/lib/oeqa/runtime_cases/date.py
deleted file mode 100644
index 6f3516a92f..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/df.py b/meta/lib/oeqa/runtime_cases/df.py
deleted file mode 100644
index 09569d5ff6..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/gcc.py b/meta/lib/oeqa/runtime_cases/gcc.py
deleted file mode 100644
index 6edb89f6f2..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/kernelmodule.py b/meta/lib/oeqa/runtime_cases/kernelmodule.py
deleted file mode 100644
index 2ac1bc93d4..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/ldd.py b/meta/lib/oeqa/runtime_cases/ldd.py
deleted file mode 100644
index 47b3885df2..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/logrotate.py b/meta/lib/oeqa/runtime_cases/logrotate.py
deleted file mode 100644
index 063280b5f7..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/multilib.py b/meta/lib/oeqa/runtime_cases/multilib.py
deleted file mode 100644
index 5cce24f5f4..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/pam.py b/meta/lib/oeqa/runtime_cases/pam.py
deleted file mode 100644
index b7f2dfa49b..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/perl.py b/meta/lib/oeqa/runtime_cases/perl.py
deleted file mode 100644
index 6bf98f1ccb..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/ping.py b/meta/lib/oeqa/runtime_cases/ping.py
deleted file mode 100644
index 0f27447926..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/python.py b/meta/lib/oeqa/runtime_cases/python.py
deleted file mode 100644
index 93e822c71c..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/rpm.py b/meta/lib/oeqa/runtime_cases/rpm.py
deleted file mode 100644
index f1c4763fc0..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/scanelf.py b/meta/lib/oeqa/runtime_cases/scanelf.py
deleted file mode 100644
index 67e02ff455..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/scp.py b/meta/lib/oeqa/runtime_cases/scp.py
deleted file mode 100644
index cf36cfa5d5..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/skeletoninit.py b/meta/lib/oeqa/runtime_cases/skeletoninit.py
deleted file mode 100644
index cb0cb9b4cf..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/ssh.py b/meta/lib/oeqa/runtime_cases/ssh.py
deleted file mode 100644
index 0e76d5d512..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/syslog.py b/meta/lib/oeqa/runtime_cases/syslog.py
deleted file mode 100644
index 8f550329e7..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/x32lib.py b/meta/lib/oeqa/runtime_cases/x32lib.py
deleted file mode 100644
index 2f98dbf71e..0000000000
--- a/meta/lib/oeqa/runtime_cases/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_cases/xorg.py b/meta/lib/oeqa/runtime_cases/xorg.py
deleted file mode 100644
index 12bcd371af..0000000000
--- a/meta/lib/oeqa/runtime_cases/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])