summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/utils/concurrencytest.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-09 14:35:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-12 09:04:26 +0100
commit4970590ecd0fec3aee9de419076057bcd169af8f (patch)
treeb4e84b3909a3d37cad3f42406dfaab970c49a09e /meta/lib/oeqa/core/utils/concurrencytest.py
parent52f1b4050baa517c4accae230e8b06cc37465f1c (diff)
downloadpoky-4970590ecd0fec3aee9de419076057bcd169af8f.tar.gz
oeqa/concurrenttest: Patch subunit module to handle classSetup failures
Currently setupClass errors were not being mapped back to the failing tests and they were hence being marked as UNKNOWN and the test statistics were inaccurate. This is because whilst the errors were being encoded into the test results stream, the decoder doesn't cope with an error outside a testStart event. We patch in an addError handler to the outsideTest parser so that this does get handled in a way similar to the non-concurrent case. It would be nice if we didn't have to do this but there doesn't seem to be any other way to fix this other than forking subunit. We also make a minor change so another of our changes can cope with tests without a start time. (From OE-Core rev: 8f7352ed9c1a3e82689b842b7f87e469ebf2e48f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/core/utils/concurrencytest.py')
-rw-r--r--meta/lib/oeqa/core/utils/concurrencytest.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/utils/concurrencytest.py b/meta/lib/oeqa/core/utils/concurrencytest.py
index 535b11e2d9..6bf7718863 100644
--- a/meta/lib/oeqa/core/utils/concurrencytest.py
+++ b/meta/lib/oeqa/core/utils/concurrencytest.py
@@ -21,6 +21,7 @@ import testtools
21import threading 21import threading
22import time 22import time
23import io 23import io
24import subunit
24 25
25from queue import Queue 26from queue import Queue
26from itertools import cycle 27from itertools import cycle
@@ -53,10 +54,11 @@ class BBThreadsafeForwardingResult(ThreadsafeForwardingResult):
53 def _add_result_with_semaphore(self, method, test, *args, **kwargs): 54 def _add_result_with_semaphore(self, method, test, *args, **kwargs):
54 self.semaphore.acquire() 55 self.semaphore.acquire()
55 try: 56 try:
56 self.result.starttime[test.id()] = self._test_start.timestamp() 57 if self._test_start:
57 self.result.threadprogress[self.threadnum].append(test.id()) 58 self.result.starttime[test.id()] = self._test_start.timestamp()
58 totalprogress = sum(len(x) for x in self.result.threadprogress.values()) 59 self.result.threadprogress[self.threadnum].append(test.id())
59 self.result.progressinfo[test.id()] = "%s: %s/%s %s/%s (%ss) (%s)" % ( 60 totalprogress = sum(len(x) for x in self.result.threadprogress.values())
61 self.result.progressinfo[test.id()] = "%s: %s/%s %s/%s (%ss) (%s)" % (
60 self.threadnum, 62 self.threadnum,
61 len(self.result.threadprogress[self.threadnum]), 63 len(self.result.threadprogress[self.threadnum]),
62 self.totalinprocess, 64 self.totalinprocess,
@@ -69,6 +71,23 @@ class BBThreadsafeForwardingResult(ThreadsafeForwardingResult):
69 super(BBThreadsafeForwardingResult, self)._add_result_with_semaphore(method, test, *args, **kwargs) 71 super(BBThreadsafeForwardingResult, self)._add_result_with_semaphore(method, test, *args, **kwargs)
70 72
71# 73#
74# We have to patch subunit since it doesn't understand how to handle addError
75# outside of a running test case. This can happen if classSetUp() fails
76# for a class of tests. This unfortunately has horrible internal knowledge.
77#
78def outSideTestaddError(self, offset, line):
79 """An 'error:' directive has been read."""
80 test_name = line[offset:-1].decode('utf8')
81 self.parser._current_test = subunit.RemotedTestCase(test_name)
82 self.parser.current_test_description = test_name
83 self.parser._state = self.parser._reading_error_details
84 self.parser._reading_error_details.set_simple()
85 self.parser.subunitLineReceived(line)
86
87subunit._OutSideTest.addError = outSideTestaddError
88
89
90#
72# A dummy structure to add to io.StringIO so that the .buffer object 91# A dummy structure to add to io.StringIO so that the .buffer object
73# is available and accepts writes. This allows unittest with buffer=True 92# is available and accepts writes. This allows unittest with buffer=True
74# to interact ok with subunit which wants to access sys.stdout.buffer. 93# to interact ok with subunit which wants to access sys.stdout.buffer.