summaryrefslogtreecommitdiffstats
path: root/lib/oeqa/selftest/cases/testutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oeqa/selftest/cases/testutils.py')
-rw-r--r--lib/oeqa/selftest/cases/testutils.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py
index d381d7d..90ba653 100644
--- a/lib/oeqa/selftest/cases/testutils.py
+++ b/lib/oeqa/selftest/cases/testutils.py
@@ -81,16 +81,42 @@ def akt_native_run(testInst, cmd, **kwargs):
81 testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) 81 testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output)
82 82
83 83
84def verifyNotProvisioned(testInst, machine):
85 print('Checking output of aktualizr-info:')
86 ran_ok = False
87 for delay in [5, 5, 5, 5, 10, 10, 10, 10]:
88 stdout, stderr, retcode = testInst.qemu_command('aktualizr-info')
89 if retcode == 0 and stderr == b'':
90 ran_ok = True
91 break
92 sleep(delay)
93 testInst.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
94
95 # Verify that device has NOT yet provisioned.
96 testInst.assertIn(b'Couldn\'t load device ID', stdout,
97 'Device already provisioned!? ' + stderr.decode() + stdout.decode())
98 testInst.assertIn(b'Couldn\'t load ECU serials', stdout,
99 'Device already provisioned!? ' + stderr.decode() + stdout.decode())
100 testInst.assertIn(b'Provisioned on server: no', stdout,
101 'Device already provisioned!? ' + stderr.decode() + stdout.decode())
102 testInst.assertIn(b'Fetched metadata: no', stdout,
103 'Device already provisioned!? ' + stderr.decode() + stdout.decode())
104
105
84def verifyProvisioned(testInst, machine): 106def verifyProvisioned(testInst, machine):
85 # Verify that device HAS provisioned. 107 # Verify that device HAS provisioned.
108 ran_ok = False
86 for delay in [5, 5, 5, 5, 10, 10, 10, 10]: 109 for delay in [5, 5, 5, 5, 10, 10, 10, 10]:
87 stdout, stderr, retcode = testInst.qemu_command('aktualizr-info') 110 stdout, stderr, retcode = testInst.qemu_command('aktualizr-info')
88 if retcode == 0 and stderr == b'' and stdout.decode().find('Fetched metadata: yes') >= 0: 111 if retcode == 0 and stderr == b'' and stdout.decode().find('Fetched metadata: yes') >= 0:
112 ran_ok = True
89 break 113 break
90 sleep(delay) 114 sleep(delay)
115 testInst.assertTrue(ran_ok, 'aktualizr-info failed: ' + stderr.decode() + stdout.decode())
116
91 testInst.assertIn(b'Device ID: ', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode()) 117 testInst.assertIn(b'Device ID: ', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode())
92 testInst.assertIn(b'Primary ecu hardware ID: ' + machine.encode(), stdout, 118 testInst.assertIn(b'Primary ecu hardware ID: ' + machine.encode(), stdout,
93 'Provisioning failed: ' + stderr.decode() + stdout.decode()) 119 'Provisioning failed: ' + stderr.decode() + stdout.decode())
94 testInst.assertIn(b'Fetched metadata: yes', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode()) 120 testInst.assertIn(b'Fetched metadata: yes', stdout, 'Provisioning failed: ' + stderr.decode() + stdout.decode())
95 p = re.compile(r'Device ID: ([a-z0-9-]*)\n') 121 p = re.compile(r'Device ID: ([a-z0-9-]*)\n')
96 m = p.search(stdout.decode()) 122 m = p.search(stdout.decode())