summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
l---------lib/oeqa/selftest/cases/qemucommand.py1
-rw-r--r--lib/oeqa/selftest/cases/updater.py (renamed from lib/oeqa/selftest/updater.py)81
l---------lib/oeqa/selftest/qemucommand.py1
3 files changed, 56 insertions, 27 deletions
diff --git a/lib/oeqa/selftest/cases/qemucommand.py b/lib/oeqa/selftest/cases/qemucommand.py
new file mode 120000
index 0000000..075cdb8
--- /dev/null
+++ b/lib/oeqa/selftest/cases/qemucommand.py
@@ -0,0 +1 @@
../../../../scripts/qemucommand.py \ No newline at end of file
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/cases/updater.py
index f28349f..91ac9fc 100644
--- a/lib/oeqa/selftest/updater.py
+++ b/lib/oeqa/selftest/cases/updater.py
@@ -1,18 +1,20 @@
1import unittest 1# pylint: disable=C0111,C0325
2import os 2import os
3import logging 3import logging
4import subprocess 4import subprocess
5import time 5import unittest
6from time import sleep
6 7
7from oeqa.selftest.base import oeSelfTest 8from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars 9from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
9from oeqa.selftest.qemucommand import QemuCommand 10from qemucommand import QemuCommand
10 11
11 12
12class SotaToolsTests(oeSelfTest): 13class SotaToolsTests(OESelftestTestCase):
13 14
14 @classmethod 15 @classmethod
15 def setUpClass(cls): 16 def setUpClass(cls):
17 super(SotaToolsTests, cls).setUpClass()
16 logger = logging.getLogger("selftest") 18 logger = logging.getLogger("selftest")
17 logger.info('Running bitbake to build aktualizr-native tools') 19 logger.info('Running bitbake to build aktualizr-native tools')
18 bitbake('aktualizr-native') 20 bitbake('aktualizr-native')
@@ -38,22 +40,23 @@ class SotaToolsTests(oeSelfTest):
38 result = runCmd('%s --help' % p, ignore_status=True) 40 result = runCmd('%s --help' % p, ignore_status=True)
39 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) 41 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output)
40 42
41class HsmTests(oeSelfTest): 43
44class HsmTests(OESelftestTestCase):
42 45
43 def test_hsm(self): 46 def test_hsm(self):
44 self.write_config('SOTA_CLIENT_FEATURES="hsm"') 47 self.write_config('SOTA_CLIENT_FEATURES="hsm"')
45 bitbake('core-image-minimal') 48 bitbake('core-image-minimal')
46 49
47 50
48class GeneralTests(oeSelfTest): 51class GeneralTests(OESelftestTestCase):
49 52
50 def test_feature_sota(self): 53 def test_feature_sota(self):
51 result = get_bb_var('DISTRO_FEATURES').find('sota') 54 result = get_bb_var('DISTRO_FEATURES').find('sota')
52 self.assertNotEqual(result, -1, 'Feature "sota" not set at DISTRO_FEATURES'); 55 self.assertNotEqual(result, -1, 'Feature "sota" not set at DISTRO_FEATURES')
53 56
54 def test_feature_systemd(self): 57 def test_feature_systemd(self):
55 result = get_bb_var('DISTRO_FEATURES').find('systemd') 58 result = get_bb_var('DISTRO_FEATURES').find('systemd')
56 self.assertNotEqual(result, -1, 'Feature "systemd" not set at DISTRO_FEATURES'); 59 self.assertNotEqual(result, -1, 'Feature "systemd" not set at DISTRO_FEATURES')
57 60
58 def test_credentials(self): 61 def test_credentials(self):
59 bitbake('core-image-minimal') 62 bitbake('core-image-minimal')
@@ -66,7 +69,8 @@ class GeneralTests(oeSelfTest):
66 deploydir = get_bb_var('DEPLOY_DIR_IMAGE') 69 deploydir = get_bb_var('DEPLOY_DIR_IMAGE')
67 imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal') 70 imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal')
68 # Check if the credentials are included in the output image 71 # Check if the credentials are included in the output image
69 result = runCmd('tar -jtvf %s/%s.tar.bz2 | grep sota_provisioning_credentials.zip' % (deploydir, imagename), ignore_status=True) 72 result = runCmd('tar -jtvf %s/%s.tar.bz2 | grep sota_provisioning_credentials.zip' %
73 (deploydir, imagename), ignore_status=True)
70 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) 74 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output)
71 75
72 def test_java(self): 76 def test_java(self):
@@ -99,29 +103,33 @@ class GeneralTests(oeSelfTest):
99 self.assertEqual(result.output, 'ERROR: Unable to find any package producing path /usr/bin/man') 103 self.assertEqual(result.output, 'ERROR: Unable to find any package producing path /usr/bin/man')
100 path2 = os.path.realpath(image_path) 104 path2 = os.path.realpath(image_path)
101 size2 = os.path.getsize(path2) 105 size2 = os.path.getsize(path2)
102 logger.info('Second image %s has size %i' % (path2, size2)) 106 logger.info('Second image %s has size %i', path2, size2)
103 self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.") 107 self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.")
104 self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") 108 self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.")
105 109
106 110
107class QemuTests(oeSelfTest): 111class QemuTests(OESelftestTestCase):
108 112
109 @classmethod 113 @classmethod
110 def setUpClass(cls): 114 def setUpClass(cls):
115 super(QemuTests, cls).setUpClass()
111 cls.qemu, cls.s = qemu_launch(machine='qemux86-64') 116 cls.qemu, cls.s = qemu_launch(machine='qemux86-64')
112 117
113 @classmethod 118 @classmethod
114 def tearDownClass(cls): 119 def tearDownClass(cls):
115 qemu_terminate(cls.s) 120 qemu_terminate(cls.s)
116 121
122 def run_command(self, command):
123 return qemu_send_command(self.qemu.ssh_port, command)
124
117 def test_hostname(self): 125 def test_hostname(self):
118 print('') 126 print('')
119 print('Checking machine name (hostname) of device:') 127 print('Checking machine name (hostname) of device:')
120 value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') 128 stdout, stderr, retcode = self.run_command('hostname')
121 machine = get_bb_var('MACHINE', 'core-image-minimal') 129 machine = get_bb_var('MACHINE', 'core-image-minimal')
122 self.assertEqual(err, b'', 'Error: ' + err.decode()) 130 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
123 # Strip off line ending. 131 # Strip off line ending.
124 value_str = value.decode()[:-1] 132 value_str = stdout.decode()[:-1]
125 self.assertEqual(value_str, machine, 133 self.assertEqual(value_str, machine,
126 'MACHINE does not match hostname: ' + machine + ', ' + value_str) 134 'MACHINE does not match hostname: ' + machine + ', ' + value_str)
127 print(value_str) 135 print(value_str)
@@ -129,16 +137,34 @@ class QemuTests(oeSelfTest):
129 def test_var_sota(self): 137 def test_var_sota(self):
130 print('') 138 print('')
131 print('Checking contents of /var/sota:') 139 print('Checking contents of /var/sota:')
132 value, err = qemu_send_command(self.qemu.ssh_port, 'ls /var/sota') 140 stdout, stderr, retcode = self.run_command('ls /var/sota')
133 self.assertEqual(err, b'', 'Error: ' + err.decode()) 141 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
134 print(value.decode()) 142 self.assertEqual(retcode, 0)
135 143 print(stdout.decode())
136class GrubTests(oeSelfTest): 144
145 def test_aktualizr_info(self):
146 print('Checking output of aktualizr-info:')
147 ran_ok = False
148 for delay in [0, 1, 2, 5, 10, 15]:
149 sleep(delay)
150 try:
151 stdout, stderr, retcode = self.run_command('aktualizr-info')
152 if retcode == 0 and stderr == b'':
153 ran_ok = True
154 break
155 except IOError as e:
156 print(e)
157 if not ran_ok:
158 print(stdout.decode())
159 print(stderr.decode())
160
161
162class GrubTests(OESelftestTestCase):
137 163
138 def setUpLocal(self): 164 def setUpLocal(self):
139 # This is a bit of a hack but I can't see a better option. 165 # This is a bit of a hack but I can't see a better option.
140 path = os.path.abspath(os.path.dirname(__file__)) 166 path = os.path.abspath(os.path.dirname(__file__))
141 metadir = path + "/../../../../" 167 metadir = path + "/../../../../../"
142 grub_config = 'OSTREE_BOOTLOADER = "grub"\nMACHINE = "intel-corei7-64"' 168 grub_config = 'OSTREE_BOOTLOADER = "grub"\nMACHINE = "intel-corei7-64"'
143 self.append_config(grub_config) 169 self.append_config(grub_config)
144 self.meta_intel = metadir + "meta-intel" 170 self.meta_intel = metadir + "meta-intel"
@@ -155,13 +181,15 @@ class GrubTests(oeSelfTest):
155 def test_grub(self): 181 def test_grub(self):
156 print('') 182 print('')
157 print('Checking machine name (hostname) of device:') 183 print('Checking machine name (hostname) of device:')
158 value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') 184 value, err, retcode = qemu_send_command(self.qemu.ssh_port, 'hostname')
159 machine = get_bb_var('MACHINE', 'core-image-minimal') 185 machine = get_bb_var('MACHINE', 'core-image-minimal')
160 self.assertEqual(err, b'', 'Error: ' + err.decode()) 186 self.assertEqual(err, b'', 'Error: ' + err.decode())
187 self.assertEqual(retcode, 0)
161 # Strip off line ending. 188 # Strip off line ending.
162 value_str = value.decode()[:-1] 189 value_str = value.decode()[:-1]
163 self.assertEqual(value_str, machine, 190 self.assertEqual(value_str, machine,
164 'MACHINE does not match hostname: ' + machine + ', ' + value_str) 191 'MACHINE does not match hostname: ' + machine + ', ' + value_str +
192 '\nIs tianocore ovmf installed?')
165 print(value_str) 193 print(value_str)
166 194
167 195
@@ -189,7 +217,7 @@ def qemu_launch(efi=False, machine=None):
189 cmdline = qemu.command_line() 217 cmdline = qemu.command_line()
190 print('Booting image with run-qemu-ota...') 218 print('Booting image with run-qemu-ota...')
191 s = subprocess.Popen(cmdline) 219 s = subprocess.Popen(cmdline)
192 time.sleep(10) 220 sleep(10)
193 return qemu, s 221 return qemu, s
194 222
195def qemu_terminate(s): 223def qemu_terminate(s):
@@ -202,6 +230,7 @@ def qemu_send_command(port, command):
202 command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + 230 command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' +
203 str(port) + ' "' + command + '"'] 231 str(port) + ' "' + command + '"']
204 s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 232 s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
205 value, err = s2.communicate() 233 stdout, stderr = s2.communicate()
206 return value, err 234 return stdout, stderr, s2.returncode
207 235
236# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/lib/oeqa/selftest/qemucommand.py b/lib/oeqa/selftest/qemucommand.py
deleted file mode 120000
index bc06dde..0000000
--- a/lib/oeqa/selftest/qemucommand.py
+++ /dev/null
@@ -1 +0,0 @@
1../../../scripts/qemucommand.py \ No newline at end of file