diff options
| author | Patrick Vacek <patrickvacek@gmail.com> | 2019-03-21 15:28:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-21 15:28:55 +0100 |
| commit | d39d8b167797243fcf067c6faa6b4220d697c71c (patch) | |
| tree | d4aca54f1e8ff8e2a3409c2df2506f1f17152d3e /lib/oeqa/selftest/cases/updater_raspberrypi.py | |
| parent | 1e569e4def74e8b161833c4874888a7e514b67b1 (diff) | |
| parent | e1867d7a7bd52d79fa3d051bb7b16f50934b88e6 (diff) | |
| download | meta-updater-d39d8b167797243fcf067c6faa6b4220d697c71c.tar.gz | |
Merge pull request #507 from advancedtelematic/feat/OTA-2142/aktualizr-resource-control
aktualizr resource control
Diffstat (limited to 'lib/oeqa/selftest/cases/updater_raspberrypi.py')
| -rw-r--r-- | lib/oeqa/selftest/cases/updater_raspberrypi.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/oeqa/selftest/cases/updater_raspberrypi.py b/lib/oeqa/selftest/cases/updater_raspberrypi.py new file mode 100644 index 0000000..bb7cfa3 --- /dev/null +++ b/lib/oeqa/selftest/cases/updater_raspberrypi.py | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | # pylint: disable=C0111,C0325 | ||
| 2 | import os | ||
| 3 | import logging | ||
| 4 | import re | ||
| 5 | import unittest | ||
| 6 | |||
| 7 | from oeqa.selftest.case import OESelftestTestCase | ||
| 8 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
| 9 | |||
| 10 | |||
| 11 | class RpiTests(OESelftestTestCase): | ||
| 12 | |||
| 13 | def setUpLocal(self): | ||
| 14 | # Add layers before changing the machine type, otherwise the sanity | ||
| 15 | # checker complains loudly. | ||
| 16 | layer_rpi = "meta-raspberrypi" | ||
| 17 | layer_upd_rpi = "meta-updater-raspberrypi" | ||
| 18 | result = runCmd('bitbake-layers show-layers') | ||
| 19 | # Assume the directory layout for finding other layers. We could also | ||
| 20 | # make assumptions by using 'show-layers', but either way, if the | ||
| 21 | # layers we need aren't where we expect them, we are out of luck. | ||
| 22 | path = os.path.abspath(os.path.dirname(__file__)) | ||
| 23 | metadir = path + "/../../../../../" | ||
| 24 | if re.search(layer_rpi, result.output) is None: | ||
| 25 | self.meta_rpi = metadir + layer_rpi | ||
| 26 | runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi) | ||
| 27 | else: | ||
| 28 | self.meta_rpi = None | ||
| 29 | if re.search(layer_upd_rpi, result.output) is None: | ||
| 30 | self.meta_upd_rpi = metadir + layer_upd_rpi | ||
| 31 | runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi) | ||
| 32 | else: | ||
| 33 | self.meta_upd_rpi = None | ||
| 34 | |||
| 35 | # This is trickier that I would've thought. The fundamental problem is | ||
| 36 | # that the qemu layer changes the u-boot file extension to .rom, but | ||
| 37 | # raspberrypi still expects .bin. To prevent this, the qemu layer must | ||
| 38 | # be temporarily removed if it is present. It has to be removed by name | ||
| 39 | # without the complete path, but to add it back when we are done, we | ||
| 40 | # need the full path. | ||
| 41 | p = re.compile(r'meta-updater-qemux86-64\s*(\S*meta-updater-qemux86-64)\s') | ||
| 42 | m = p.search(result.output) | ||
| 43 | if m and m.lastindex > 0: | ||
| 44 | self.meta_qemu = m.group(1) | ||
| 45 | runCmd('bitbake-layers remove-layer meta-updater-qemux86-64') | ||
| 46 | else: | ||
| 47 | self.meta_qemu = None | ||
| 48 | |||
| 49 | self.append_config('MACHINE = "raspberrypi3"') | ||
| 50 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | ||
| 51 | |||
| 52 | def tearDownLocal(self): | ||
| 53 | if self.meta_qemu: | ||
| 54 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu, ignore_status=True) | ||
| 55 | if self.meta_upd_rpi: | ||
| 56 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_upd_rpi, ignore_status=True) | ||
| 57 | if self.meta_rpi: | ||
| 58 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_rpi, ignore_status=True) | ||
| 59 | |||
| 60 | def test_build(self): | ||
| 61 | logger = logging.getLogger("selftest") | ||
| 62 | logger.info('Running bitbake to build core-image-minimal') | ||
| 63 | self.append_config('SOTA_CLIENT_PROV = "aktualizr-auto-prov"') | ||
| 64 | bitbake('core-image-minimal') | ||
| 65 | credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') | ||
| 66 | # Skip the test if the variable SOTA_PACKED_CREDENTIALS is not set. | ||
| 67 | if credentials is None: | ||
| 68 | raise unittest.SkipTest("Variable 'SOTA_PACKED_CREDENTIALS' not set.") | ||
| 69 | # Check if the file exists. | ||
| 70 | self.assertTrue(os.path.isfile(credentials), "File %s does not exist" % credentials) | ||
| 71 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') | ||
| 72 | imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal') | ||
| 73 | # Check if the credentials are included in the output image. | ||
| 74 | result = runCmd('tar -jtvf %s/%s.tar.bz2 | grep sota_provisioning_credentials.zip' % | ||
| 75 | (deploydir, imagename), ignore_status=True) | ||
| 76 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
| 77 | |||
| 78 | # vim:set ts=4 sw=4 sts=4 expandtab: | ||
