summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2018-02-19 16:52:12 +0100
committerPatrick Vacek <patrickvacek@gmail.com>2018-02-20 11:01:34 +0100
commit5c141641e143883e06b815371dd69551dbf3d52a (patch)
treec3eeac35f5f08695d25398d52236cedd6b81e716
parenteb173b6cba56c5b97465a6506a9a69b2f1c858f7 (diff)
downloadmeta-updater-5c141641e143883e06b815371dd69551dbf3d52a.tar.gz
oe-selftest standardization and general improvement.
-rw-r--r--lib/oeqa/selftest/updater.py72
1 files changed, 42 insertions, 30 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py
index c8ec711..0ef3e16 100644
--- a/lib/oeqa/selftest/updater.py
+++ b/lib/oeqa/selftest/updater.py
@@ -173,10 +173,11 @@ class QemuTests(oeSelfTest):
173 def qemu_command(self, command): 173 def qemu_command(self, command):
174 return qemu_send_command(self.qemu.ssh_port, command) 174 return qemu_send_command(self.qemu.ssh_port, command)
175 175
176 def test_hostname(self): 176 def test_qemu(self):
177 print('')
178 print('Checking machine name (hostname) of device:') 177 print('Checking machine name (hostname) of device:')
179 stdout, stderr, retcode = self.qemu_command('hostname') 178 stdout, stderr, retcode = self.qemu_command('hostname')
179 self.assertEqual(retcode, 0, "Unable to check hostname. " +
180 "Is an ssh daemon (such as dropbear or openssh) installed on the device?")
180 machine = get_bb_var('MACHINE', 'core-image-minimal') 181 machine = get_bb_var('MACHINE', 'core-image-minimal')
181 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode()) 182 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
182 # Strip off line ending. 183 # Strip off line ending.
@@ -184,27 +185,14 @@ class QemuTests(oeSelfTest):
184 self.assertEqual(value_str, machine, 185 self.assertEqual(value_str, machine,
185 'MACHINE does not match hostname: ' + machine + ', ' + value_str) 186 'MACHINE does not match hostname: ' + machine + ', ' + value_str)
186 print(value_str) 187 print(value_str)
187
188 def test_var_sota(self):
189 print('')
190 print('Checking contents of /var/sota:')
191 stdout, stderr, retcode = self.qemu_command('ls /var/sota')
192 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
193 self.assertEqual(retcode, 0)
194 print(stdout.decode())
195
196 def test_aktualizr_info(self):
197 print('Checking output of aktualizr-info:') 188 print('Checking output of aktualizr-info:')
198 ran_ok = False 189 ran_ok = False
199 for delay in [0, 1, 2, 5, 10, 15]: 190 for delay in [0, 1, 2, 5, 10, 15]:
200 sleep(delay) 191 sleep(delay)
201 try: 192 stdout, stderr, retcode = self.qemu_command('aktualizr-info')
202 stdout, stderr, retcode = self.qemu_command('aktualizr-info') 193 if retcode == 0 and stderr == b'':
203 if retcode == 0 and stderr == b'': 194 ran_ok = True
204 ran_ok = True 195 break
205 break
206 except IOError as e:
207 print(e)
208 self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode()) 196 self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
209 197
210 198
@@ -227,26 +215,39 @@ class GrubTests(oeSelfTest):
227 runCmd('bitbake-layers remove-layer "%s"' % self.meta_intel, ignore_status=True) 215 runCmd('bitbake-layers remove-layer "%s"' % self.meta_intel, ignore_status=True)
228 runCmd('bitbake-layers remove-layer "%s"' % self.meta_minnow, ignore_status=True) 216 runCmd('bitbake-layers remove-layer "%s"' % self.meta_minnow, ignore_status=True)
229 217
218 def qemu_command(self, command):
219 return qemu_send_command(self.qemu.ssh_port, command)
220
230 def test_grub(self): 221 def test_grub(self):
231 print('') 222 print('')
232 print('Checking machine name (hostname) of device:') 223 print('Checking machine name (hostname) of device:')
233 value, err, retcode = qemu_send_command(self.qemu.ssh_port, 'hostname') 224 stdout, stderr, retcode = self.qemu_command('hostname')
225 self.assertEqual(retcode, 0, "Unable to check hostname. " +
226 "Is an ssh daemon (such as dropbear or openssh) installed on the device?")
234 machine = get_bb_var('MACHINE', 'core-image-minimal') 227 machine = get_bb_var('MACHINE', 'core-image-minimal')
235 self.assertEqual(err, b'', 'Error: ' + err.decode()) 228 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
236 self.assertEqual(retcode, 0)
237 # Strip off line ending. 229 # Strip off line ending.
238 value_str = value.decode()[:-1] 230 value = stdout.decode()[:-1]
239 self.assertEqual(value_str, machine, 231 self.assertEqual(value, machine,
240 'MACHINE does not match hostname: ' + machine + ', ' + value_str + 232 'MACHINE does not match hostname: ' + machine + ', ' + value +
241 '\nIs tianocore ovmf installed?') 233 '\nIs TianoCore ovmf installed?')
242 print(value_str) 234 print(value)
235 print('Checking output of aktualizr-info:')
236 ran_ok = False
237 for delay in [0, 1, 2, 5, 10, 15]:
238 sleep(delay)
239 stdout, stderr, retcode = self.qemu_command('aktualizr-info')
240 if retcode == 0 and stderr == b'':
241 ran_ok = True
242 break
243 self.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
243 244
244 245
245class HsmTests(oeSelfTest): 246class HsmTests(oeSelfTest):
246 247
247 def setUpLocal(self): 248 def setUpLocal(self):
248 self.write_config('SOTA_CLIENT_PROV = " aktualizr-hsm-prov "') 249 self.write_config('SOTA_CLIENT_PROV = "aktualizr-hsm-prov"')
249 self.write_config('SOTA_CLIENT_FEATURES="hsm"') 250 self.write_config('SOTA_CLIENT_FEATURES = "hsm"')
250 self.qemu, self.s = qemu_launch(machine='qemux86-64') 251 self.qemu, self.s = qemu_launch(machine='qemux86-64')
251 252
252 def tearDownLocal(self): 253 def tearDownLocal(self):
@@ -256,7 +257,18 @@ class HsmTests(oeSelfTest):
256 return qemu_send_command(self.qemu.ssh_port, command) 257 return qemu_send_command(self.qemu.ssh_port, command)
257 258
258 def test_provisioning(self): 259 def test_provisioning(self):
259 print('') 260 print('Checking machine name (hostname) of device:')
261 stdout, stderr, retcode = self.qemu_command('hostname')
262 self.assertEqual(retcode, 0, "Unable to check hostname. " +
263 "Is an ssh daemon (such as dropbear or openssh) installed on the device?")
264 machine = get_bb_var('MACHINE', 'core-image-minimal')
265 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
266 # Strip off line ending.
267 value_str = stdout.decode()[:-1]
268 self.assertEqual(value_str, machine,
269 'MACHINE does not match hostname: ' + machine + ', ' + value_str)
270 print(value_str)
271 print('Checking output of aktualizr-info:')
260 ran_ok = False 272 ran_ok = False
261 for delay in [0, 1, 2, 5, 10, 15]: 273 for delay in [0, 1, 2, 5, 10, 15]:
262 stdout, stderr, retcode = self.qemu_command('aktualizr-info') 274 stdout, stderr, retcode = self.qemu_command('aktualizr-info')