1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
import os
import re
from time import sleep
from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import runCmd, bitbake, get_bb_var
from testutils import qemu_launch, qemu_send_command, qemu_terminate, verifyProvisioned
class MinnowTests(OESelftestTestCase):
def setUpLocal(self):
layer_intel = "meta-intel"
layer_minnow = "meta-updater-minnowboard"
result = runCmd('bitbake-layers show-layers')
# Assume the directory layout for finding other layers. We could also
# make assumptions by using 'show-layers', but either way, if the
# layers we need aren't where we expect them, we are out of luck.
path = os.path.abspath(os.path.dirname(__file__))
metadir = path + "/../../../../../"
if re.search(layer_intel, result.output) is None:
self.meta_intel = metadir + layer_intel
runCmd('bitbake-layers add-layer "%s"' % self.meta_intel)
else:
self.meta_intel = None
if re.search(layer_minnow, result.output) is None:
self.meta_minnow = metadir + layer_minnow
runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow)
else:
self.meta_minnow = None
self.append_config('MACHINE = "intel-corei7-64"')
self.append_config('OSTREE_BOOTLOADER = "grub"')
self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "')
self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64')
def tearDownLocal(self):
qemu_terminate(self.s)
if self.meta_intel:
runCmd('bitbake-layers remove-layer "%s"' % self.meta_intel, ignore_status=True)
if self.meta_minnow:
runCmd('bitbake-layers remove-layer "%s"' % self.meta_minnow, ignore_status=True)
def qemu_command(self, command):
return qemu_send_command(self.qemu.ssh_port, command)
def test_provisioning(self):
print('Checking machine name (hostname) of device:')
stdout, stderr, retcode = self.qemu_command('hostname')
self.assertEqual(retcode, 0, "Unable to check hostname. " +
"Is an ssh daemon (such as dropbear or openssh) installed on the device?")
machine = get_bb_var('MACHINE', 'core-image-minimal')
self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
# Strip off line ending.
value = stdout.decode()[:-1]
self.assertEqual(value, machine,
'MACHINE does not match hostname: ' + machine + ', ' + value +
'\nIs TianoCore ovmf installed on your host machine?')
print(value)
print('Checking output of aktualizr-info:')
ran_ok = False
for delay in [1, 2, 5, 10, 15]:
stdout, stderr, retcode = self.qemu_command('aktualizr-info')
if retcode == 0 and stderr == b'':
ran_ok = True
break
sleep(delay)
self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
verifyProvisioned(self, machine)
# vim:set ts=4 sw=4 sts=4 expandtab:
|