summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2019-04-22 06:32:40 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-18 11:28:58 +0100
commitacf1e0b1fe19feffd8ac350f699502b6c43559a0 (patch)
tree95a4526943390056cf20e83e72131a1a5738a75b /meta
parent7b96f74d8ff6beb19309460f773db2a893516ad4 (diff)
downloadpoky-acf1e0b1fe19feffd8ac350f699502b6c43559a0.tar.gz
ltp: add runtime test
This adds the framework for running ltp tests. Here are some times: math: 61 syscalls: 3957 dio: 18472 io: 29 mm: 551 ipc: 48 sched: 165 nptl: 46 pty: 37 containers: 52 controllers: 9625 filecaps: 27 cap_bounds: 27 fcntl-locktests: 29 connectors: 27 timers: 37 commands: 165 net.ipv6_lib: 30 input: 29 fs_perms_simple: 31 fs: 3476 fsx: 30 fs_bind: 28 fs_ext4: 28 cve: 675 (From OE-Core rev: 2a5767f584c159f4711afc5a01ee740d44c94d02) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/runtime/cases/ltp.py124
1 files changed, 124 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ltp.py b/meta/lib/oeqa/runtime/cases/ltp.py
new file mode 100644
index 0000000000..628494e453
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ltp.py
@@ -0,0 +1,124 @@
1# LTP runtime
2#
3# Copyright (c) 2019 MontaVista Software, LLC
4#
5# This program is free software; you can redistribute it and/or modify it
6# under the terms and conditions of the GNU General Public License,
7# version 2, as published by the Free Software Foundation.
8#
9# This program is distributed in the hope it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12# more details.
13#
14import time
15import datetime
16import pprint
17
18from oeqa.runtime.case import OERuntimeTestCase
19from oeqa.core.decorator.depends import OETestDepends
20from oeqa.runtime.decorator.package import OEHasPackage
21from oeqa.utils.logparser import LtpParser
22
23class LtpTestBase(OERuntimeTestCase):
24
25 @classmethod
26 def setUpClass(cls):
27 cls.ltp_startup()
28
29 @classmethod
30 def tearDownClass(cls):
31 cls.ltp_finishup()
32
33 @classmethod
34 def ltp_startup(cls):
35 cls.sections = {}
36 cls.failmsg = ""
37 test_log_dir = os.path.join(cls.td.get('WORKDIR', ''), 'testimage')
38 timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
39
40 cls.ltptest_log_dir_link = os.path.join(test_log_dir, 'ltp_log')
41 cls.ltptest_log_dir = '%s.%s' % (cls.ltptest_log_dir_link, timestamp)
42 os.makedirs(cls.ltptest_log_dir)
43
44 cls.tc.target.run("mkdir -p /opt/ltp/results")
45
46 if not hasattr(cls.tc, "extraresults"):
47 cls.tc.extraresults = {}
48 cls.extras = cls.tc.extraresults
49 cls.extras['ltpresult.rawlogs'] = {'log': ""}
50
51
52 @classmethod
53 def ltp_finishup(cls):
54 cls.extras['ltpresult.sections'] = cls.sections
55
56 # update symlink to ltp_log
57 if os.path.exists(cls.ltptest_log_dir_link):
58 os.remove(cls.ltptest_log_dir_link)
59 os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
60
61 if cls.failmsg:
62 cls.fail(cls.failmsg)
63
64class LtpTest(LtpTestBase):
65
66 ltp_groups = ["math", "syscalls", "dio", "io", "mm", "ipc", "sched", "nptl", "pty", "containers", "controllers", "filecaps", "cap_bounds", "fcntl-locktests", "connectors","timers", "commands", "net.ipv6_lib", "input","fs_perms_simple"]
67
68 ltp_fs = ["fs", "fsx", "fs_bind", "fs_ext4"]
69 # skip kernel cpuhotplug
70 ltp_kernel = ["power_management_tests", "hyperthreading ", "kernel_misc", "hugetlb"]
71 ltp_groups += ltp_fs
72
73 def runltp(self, ltp_group):
74 cmd = '/opt/ltp/runltp -f %s -p -q -r /opt/ltp -l /opt/ltp/results/%s -I 1 -d /opt/ltp' % (ltp_group, ltp_group)
75 starttime = time.time()
76 (status, output) = self.target.run(cmd)
77 endtime = time.time()
78
79 with open(os.path.join(self.ltptest_log_dir, "%s-raw.log" % ltp_group), 'w') as f:
80 f.write(output)
81
82 self.extras['ltpresult.rawlogs']['log'] = self.extras['ltpresult.rawlogs']['log'] + output
83
84 # copy nice log from DUT
85 dst = os.path.join(self.ltptest_log_dir, "%s" % ltp_group )
86 remote_src = "/opt/ltp/results/%s" % ltp_group
87 (status, output) = self.target.copyFrom(remote_src, dst)
88 msg = 'File could not be copied. Output: %s' % output
89 self.assertEqual(status, 0, msg=msg)
90
91 parser = LtpParser()
92 results, sections = parser.parse(dst)
93
94 runtime = int(endtime-starttime)
95 sections['duration'] = runtime
96 self.sections[ltp_group] = sections
97
98 failed_tests = {}
99 for test in results:
100 result = results[test]
101 testname = ("ltpresult." + ltp_group + "." + test)
102 self.extras[testname] = {'status': result}
103 if result == 'FAILED':
104 failed_tests[ltp_group] = test
105
106 if failed_tests:
107 self.failmsg = self.failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests)
108
109 # LTP runtime tests
110 @OETestDepends(['ssh.SSHTest.test_ssh'])
111 @OEHasPackage(["ltp"])
112 def test_ltp_help(self):
113 (status, output) = self.target.run('/opt/ltp/runltp --help')
114 msg = 'Failed to get ltp help. Output: %s' % output
115 self.assertEqual(status, 0, msg=msg)
116
117 @OETestDepends(['ltp.LtpTest.test_ltp_help'])
118 def test_ltp_groups(self):
119 for ltp_group in self.ltp_groups:
120 self.runltp(ltp_group)
121
122 @OETestDepends(['ltp.LtpTest.test_ltp_groups'])
123 def test_ltp_runltp_cve(self):
124 self.runltp("cve")