diff options
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/tinfoil.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/meta/lib/oeqa/selftest/cases/tinfoil.py b/meta/lib/oeqa/selftest/cases/tinfoil.py index 3a58761c00..aa1af7e042 100644 --- a/meta/lib/oeqa/selftest/cases/tinfoil.py +++ b/meta/lib/oeqa/selftest/cases/tinfoil.py | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import re | 2 | import re |
| 3 | import time | ||
| 3 | import bb.tinfoil | 4 | import bb.tinfoil |
| 4 | 5 | ||
| 5 | from oeqa.selftest.case import OESelftestTestCase | 6 | from oeqa.selftest.case import OESelftestTestCase |
| @@ -102,21 +103,26 @@ class TinfoilTests(OESelftestTestCase): | |||
| 102 | def test_wait_event(self): | 103 | def test_wait_event(self): |
| 103 | with bb.tinfoil.Tinfoil() as tinfoil: | 104 | with bb.tinfoil.Tinfoil() as tinfoil: |
| 104 | tinfoil.prepare(config_only=True) | 105 | tinfoil.prepare(config_only=True) |
| 105 | # Need to drain events otherwise events that will be masked will still be in the queue | 106 | |
| 106 | while tinfoil.wait_event(0.25): | ||
| 107 | pass | ||
| 108 | tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted']) | 107 | tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted']) |
| 108 | |||
| 109 | # Need to drain events otherwise events that were masked may still be in the queue | ||
| 110 | while tinfoil.wait_event(): | ||
| 111 | pass | ||
| 112 | |||
| 109 | pattern = 'conf' | 113 | pattern = 'conf' |
| 110 | res = tinfoil.run_command('findFilesMatchingInDir', pattern, 'conf/machine') | 114 | res = tinfoil.run_command('findFilesMatchingInDir', pattern, 'conf/machine') |
| 111 | self.assertTrue(res) | 115 | self.assertTrue(res) |
| 112 | 116 | ||
| 113 | eventreceived = False | 117 | eventreceived = False |
| 114 | waitcount = 5 | 118 | commandcomplete = False |
| 115 | while waitcount > 0: | 119 | start = time.time() |
| 120 | # Wait for 5s in total so we'd detect spurious heartbeat events for example | ||
| 121 | while time.time() - start < 5: | ||
| 116 | event = tinfoil.wait_event(1) | 122 | event = tinfoil.wait_event(1) |
| 117 | if event: | 123 | if event: |
| 118 | if isinstance(event, bb.command.CommandCompleted): | 124 | if isinstance(event, bb.command.CommandCompleted): |
| 119 | break | 125 | commandcomplete = True |
| 120 | elif isinstance(event, bb.event.FilesMatchingFound): | 126 | elif isinstance(event, bb.event.FilesMatchingFound): |
| 121 | self.assertEqual(pattern, event._pattern) | 127 | self.assertEqual(pattern, event._pattern) |
| 122 | self.assertIn('qemuarm.conf', event._matches) | 128 | self.assertIn('qemuarm.conf', event._matches) |
| @@ -124,9 +130,7 @@ class TinfoilTests(OESelftestTestCase): | |||
| 124 | else: | 130 | else: |
| 125 | self.fail('Unexpected event: %s' % event) | 131 | self.fail('Unexpected event: %s' % event) |
| 126 | 132 | ||
| 127 | waitcount = waitcount - 1 | 133 | self.assertTrue(commandcomplete, 'Timed out waiting for CommandCompleted event from bitbake server') |
| 128 | |||
| 129 | self.assertNotEqual(waitcount, 0, 'Timed out waiting for CommandCompleted event from bitbake server') | ||
| 130 | self.assertTrue(eventreceived, 'Did not receive FilesMatchingFound event from bitbake server') | 134 | self.assertTrue(eventreceived, 'Did not receive FilesMatchingFound event from bitbake server') |
| 131 | 135 | ||
| 132 | @OETestID(1576) | 136 | @OETestID(1576) |
