diff options
| author | Patrick Vacek <patrickvacek@gmail.com> | 2019-05-20 17:47:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-20 17:47:50 +0200 |
| commit | cdf070e20556a13ecda308833fd5c314d20547ab (patch) | |
| tree | f62f36ca4b7b2f26644f9d7f2fdb7e6fdee0154d /lib/oeqa/selftest/cases/updater_raspberrypi.py | |
| parent | 195135f3d01fecc099bfec43d56b87c28c9aa8a0 (diff) | |
| parent | 99992959999ce9f6ad5fdae5a96262a5e0e59b5e (diff) | |
| download | meta-updater-cdf070e20556a13ecda308833fd5c314d20547ab.tar.gz | |
Merge pull request #514 from advancedtelematic/fix/rocko/backport
Fix/rocko/backport
Diffstat (limited to 'lib/oeqa/selftest/cases/updater_raspberrypi.py')
| -rw-r--r-- | lib/oeqa/selftest/cases/updater_raspberrypi.py | 86 |
1 files changed, 86 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..1cab2b8 --- /dev/null +++ b/lib/oeqa/selftest/cases/updater_raspberrypi.py | |||
| @@ -0,0 +1,86 @@ | |||
| 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_python = "meta-openembedded/meta-python" | ||
| 17 | layer_rpi = "meta-raspberrypi" | ||
| 18 | layer_upd_rpi = "meta-updater-raspberrypi" | ||
| 19 | result = runCmd('bitbake-layers show-layers') | ||
| 20 | # Assume the directory layout for finding other layers. We could also | ||
| 21 | # make assumptions by using 'show-layers', but either way, if the | ||
| 22 | # layers we need aren't where we expect them, we are out of luck. | ||
| 23 | path = os.path.abspath(os.path.dirname(__file__)) | ||
| 24 | metadir = path + "/../../../../../" | ||
| 25 | if re.search(layer_python, result.output) is None: | ||
| 26 | self.meta_python = metadir + layer_python | ||
| 27 | runCmd('bitbake-layers add-layer "%s"' % self.meta_python) | ||
| 28 | else: | ||
| 29 | self.meta_python = None | ||
| 30 | if re.search(layer_rpi, result.output) is None: | ||
| 31 | self.meta_rpi = metadir + layer_rpi | ||
| 32 | runCmd('bitbake-layers add-layer "%s"' % self.meta_rpi) | ||
| 33 | else: | ||
| 34 | self.meta_rpi = None | ||
| 35 | if re.search(layer_upd_rpi, result.output) is None: | ||
| 36 | self.meta_upd_rpi = metadir + layer_upd_rpi | ||
| 37 | runCmd('bitbake-layers add-layer "%s"' % self.meta_upd_rpi) | ||
| 38 | else: | ||
| 39 | self.meta_upd_rpi = None | ||
| 40 | |||
| 41 | # This is trickier that I would've thought. The fundamental problem is | ||
| 42 | # that the qemu layer changes the u-boot file extension to .rom, but | ||
| 43 | # raspberrypi still expects .bin. To prevent this, the qemu layer must | ||
| 44 | # be temporarily removed if it is present. It has to be removed by name | ||
| 45 | # without the complete path, but to add it back when we are done, we | ||
| 46 | # need the full path. | ||
| 47 | p = re.compile(r'meta-updater-qemux86-64\s*(\S*meta-updater-qemux86-64)\s') | ||
| 48 | m = p.search(result.output) | ||
| 49 | if m and m.lastindex > 0: | ||
| 50 | self.meta_qemu = m.group(1) | ||
| 51 | runCmd('bitbake-layers remove-layer meta-updater-qemux86-64') | ||
| 52 | else: | ||
| 53 | self.meta_qemu = None | ||
| 54 | |||
| 55 | self.append_config('MACHINE = "raspberrypi3"') | ||
| 56 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | ||
| 57 | |||
| 58 | def tearDownLocal(self): | ||
| 59 | if self.meta_qemu: | ||
| 60 | runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu, ignore_status=True) | ||
| 61 | if self.meta_upd_rpi: | ||
| 62 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_upd_rpi, ignore_status=True) | ||
| 63 | if self.meta_rpi: | ||
| 64 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_rpi, ignore_status=True) | ||
| 65 | if self.meta_python: | ||
| 66 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_python, ignore_status=True) | ||
| 67 | |||
| 68 | def test_build(self): | ||
| 69 | logger = logging.getLogger("selftest") | ||
| 70 | logger.info('Running bitbake to build rpi-basic-image') | ||
| 71 | self.append_config('SOTA_CLIENT_PROV = "aktualizr-auto-prov"') | ||
| 72 | bitbake('rpi-basic-image') | ||
| 73 | credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') | ||
| 74 | # Skip the test if the variable SOTA_PACKED_CREDENTIALS is not set. | ||
| 75 | if credentials is None: | ||
| 76 | raise unittest.SkipTest("Variable 'SOTA_PACKED_CREDENTIALS' not set.") | ||
| 77 | # Check if the file exists. | ||
| 78 | self.assertTrue(os.path.isfile(credentials), "File %s does not exist" % credentials) | ||
| 79 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') | ||
| 80 | imagename = get_bb_var('IMAGE_LINK_NAME', 'rpi-basic-image') | ||
| 81 | # Check if the credentials are included in the output image. | ||
| 82 | result = runCmd('tar -jtvf %s/%s.tar.bz2 | grep sota_provisioning_credentials.zip' % | ||
| 83 | (deploydir, imagename), ignore_status=True) | ||
| 84 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
| 85 | |||
| 86 | # vim:set ts=4 sw=4 sts=4 expandtab: | ||
