summaryrefslogtreecommitdiffstats
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-22 00:31:49 +0100
commit8356d0f38c675f6cdc3fe73f6c1198b5e65f2fb2 (patch)
tree15da0391a2e1c03efe3c785f056d690ce937e504
parent63bea82d93a48c3dbc17477fb6b54a71ad4bc363 (diff)
downloadpoky-8356d0f38c675f6cdc3fe73f6c1198b5e65f2fb2.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: 6f58c301e2d3463848df35c5b5c55d167ab34035) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 f050289e61..1a58d35ba0 100644
--- a/meta/lib/oeqa/core/utils/concurrencytest.py
+++ b/meta/lib/oeqa/core/utils/concurrencytest.py
@@ -19,6 +19,7 @@ import testtools
19import threading 19import threading
20import time 20import time
21import io 21import io
22import subunit
22 23
23from queue import Queue 24from queue import Queue
24from itertools import cycle 25from itertools import cycle
@@ -50,10 +51,11 @@ class BBThreadsafeForwardingResult(ThreadsafeForwardingResult):
50 def _add_result_with_semaphore(self, method, test, *args, **kwargs): 51 def _add_result_with_semaphore(self, method, test, *args, **kwargs):
51 self.semaphore.acquire() 52 self.semaphore.acquire()
52 try: 53 try:
53 self.result.starttime[test.id()] = self._test_start.timestamp() 54 if self._test_start:
54 self.result.threadprogress[self.threadnum].append(test.id()) 55 self.result.starttime[test.id()] = self._test_start.timestamp()
55 totalprogress = sum(len(x) for x in self.result.threadprogress.values()) 56 self.result.threadprogress[self.threadnum].append(test.id())
56 self.result.progressinfo[test.id()] = "%s: %s/%s %s/%s (%ss) (%s)" % ( 57 totalprogress = sum(len(x) for x in self.result.threadprogress.values())
58 self.result.progressinfo[test.id()] = "%s: %s/%s %s/%s (%ss) (%s)" % (
57 self.threadnum, 59 self.threadnum,
58 len(self.result.threadprogress[self.threadnum]), 60 len(self.result.threadprogress[self.threadnum]),
59 self.totalinprocess, 61 self.totalinprocess,
@@ -66,6 +68,23 @@ class BBThreadsafeForwardingResult(ThreadsafeForwardingResult):
66 super(BBThreadsafeForwardingResult, self)._add_result_with_semaphore(method, test, *args, **kwargs) 68 super(BBThreadsafeForwardingResult, self)._add_result_with_semaphore(method, test, *args, **kwargs)
67 69
68# 70#
71# We have to patch subunit since it doesn't understand how to handle addError
72# outside of a running test case. This can happen if classSetUp() fails
73# for a class of tests. This unfortunately has horrible internal knowledge.
74#
75def outSideTestaddError(self, offset, line):
76 """An 'error:' directive has been read."""
77 test_name = line[offset:-1].decode('utf8')
78 self.parser._current_test = subunit.RemotedTestCase(test_name)
79 self.parser.current_test_description = test_name
80 self.parser._state = self.parser._reading_error_details
81 self.parser._reading_error_details.set_simple()
82 self.parser.subunitLineReceived(line)
83
84subunit._OutSideTest.addError = outSideTestaddError
85
86
87#
69# A dummy structure to add to io.StringIO so that the .buffer object 88# A dummy structure to add to io.StringIO so that the .buffer object
70# is available and accepts writes. This allows unittest with buffer=True 89# is available and accepts writes. This allows unittest with buffer=True
71# to interact ok with subunit which wants to access sys.stdout.buffer. 90# to interact ok with subunit which wants to access sys.stdout.buffer.