summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-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")