diff options
authorRichard Purdie <>2017-07-07 13:55:06 +0100
committerRichard Purdie <>2017-07-08 13:34:00 +0100
commit7dd5dfc4d56f1201110d947ce1ca3c6d64fbc7da (patch)
parentc440298674ab3b960c83a127eedb9e1b66bddf78 (diff)
oeqa/tinfoil: Improve test_wait_event for race issues
The test could break in a variety of ways: a) If BB_HEARTBEAT_EVENT was less than ~0.25 it would hang indefinitely b) The mask is set after draining the event queue meaning a heartbeat event could have happened c) The test exits once it sees the events it wants, it doesn't check for spurious events such as heartbeats which shouldn't have occured. d) The hardcoded delay of 0.25 is nasty and shouldn't be needed. I found a bitbake bug and fixed that meaning we don't need the delay any more which fixes d). That means a) is no longer an issue either. We now set the mask, then drain the queue meaning no spurious events should be able to sneak in. The test is also tweaked to wait for 5s in total to ensure spurious events don't occur such as heartbeat events we shouldn't see. [YOCTO #11045] Signed-off-by: Richard Purdie <>
1 files changed, 13 insertions, 9 deletions
diff --git a/meta/lib/oeqa/selftest/cases/ b/meta/lib/oeqa/selftest/cases/
index 3a58761c00..aa1af7e042 100644
--- a/meta/lib/oeqa/selftest/cases/
+++ b/meta/lib/oeqa/selftest/cases/
@@ -1,5 +1,6 @@
import os
import re
+import time
import bb.tinfoil
from import OESelftestTestCase
@@ -102,21 +103,26 @@ class TinfoilTests(OESelftestTestCase):
def test_wait_event(self):
with bb.tinfoil.Tinfoil() as tinfoil:
- # Need to drain events otherwise events that will be masked will still be in the queue
- while tinfoil.wait_event(0.25):
- pass
tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted'])
+ # Need to drain events otherwise events that were masked may still be in the queue
+ while tinfoil.wait_event():
+ pass
pattern = 'conf'
res = tinfoil.run_command('findFilesMatchingInDir', pattern, 'conf/machine')
eventreceived = False
- waitcount = 5
- while waitcount > 0:
+ commandcomplete = False
+ start = time.time()
+ # Wait for 5s in total so we'd detect spurious heartbeat events for example
+ while time.time() - start < 5:
event = tinfoil.wait_event(1)
if event:
if isinstance(event, bb.command.CommandCompleted):
- break
+ commandcomplete = True
elif isinstance(event, bb.event.FilesMatchingFound):
self.assertEqual(pattern, event._pattern)
self.assertIn('qemuarm.conf', event._matches)
@@ -124,9 +130,7 @@ class TinfoilTests(OESelftestTestCase):
else:'Unexpected event: %s' % event)
- waitcount = waitcount - 1
- self.assertNotEqual(waitcount, 0, 'Timed out waiting for CommandCompleted event from bitbake server')
+ self.assertTrue(commandcomplete, 'Timed out waiting for CommandCompleted event from bitbake server')
self.assertTrue(eventreceived, 'Did not receive FilesMatchingFound event from bitbake server')