summaryrefslogtreecommitdiffstats
path: root/lib/oeqa/selftest/cases/updater_raspberrypi.py
diff options
context:
space:
mode:
authorLaurent Bonnans <laurent.bonnans@here.com>2019-03-19 16:45:34 +0100
committerLaurent Bonnans <laurent.bonnans@here.com>2019-03-20 14:13:41 +0100
commit8b98e1e0f908ef30f5a4459f2bd62442d2b6649b (patch)
tree59d17466158dbba27c0371294819fa52e94861e1 /lib/oeqa/selftest/cases/updater_raspberrypi.py
parentececedcbd58a7cd04eea0a7faf7b04939536a555 (diff)
downloadmeta-updater-8b98e1e0f908ef30f5a4459f2bd62442d2b6649b.tar.gz
Split oe-selftests by target machines
To allow for more targeted testing Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Diffstat (limited to 'lib/oeqa/selftest/cases/updater_raspberrypi.py')
-rw-r--r--lib/oeqa/selftest/cases/updater_raspberrypi.py78
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
2import os
3import logging
4import re
5import unittest
6
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var
9
10
11class 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: