diff options
-rw-r--r-- | lib/oeqa/selftest/updater.py | 114 |
1 files changed, 98 insertions, 16 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py index 6c0d31e..971e7c5 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/updater.py | |||
@@ -63,7 +63,6 @@ class GeneralTests(oeSelfTest): | |||
63 | "Java not found. Do you have a JDK installed on your host machine?") | 63 | "Java not found. Do you have a JDK installed on your host machine?") |
64 | 64 | ||
65 | def test_add_package(self): | 65 | def test_add_package(self): |
66 | print('') | ||
67 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') | 66 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') |
68 | imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal') | 67 | imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal') |
69 | image_path = deploydir + '/' + imagename + '.otaimg' | 68 | image_path = deploydir + '/' + imagename + '.otaimg' |
@@ -135,18 +134,20 @@ class AktualizrToolsTests(oeSelfTest): | |||
135 | class AutoProvTests(oeSelfTest): | 134 | class AutoProvTests(oeSelfTest): |
136 | 135 | ||
137 | def setUpLocal(self): | 136 | def setUpLocal(self): |
138 | self.append_config('MACHINE = "qemux86-64"') | ||
139 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | ||
140 | layer = "meta-updater-qemux86-64" | 137 | layer = "meta-updater-qemux86-64" |
141 | result = runCmd('bitbake-layers show-layers') | 138 | result = runCmd('bitbake-layers show-layers') |
142 | if re.search(layer, result.output) is None: | 139 | if re.search(layer, result.output) is None: |
143 | # This is a bit of a hack but I can't see a better option. | 140 | # Assume the directory layout for finding other layers. We could also |
141 | # make assumptions by using 'show-layers', but either way, if the | ||
142 | # layers we need aren't where we expect them, we are out of like. | ||
144 | path = os.path.abspath(os.path.dirname(__file__)) | 143 | path = os.path.abspath(os.path.dirname(__file__)) |
145 | metadir = path + "/../../../../" | 144 | metadir = path + "/../../../../" |
146 | self.meta_qemu = metadir + layer | 145 | self.meta_qemu = metadir + layer |
147 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 146 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
148 | else: | 147 | else: |
149 | self.meta_qemu = None | 148 | self.meta_qemu = None |
149 | self.append_config('MACHINE = "qemux86-64"') | ||
150 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | ||
150 | self.qemu, self.s = qemu_launch(machine='qemux86-64') | 151 | self.qemu, self.s = qemu_launch(machine='qemux86-64') |
151 | 152 | ||
152 | def tearDownLocal(self): | 153 | def tearDownLocal(self): |
@@ -182,16 +183,91 @@ class AutoProvTests(oeSelfTest): | |||
182 | verifyProvisioned(self, machine) | 183 | verifyProvisioned(self, machine) |
183 | 184 | ||
184 | 185 | ||
185 | class GrubTests(oeSelfTest): | 186 | class RpiTests(oeSelfTest): |
186 | 187 | ||
187 | def setUpLocal(self): | 188 | def setUpLocal(self): |
188 | self.append_config('MACHINE = "intel-corei7-64"') | 189 | # Add layers before changing the machine type, otherwise the sanity |
189 | self.append_config('OSTREE_BOOTLOADER = "grub"') | 190 | # checker complains loudly. |
191 | layer_python = "meta-openembedded/meta-python" | ||
192 | layer_rpi = "meta-raspberrypi" | ||
193 | layer_upd_rpi = "meta-updater-raspberrypi" | ||
194 | result = runCmd('bitbake-layers show-layers') | ||
195 | # Assume the directory layout for finding other layers. We could also | ||
196 | # make assumptions by using 'show-layers', but either way, if the | ||
197 | # layers we need aren't where we expect them, we are out of like. | ||
198 | path = os.path.abspath(os.path.dirname(__file__)) | ||
199 | metadir = path + "/../../../../" | ||
200 | if re.search(layer_python, result.output) is None: | ||
201 | self.meta_python = metadir + layer_python | ||
202 | runCmd('bitbake-layers add-layer "%s"' % self.meta_python) | ||
203 | else: | ||
204 | self.meta_python = None | ||
205 | if re.search(layer_rpi, result.output) is None: | ||
206 | self.meta_rpi = metadir + layer_rpi | ||
207 | runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi) | ||
208 | else: | ||
209 | self.meta_rpi = None | ||
210 | if re.search(layer_upd_rpi, result.output) is None: | ||
211 | self.meta_upd_rpi = metadir + layer_upd_rpi | ||
212 | runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi) | ||
213 | else: | ||
214 | self.meta_upd_rpi = None | ||
215 | |||
216 | # This is trickier that I would've thought. The fundamental problem is | ||
217 | # that the qemu layer changes the u-boot file extension to .rom, but | ||
218 | # raspberrypi still expects .bin. To prevent this, the qemu layer must | ||
219 | # be temporarily removed if it is present. It has to be removed by name | ||
220 | # without the complete path, but to add it back when we are done, we | ||
221 | # need the full path. | ||
222 | p = re.compile(r'meta-updater-qemux86-64\s*(\S*meta-updater-qemux86-64)\s') | ||
223 | m = p.search(result.output) | ||
224 | if m and m.lastindex > 0: | ||
225 | self.meta_qemu = m.group(1) | ||
226 | runCmd('bitbake-layers remove-layer meta-updater-qemux86-64') | ||
227 | else: | ||
228 | self.meta_qemu = None | ||
229 | |||
230 | self.append_config('MACHINE = "raspberrypi3"') | ||
190 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | 231 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') |
232 | |||
233 | def tearDownLocal(self): | ||
234 | if self.meta_qemu: | ||
235 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu, ignore_status=True) | ||
236 | if self.meta_upd_rpi: | ||
237 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_upd_rpi, ignore_status=True) | ||
238 | if self.meta_rpi: | ||
239 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_rpi, ignore_status=True) | ||
240 | if self.meta_python: | ||
241 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_python, ignore_status=True) | ||
242 | |||
243 | def test_rpi(self): | ||
244 | logger = logging.getLogger("selftest") | ||
245 | logger.info('Running bitbake to build rpi-basic-image') | ||
246 | self.append_config('SOTA_CLIENT_PROV = "aktualizr-auto-prov"') | ||
247 | bitbake('rpi-basic-image') | ||
248 | credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') | ||
249 | # Skip the test if the variable SOTA_PACKED_CREDENTIALS is not set. | ||
250 | if credentials is None: | ||
251 | raise unittest.SkipTest("Variable 'SOTA_PACKED_CREDENTIALS' not set.") | ||
252 | # Check if the file exists. | ||
253 | self.assertTrue(os.path.isfile(credentials), "File %s does not exist" % credentials) | ||
254 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') | ||
255 | imagename = get_bb_var('IMAGE_LINK_NAME', 'rpi-basic-image') | ||
256 | # Check if the credentials are included in the output image. | ||
257 | result = runCmd('tar -jtvf %s/%s.tar.bz2 | grep sota_provisioning_credentials.zip' % | ||
258 | (deploydir, imagename), ignore_status=True) | ||
259 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
260 | |||
261 | |||
262 | class GrubTests(oeSelfTest): | ||
263 | |||
264 | def setUpLocal(self): | ||
191 | layer_intel = "meta-intel" | 265 | layer_intel = "meta-intel" |
192 | layer_minnow = "meta-updater-minnowboard" | 266 | layer_minnow = "meta-updater-minnowboard" |
193 | result = runCmd('bitbake-layers show-layers') | 267 | result = runCmd('bitbake-layers show-layers') |
194 | # This is a bit of a hack but I can't see a better option. | 268 | # Assume the directory layout for finding other layers. We could also |
269 | # make assumptions by using 'show-layers', but either way, if the | ||
270 | # layers we need aren't where we expect them, we are out of like. | ||
195 | path = os.path.abspath(os.path.dirname(__file__)) | 271 | path = os.path.abspath(os.path.dirname(__file__)) |
196 | metadir = path + "/../../../../" | 272 | metadir = path + "/../../../../" |
197 | if re.search(layer_intel, result.output) is None: | 273 | if re.search(layer_intel, result.output) is None: |
@@ -204,6 +280,9 @@ class GrubTests(oeSelfTest): | |||
204 | runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow) | 280 | runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow) |
205 | else: | 281 | else: |
206 | self.meta_minnow = None | 282 | self.meta_minnow = None |
283 | self.append_config('MACHINE = "intel-corei7-64"') | ||
284 | self.append_config('OSTREE_BOOTLOADER = "grub"') | ||
285 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | ||
207 | self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64') | 286 | self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64') |
208 | 287 | ||
209 | def tearDownLocal(self): | 288 | def tearDownLocal(self): |
@@ -217,7 +296,6 @@ class GrubTests(oeSelfTest): | |||
217 | return qemu_send_command(self.qemu.ssh_port, command) | 296 | return qemu_send_command(self.qemu.ssh_port, command) |
218 | 297 | ||
219 | def test_grub(self): | 298 | def test_grub(self): |
220 | print('') | ||
221 | print('Checking machine name (hostname) of device:') | 299 | print('Checking machine name (hostname) of device:') |
222 | stdout, stderr, retcode = self.qemu_command('hostname') | 300 | stdout, stderr, retcode = self.qemu_command('hostname') |
223 | self.assertEqual(retcode, 0, "Unable to check hostname. " + | 301 | self.assertEqual(retcode, 0, "Unable to check hostname. " + |
@@ -246,18 +324,20 @@ class GrubTests(oeSelfTest): | |||
246 | class ImplProvTests(oeSelfTest): | 324 | class ImplProvTests(oeSelfTest): |
247 | 325 | ||
248 | def setUpLocal(self): | 326 | def setUpLocal(self): |
249 | self.append_config('MACHINE = "qemux86-64"') | ||
250 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-implicit-prov "') | ||
251 | layer = "meta-updater-qemux86-64" | 327 | layer = "meta-updater-qemux86-64" |
252 | result = runCmd('bitbake-layers show-layers') | 328 | result = runCmd('bitbake-layers show-layers') |
253 | if re.search(layer, result.output) is None: | 329 | if re.search(layer, result.output) is None: |
254 | # This is a bit of a hack but I can't see a better option. | 330 | # Assume the directory layout for finding other layers. We could also |
331 | # make assumptions by using 'show-layers', but either way, if the | ||
332 | # layers we need aren't where we expect them, we are out of like. | ||
255 | path = os.path.abspath(os.path.dirname(__file__)) | 333 | path = os.path.abspath(os.path.dirname(__file__)) |
256 | metadir = path + "/../../../../" | 334 | metadir = path + "/../../../../" |
257 | self.meta_qemu = metadir + layer | 335 | self.meta_qemu = metadir + layer |
258 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 336 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
259 | else: | 337 | else: |
260 | self.meta_qemu = None | 338 | self.meta_qemu = None |
339 | self.append_config('MACHINE = "qemux86-64"') | ||
340 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-implicit-prov "') | ||
261 | self.qemu, self.s = qemu_launch(machine='qemux86-64') | 341 | self.qemu, self.s = qemu_launch(machine='qemux86-64') |
262 | 342 | ||
263 | def tearDownLocal(self): | 343 | def tearDownLocal(self): |
@@ -313,19 +393,21 @@ class ImplProvTests(oeSelfTest): | |||
313 | class HsmTests(oeSelfTest): | 393 | class HsmTests(oeSelfTest): |
314 | 394 | ||
315 | def setUpLocal(self): | 395 | def setUpLocal(self): |
316 | self.append_config('MACHINE = "qemux86-64"') | ||
317 | self.append_config('SOTA_CLIENT_PROV = "aktualizr-hsm-prov"') | ||
318 | self.append_config('SOTA_CLIENT_FEATURES = "hsm"') | ||
319 | layer = "meta-updater-qemux86-64" | 396 | layer = "meta-updater-qemux86-64" |
320 | result = runCmd('bitbake-layers show-layers') | 397 | result = runCmd('bitbake-layers show-layers') |
321 | if re.search(layer, result.output) is None: | 398 | if re.search(layer, result.output) is None: |
322 | # This is a bit of a hack but I can't see a better option. | 399 | # Assume the directory layout for finding other layers. We could also |
400 | # make assumptions by using 'show-layers', but either way, if the | ||
401 | # layers we need aren't where we expect them, we are out of like. | ||
323 | path = os.path.abspath(os.path.dirname(__file__)) | 402 | path = os.path.abspath(os.path.dirname(__file__)) |
324 | metadir = path + "/../../../../" | 403 | metadir = path + "/../../../../" |
325 | self.meta_qemu = metadir + layer | 404 | self.meta_qemu = metadir + layer |
326 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) | 405 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) |
327 | else: | 406 | else: |
328 | self.meta_qemu = None | 407 | self.meta_qemu = None |
408 | self.append_config('MACHINE = "qemux86-64"') | ||
409 | self.append_config('SOTA_CLIENT_PROV = "aktualizr-hsm-prov"') | ||
410 | self.append_config('SOTA_CLIENT_FEATURES = "hsm"') | ||
329 | self.qemu, self.s = qemu_launch(machine='qemux86-64') | 411 | self.qemu, self.s = qemu_launch(machine='qemux86-64') |
330 | 412 | ||
331 | def tearDownLocal(self): | 413 | def tearDownLocal(self): |