summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/runner.py
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2019-09-07 12:55:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-09-07 21:56:43 +0100
commit1220faf6659e404f6aa2c3155eb8840ac361c2b2 (patch)
tree4abb88044618505836b00434a3e6ef9609caacbb /meta/lib/oeqa/core/runner.py
parent52ba1a3d44c89f4c38d6851504fe8b70c9e8e07e (diff)
downloadpoky-1220faf6659e404f6aa2c3155eb8840ac361c2b2.tar.gz
oeqa/core: Implement proper extra result collection and serialization
Implement handling of extra result (e.g. ptestresult) collection with the addition of a "extraresults" extraction function in OETestResult. In order to be able to serialize and deserialize the extraresults data, allow OETestResult add* calls to take a details kwarg. The subunit module can handle cross-process transfer of binary data for the details kwarg. With a TestResult proxy class to sit inbetween to encode and decode to and from json. (From OE-Core rev: b0831d43606415807af80e2aa1d0566d0b8c209c) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/core/runner.py')
-rw-r--r--meta/lib/oeqa/core/runner.py41
1 files changed, 37 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index 930620ea19..3060a00fbf 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -43,6 +43,7 @@ class OETestResult(_TestResult):
43 self.starttime = {} 43 self.starttime = {}
44 self.endtime = {} 44 self.endtime = {}
45 self.progressinfo = {} 45 self.progressinfo = {}
46 self.extraresults = {}
46 47
47 # Inject into tc so that TestDepends decorator can see results 48 # Inject into tc so that TestDepends decorator can see results
48 tc.results = self 49 tc.results = self
@@ -129,19 +130,51 @@ class OETestResult(_TestResult):
129 130
130 return 'UNKNOWN', None 131 return 'UNKNOWN', None
131 132
132 def addSuccess(self, test): 133 def extractExtraResults(self, test, details = None):
134 extraresults = None
135 if details is not None and "extraresults" in details:
136 extraresults = details.get("extraresults", {})
137 elif hasattr(test, "extraresults"):
138 extraresults = test.extraresults
139
140 if extraresults is not None:
141 for k, v in extraresults.items():
142 # handle updating already existing entries (e.g. ptestresults.sections)
143 if k in self.extraresults:
144 self.extraresults[k].update(v)
145 else:
146 self.extraresults[k] = v
147
148 def addError(self, test, *args, details = None):
149 self.extractExtraResults(test, details = details)
150 return super(OETestResult, self).addError(test, *args)
151
152 def addFailure(self, test, *args, details = None):
153 self.extractExtraResults(test, details = details)
154 return super(OETestResult, self).addFailure(test, *args)
155
156 def addSuccess(self, test, details = None):
133 #Added so we can keep track of successes too 157 #Added so we can keep track of successes too
134 self.successes.append((test, None)) 158 self.successes.append((test, None))
135 super(OETestResult, self).addSuccess(test) 159 self.extractExtraResults(test, details = details)
160 return super(OETestResult, self).addSuccess(test)
161
162 def addExpectedFailure(self, test, *args, details = None):
163 self.extractExtraResults(test, details = details)
164 return super(OETestResult, self).addExpectedFailure(test, *args)
165
166 def addUnexpectedSuccess(self, test, details = None):
167 self.extractExtraResults(test, details = details)
168 return super(OETestResult, self).addUnexpectedSuccess(test)
136 169
137 def logDetails(self, json_file_dir=None, configuration=None, result_id=None, 170 def logDetails(self, json_file_dir=None, configuration=None, result_id=None,
138 dump_streams=False): 171 dump_streams=False):
139 self.tc.logger.info("RESULTS:") 172 self.tc.logger.info("RESULTS:")
140 173
141 result = {} 174 result = self.extraresults
142 logs = {} 175 logs = {}
143 if hasattr(self.tc, "extraresults"): 176 if hasattr(self.tc, "extraresults"):
144 result = self.tc.extraresults 177 result.update(self.tc.extraresults)
145 178
146 for case_name in self.tc._registry['cases']: 179 for case_name in self.tc._registry['cases']:
147 case = self.tc._registry['cases'][case_name] 180 case = self.tc._registry['cases'][case_name]