summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2019-09-03 16:56:41 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-09-07 21:56:43 +0100
commitd8f39cc971cb43a6660803eb717103c85ffaeb28 (patch)
tree125671ed8a70ca72e1eebcf96167d3dbb7a05419 /meta/lib/oeqa/selftest/cases
parentdb62562db5f1ccae95b30135b794415755fbf01d (diff)
downloadpoky-d8f39cc971cb43a6660803eb717103c85ffaeb28.tar.gz
oeqa/selftest/binutils: Create selftest case for binutils test suite
Create a oeqa selftest test case to execute the binutils test suites and report the results. The results are populated into the extraresults variable of the test case which are written to testresults.json for resulttool to analyse. (From OE-Core rev: e5629aa4bd939072208f6eb5b30a98e17eb6a8ae) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases')
-rw-r--r--meta/lib/oeqa/selftest/cases/binutils.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/binutils.py b/meta/lib/oeqa/selftest/cases/binutils.py
new file mode 100644
index 0000000000..4edee09390
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/binutils.py
@@ -0,0 +1,64 @@
1# SPDX-License-Identifier: MIT
2import os
3import sys
4import re
5import logging
6from oeqa.core.decorator import OETestTag
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars
9
10def parse_values(content):
11 for i in content:
12 for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
13 if i.startswith(v + ": "):
14 yield i[len(v) + 2:].strip(), v
15 break
16
17@OETestTag("machine")
18class BinutilsCrossSelfTest(OESelftestTestCase):
19 @classmethod
20 def setUpClass(cls):
21 super().setUpClass()
22 if not hasattr(cls.tc, "extraresults"):
23 cls.tc.extraresults = {}
24
25 if "ptestresult.sections" not in cls.tc.extraresults:
26 cls.tc.extraresults["ptestresult.sections"] = {}
27
28 def test_binutils(self):
29 self.run_binutils("binutils")
30
31 def test_gas(self):
32 self.run_binutils("gas")
33
34 def test_ld(self):
35 self.run_binutils("ld")
36
37 def run_binutils(self, suite):
38 features = []
39 features.append('CHECK_TARGETS = "{0}"'.format(suite))
40 self.write_config("\n".join(features))
41
42 recipe = "binutils-cross-testsuite"
43 bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe)
44 builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"]
45
46 bitbake("{0} -c check".format(recipe))
47
48 ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite
49 self.tc.extraresults["ptestresult.sections"][ptestsuite] = {}
50
51 sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite))
52 if not os.path.exists(sumspath):
53 sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite))
54
55 failed = 0
56 with open(sumspath, "r") as f:
57 for test, result in parse_values(f):
58 self.tc.extraresults["ptestresult.{}.{}".format(ptestsuite, test)] = {"status" : result}
59 if result == "FAIL":
60 self.logger.info("failed: '{}'".format(test))
61 failed += 1
62
63 self.assertEqual(failed, 0)
64