diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/tinfoil.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/tinfoil.py | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/meta/lib/oeqa/selftest/cases/tinfoil.py b/meta/lib/oeqa/selftest/cases/tinfoil.py index a51c6048d3..21c8686b2a 100644 --- a/meta/lib/oeqa/selftest/cases/tinfoil.py +++ b/meta/lib/oeqa/selftest/cases/tinfoil.py | |||
@@ -1,4 +1,6 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
3 | # | 5 | # |
4 | 6 | ||
@@ -9,7 +11,6 @@ import logging | |||
9 | import bb.tinfoil | 11 | import bb.tinfoil |
10 | 12 | ||
11 | from oeqa.selftest.case import OESelftestTestCase | 13 | from oeqa.selftest.case import OESelftestTestCase |
12 | from oeqa.utils.commands import runCmd | ||
13 | 14 | ||
14 | class TinfoilTests(OESelftestTestCase): | 15 | class TinfoilTests(OESelftestTestCase): |
15 | """ Basic tests for the tinfoil API """ | 16 | """ Basic tests for the tinfoil API """ |
@@ -47,6 +48,17 @@ class TinfoilTests(OESelftestTestCase): | |||
47 | rd = tinfoil.parse_recipe_file(best[3]) | 48 | rd = tinfoil.parse_recipe_file(best[3]) |
48 | self.assertEqual(testrecipe, rd.getVar('PN')) | 49 | self.assertEqual(testrecipe, rd.getVar('PN')) |
49 | 50 | ||
51 | def test_parse_virtual_recipe(self): | ||
52 | with bb.tinfoil.Tinfoil() as tinfoil: | ||
53 | tinfoil.prepare(config_only=False, quiet=2) | ||
54 | testrecipe = 'nativesdk-gcc' | ||
55 | best = tinfoil.find_best_provider(testrecipe) | ||
56 | if not best: | ||
57 | self.fail('Unable to find recipe providing %s' % testrecipe) | ||
58 | rd = tinfoil.parse_recipe_file(best[3]) | ||
59 | self.assertEqual(testrecipe, rd.getVar('PN')) | ||
60 | self.assertIsNotNone(rd.getVar('FILE_LAYERNAME')) | ||
61 | |||
50 | def test_parse_recipe_copy_expand(self): | 62 | def test_parse_recipe_copy_expand(self): |
51 | with bb.tinfoil.Tinfoil() as tinfoil: | 63 | with bb.tinfoil.Tinfoil() as tinfoil: |
52 | tinfoil.prepare(config_only=False, quiet=2) | 64 | tinfoil.prepare(config_only=False, quiet=2) |
@@ -65,6 +77,32 @@ class TinfoilTests(OESelftestTestCase): | |||
65 | localdata.setVar('PN', 'hello') | 77 | localdata.setVar('PN', 'hello') |
66 | self.assertEqual('hello', localdata.getVar('BPN')) | 78 | self.assertEqual('hello', localdata.getVar('BPN')) |
67 | 79 | ||
80 | # The config_data API to parse_recipe_file is used by: | ||
81 | # layerindex-web layerindex/update_layer.py | ||
82 | def test_parse_recipe_custom_data(self): | ||
83 | with bb.tinfoil.Tinfoil() as tinfoil: | ||
84 | tinfoil.prepare(config_only=False, quiet=2) | ||
85 | localdata = bb.data.createCopy(tinfoil.config_data) | ||
86 | localdata.setVar("TESTVAR", "testval") | ||
87 | testrecipe = 'mdadm' | ||
88 | best = tinfoil.find_best_provider(testrecipe) | ||
89 | if not best: | ||
90 | self.fail('Unable to find recipe providing %s' % testrecipe) | ||
91 | rd = tinfoil.parse_recipe_file(best[3], config_data=localdata) | ||
92 | self.assertEqual("testval", rd.getVar('TESTVAR')) | ||
93 | |||
94 | def test_parse_virtual_recipe_custom_data(self): | ||
95 | with bb.tinfoil.Tinfoil() as tinfoil: | ||
96 | tinfoil.prepare(config_only=False, quiet=2) | ||
97 | localdata = bb.data.createCopy(tinfoil.config_data) | ||
98 | localdata.setVar("TESTVAR", "testval") | ||
99 | testrecipe = 'nativesdk-gcc' | ||
100 | best = tinfoil.find_best_provider(testrecipe) | ||
101 | if not best: | ||
102 | self.fail('Unable to find recipe providing %s' % testrecipe) | ||
103 | rd = tinfoil.parse_recipe_file(best[3], config_data=localdata) | ||
104 | self.assertEqual("testval", rd.getVar('TESTVAR')) | ||
105 | |||
68 | def test_list_recipes(self): | 106 | def test_list_recipes(self): |
69 | with bb.tinfoil.Tinfoil() as tinfoil: | 107 | with bb.tinfoil.Tinfoil() as tinfoil: |
70 | tinfoil.prepare(config_only=False, quiet=2) | 108 | tinfoil.prepare(config_only=False, quiet=2) |
@@ -87,21 +125,20 @@ class TinfoilTests(OESelftestTestCase): | |||
87 | with bb.tinfoil.Tinfoil() as tinfoil: | 125 | with bb.tinfoil.Tinfoil() as tinfoil: |
88 | tinfoil.prepare(config_only=True) | 126 | tinfoil.prepare(config_only=True) |
89 | 127 | ||
90 | tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted']) | 128 | tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted', 'bb.command.CommandFailed', 'bb.command.CommandExit']) |
91 | 129 | ||
92 | # Need to drain events otherwise events that were masked may still be in the queue | 130 | # Need to drain events otherwise events that were masked may still be in the queue |
93 | while tinfoil.wait_event(): | 131 | while tinfoil.wait_event(): |
94 | pass | 132 | pass |
95 | 133 | ||
96 | pattern = 'conf' | 134 | pattern = 'conf' |
97 | res = tinfoil.run_command('findFilesMatchingInDir', pattern, 'conf/machine') | 135 | res = tinfoil.run_command('testCookerCommandEvent', pattern, handle_events=False) |
98 | self.assertTrue(res) | 136 | self.assertTrue(res) |
99 | 137 | ||
100 | eventreceived = False | 138 | eventreceived = False |
101 | commandcomplete = False | 139 | commandcomplete = False |
102 | start = time.time() | 140 | start = time.time() |
103 | # Wait for maximum 60s in total so we'd detect spurious heartbeat events for example | 141 | # Wait for maximum 60s in total so we'd detect spurious heartbeat events for example |
104 | # The test is IO load sensitive too | ||
105 | while (not (eventreceived == True and commandcomplete == True) | 142 | while (not (eventreceived == True and commandcomplete == True) |
106 | and (time.time() - start < 60)): | 143 | and (time.time() - start < 60)): |
107 | # if we received both events (on let's say a good day), we are done | 144 | # if we received both events (on let's say a good day), we are done |
@@ -111,14 +148,15 @@ class TinfoilTests(OESelftestTestCase): | |||
111 | commandcomplete = True | 148 | commandcomplete = True |
112 | elif isinstance(event, bb.event.FilesMatchingFound): | 149 | elif isinstance(event, bb.event.FilesMatchingFound): |
113 | self.assertEqual(pattern, event._pattern) | 150 | self.assertEqual(pattern, event._pattern) |
114 | self.assertIn('qemuarm.conf', event._matches) | 151 | self.assertIn('A', event._matches) |
152 | self.assertIn('B', event._matches) | ||
115 | eventreceived = True | 153 | eventreceived = True |
116 | elif isinstance(event, logging.LogRecord): | 154 | elif isinstance(event, logging.LogRecord): |
117 | continue | 155 | continue |
118 | else: | 156 | else: |
119 | self.fail('Unexpected event: %s' % event) | 157 | self.fail('Unexpected event: %s' % event) |
120 | 158 | ||
121 | self.assertTrue(commandcomplete, 'Timed out waiting for CommandCompleted event from bitbake server') | 159 | self.assertTrue(commandcomplete, 'Timed out waiting for CommandCompleted event from bitbake server (Matching event received: %s)' % str(eventreceived)) |
122 | self.assertTrue(eventreceived, 'Did not receive FilesMatchingFound event from bitbake server') | 160 | self.assertTrue(eventreceived, 'Did not receive FilesMatchingFound event from bitbake server') |
123 | 161 | ||
124 | def test_setvariable_clean(self): | 162 | def test_setvariable_clean(self): |
@@ -173,8 +211,8 @@ class TinfoilTests(OESelftestTestCase): | |||
173 | self.assertEqual(value, 'origvalue', 'Variable renamed using config_data.renameVar() does not appear with new name') | 211 | self.assertEqual(value, 'origvalue', 'Variable renamed using config_data.renameVar() does not appear with new name') |
174 | # Test overrides | 212 | # Test overrides |
175 | tinfoil.config_data.setVar('TESTVAR', 'original') | 213 | tinfoil.config_data.setVar('TESTVAR', 'original') |
176 | tinfoil.config_data.setVar('TESTVAR_overrideone', 'one') | 214 | tinfoil.config_data.setVar('TESTVAR:overrideone', 'one') |
177 | tinfoil.config_data.setVar('TESTVAR_overridetwo', 'two') | 215 | tinfoil.config_data.setVar('TESTVAR:overridetwo', 'two') |
178 | tinfoil.config_data.appendVar('OVERRIDES', ':overrideone') | 216 | tinfoil.config_data.appendVar('OVERRIDES', ':overrideone') |
179 | value = tinfoil.config_data.getVar('TESTVAR') | 217 | value = tinfoil.config_data.getVar('TESTVAR') |
180 | self.assertEqual(value, 'one', 'Variable overrides not functioning correctly') | 218 | self.assertEqual(value, 'one', 'Variable overrides not functioning correctly') |