diff options
-rw-r--r-- | meta/lib/oeqa/runtime/cases/ltp_compliance.py | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ltp_compliance.py b/meta/lib/oeqa/runtime/cases/ltp_compliance.py new file mode 100644 index 0000000000..be9a9a32af --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/ltp_compliance.py | |||
@@ -0,0 +1,104 @@ | |||
1 | # LTP compliance 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 | # | ||
14 | |||
15 | import time | ||
16 | import datetime | ||
17 | import pprint | ||
18 | |||
19 | from oeqa.runtime.case import OERuntimeTestCase | ||
20 | from oeqa.core.decorator.depends import OETestDepends | ||
21 | from oeqa.runtime.decorator.package import OEHasPackage | ||
22 | from oeqa.utils.logparser import LtpComplianceParser | ||
23 | |||
24 | class LtpPosixBase(OERuntimeTestCase): | ||
25 | |||
26 | @classmethod | ||
27 | def setUpClass(cls): | ||
28 | cls.ltp_startup() | ||
29 | |||
30 | @classmethod | ||
31 | def tearDownClass(cls): | ||
32 | cls.ltp_finishup() | ||
33 | |||
34 | @classmethod | ||
35 | def ltp_startup(cls): | ||
36 | cls.sections = {} | ||
37 | cls.failmsg = "" | ||
38 | test_log_dir = os.path.join(cls.td.get('WORKDIR', ''), 'testimage') | ||
39 | timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') | ||
40 | |||
41 | cls.ltptest_log_dir_link = os.path.join(test_log_dir, 'ltpcomp_log') | ||
42 | cls.ltptest_log_dir = '%s.%s' % (cls.ltptest_log_dir_link, timestamp) | ||
43 | os.makedirs(cls.ltptest_log_dir) | ||
44 | |||
45 | cls.tc.target.run("mkdir -p /opt/ltp/results") | ||
46 | |||
47 | if not hasattr(cls.tc, "extraresults"): | ||
48 | cls.tc.extraresults = {} | ||
49 | cls.extras = cls.tc.extraresults | ||
50 | cls.extras['ltpposixresult.rawlogs'] = {'log': ""} | ||
51 | |||
52 | |||
53 | @classmethod | ||
54 | def ltp_finishup(cls): | ||
55 | cls.extras['ltpposixresult.sections'] = cls.sections | ||
56 | |||
57 | # update symlink to ltp_log | ||
58 | if os.path.exists(cls.ltptest_log_dir_link): | ||
59 | os.remove(cls.ltptest_log_dir_link) | ||
60 | |||
61 | os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link) | ||
62 | |||
63 | if cls.failmsg: | ||
64 | cls.fail(cls.failmsg) | ||
65 | |||
66 | class LtpPosixTest(LtpPosixBase): | ||
67 | posix_groups = ["AIO", "MEM", "MSG", "SEM", "SIG", "THR", "TMR", "TPS"] | ||
68 | |||
69 | def runltp(self, posix_group): | ||
70 | cmd = "/opt/ltp/bin/run-posix-option-group-test.sh %s 2>@1 | tee /opt/ltp/results/%s" % (posix_group, posix_group) | ||
71 | starttime = time.time() | ||
72 | (status, output) = self.target.run(cmd) | ||
73 | endtime = time.time() | ||
74 | |||
75 | with open(os.path.join(self.ltptest_log_dir, "%s" % posix_group), 'w') as f: | ||
76 | f.write(output) | ||
77 | |||
78 | self.extras['ltpposixresult.rawlogs']['log'] = self.extras['ltpposixresult.rawlogs']['log'] + output | ||
79 | |||
80 | parser = LtpComplianceParser() | ||
81 | results, sections = parser.parse(os.path.join(self.ltptest_log_dir, "%s" % posix_group)) | ||
82 | |||
83 | runtime = int(endtime-starttime) | ||
84 | sections['duration'] = runtime | ||
85 | self.sections[posix_group] = sections | ||
86 | |||
87 | failed_tests = {} | ||
88 | for test in results: | ||
89 | result = results[test] | ||
90 | testname = ("ltpposixresult." + posix_group + "." + test) | ||
91 | self.extras[testname] = {'status': result} | ||
92 | if result == 'FAILED': | ||
93 | failed_tests[posix_group] = test | ||
94 | |||
95 | if failed_tests: | ||
96 | self.failmsg = self.failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests) | ||
97 | |||
98 | # LTP Posix compliance runtime tests | ||
99 | |||
100 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
101 | @OEHasPackage(["ltp"]) | ||
102 | def test_posix_groups(self): | ||
103 | for posix_group in self.posix_groups: | ||
104 | self.runltp(posix_group) | ||