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