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