diff options
author | Laurent Bonnans <laurent.bonnans@here.com> | 2019-07-05 17:41:29 +0200 |
---|---|---|
committer | Laurent Bonnans <laurent.bonnans@here.com> | 2019-07-15 15:28:26 +0200 |
commit | 69d8dc6ed1405a6a05faca12f482e79cb6e0471b (patch) | |
tree | 025ebacfe5a81e5eda40c9cb84250b983fa5b04a /lib | |
parent | f68e1d59f0a0ed4341dad3b16d4979b1b63336d7 (diff) | |
download | meta-updater-69d8dc6ed1405a6a05faca12f482e79cb6e0471b.tar.gz |
Fix aktualizr-native run in oe-selftest
It did not work when using an empty build dir with sstate-cache,
the proper working way is to bitbake build_sysroots.
Also change the way we fetches some of the akautalizr package files
which was broken too.
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oeqa/selftest/cases/testutils.py | 25 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_native.py | 1 | ||||
-rw-r--r-- | lib/oeqa/selftest/cases/updater_qemux86_64.py | 20 |
3 files changed, 22 insertions, 24 deletions
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py index f8b1904..900d15c 100644 --- a/lib/oeqa/selftest/cases/testutils.py +++ b/lib/oeqa/selftest/cases/testutils.py | |||
@@ -1,4 +1,5 @@ | |||
1 | import os | 1 | import os |
2 | import oe.path | ||
2 | import logging | 3 | import logging |
3 | import re | 4 | import re |
4 | import subprocess | 5 | import subprocess |
@@ -72,20 +73,16 @@ def akt_native_run(testInst, cmd, **kwargs): | |||
72 | # run a command supplied by aktualizr-native and checks that: | 73 | # run a command supplied by aktualizr-native and checks that: |
73 | # - the executable exists | 74 | # - the executable exists |
74 | # - the command runs without error | 75 | # - the command runs without error |
75 | # NOTE: the base test class must have built aktualizr-native (in | 76 | # |
76 | # setUpClass, for example) | 77 | # Requirements in base test class (setUpClass for example): |
77 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'base_prefix', 'libdir', 'bindir'], | 78 | # bitbake aktualizr-native |
78 | 'aktualizr-native') | 79 | # bitbake build-sysroots -c build_native_sysroot |
79 | sysroot = bb_vars['SYSROOT_DESTDIR'] + bb_vars['base_prefix'] | 80 | # |
80 | sysrootbin = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] | 81 | # (technique found in poky/meta/lib/oeqa/selftest/cases/package.py) |
81 | libdir = bb_vars['libdir'] | 82 | bb_vars = get_bb_vars(['STAGING_DIR', 'BUILD_ARCH']) |
82 | 83 | sysroot = oe.path.join(bb_vars['STAGING_DIR'], bb_vars['BUILD_ARCH']) | |
83 | program, *_ = cmd.split(' ') | 84 | |
84 | p = '{}/{}'.format(sysrootbin, program) | 85 | result = runCmd(cmd, native_sysroot=sysroot, ignore_status=True, **kwargs) |
85 | testInst.assertTrue(os.path.isfile(p), msg="No {} found ({})".format(program, p)) | ||
86 | env = dict(os.environ) | ||
87 | env['LD_LIBRARY_PATH'] = libdir | ||
88 | result = runCmd(cmd, env=env, native_sysroot=sysroot, ignore_status=True, **kwargs) | ||
89 | testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | 86 | testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) |
90 | 87 | ||
91 | 88 | ||
diff --git a/lib/oeqa/selftest/cases/updater_native.py b/lib/oeqa/selftest/cases/updater_native.py index 1fc9cb8..d2bf341 100644 --- a/lib/oeqa/selftest/cases/updater_native.py +++ b/lib/oeqa/selftest/cases/updater_native.py | |||
@@ -14,6 +14,7 @@ class SotaToolsTests(OESelftestTestCase): | |||
14 | logger = logging.getLogger("selftest") | 14 | logger = logging.getLogger("selftest") |
15 | logger.info('Running bitbake to build aktualizr-native tools') | 15 | logger.info('Running bitbake to build aktualizr-native tools') |
16 | bitbake('aktualizr-native') | 16 | bitbake('aktualizr-native') |
17 | bitbake('build-sysroots -c build_native_sysroot') | ||
17 | 18 | ||
18 | def test_push_help(self): | 19 | def test_push_help(self): |
19 | akt_native_run(self, 'garage-push --help') | 20 | akt_native_run(self, 'garage-push --help') |
diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64.py b/lib/oeqa/selftest/cases/updater_qemux86_64.py index 7223e9e..04d9a6f 100644 --- a/lib/oeqa/selftest/cases/updater_qemux86_64.py +++ b/lib/oeqa/selftest/cases/updater_qemux86_64.py | |||
@@ -39,7 +39,8 @@ class AktualizrToolsTests(OESelftestTestCase): | |||
39 | super(AktualizrToolsTests, cls).setUpClass() | 39 | super(AktualizrToolsTests, cls).setUpClass() |
40 | logger = logging.getLogger("selftest") | 40 | logger = logging.getLogger("selftest") |
41 | logger.info('Running bitbake to build aktualizr-native tools') | 41 | logger.info('Running bitbake to build aktualizr-native tools') |
42 | bitbake('aktualizr-native') | 42 | bitbake('aktualizr-native aktualizr-device-prov') |
43 | bitbake('build-sysroots -c build_native_sysroot') | ||
43 | 44 | ||
44 | def test_cert_provider_help(self): | 45 | def test_cert_provider_help(self): |
45 | akt_native_run(self, 'aktualizr-cert-provider --help') | 46 | akt_native_run(self, 'aktualizr-cert-provider --help') |
@@ -47,12 +48,11 @@ class AktualizrToolsTests(OESelftestTestCase): | |||
47 | def test_cert_provider_local_output(self): | 48 | def test_cert_provider_local_output(self): |
48 | logger = logging.getLogger("selftest") | 49 | logger = logging.getLogger("selftest") |
49 | logger.info('Running bitbake to build aktualizr-device-prov') | 50 | logger.info('Running bitbake to build aktualizr-device-prov') |
50 | bitbake('aktualizr-device-prov') | ||
51 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') | 51 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') |
52 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] | 52 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] |
53 | temp_dir = bb_vars['T'] | 53 | temp_dir = bb_vars['T'] |
54 | bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-device-prov') | 54 | bb_vars_prov = get_bb_vars(['WORKDIR', 'libdir'], 'aktualizr-device-prov') |
55 | config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota-device-cred.toml' | 55 | config = bb_vars_prov['WORKDIR'] + '/sysroot-destdir' + bb_vars_prov['libdir'] + '/sota/conf.d/20-sota-device-cred.toml' |
56 | 56 | ||
57 | akt_native_run(self, 'aktualizr-cert-provider -c {creds} -r -l {temp} -g {config}' | 57 | akt_native_run(self, 'aktualizr-cert-provider -c {creds} -r -l {temp} -g {config}' |
58 | .format(creds=creds, temp=temp_dir, config=config)) | 58 | .format(creds=creds, temp=temp_dir, config=config)) |
@@ -173,8 +173,8 @@ class DeviceCredProvTests(OESelftestTestCase): | |||
173 | self.append_config('MACHINE = "qemux86-64"') | 173 | self.append_config('MACHINE = "qemux86-64"') |
174 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-device-prov "') | 174 | self.append_config('SOTA_CLIENT_PROV = " aktualizr-device-prov "') |
175 | self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"') | 175 | self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"') |
176 | runCmd('bitbake -c cleanall aktualizr aktualizr-device-prov') | ||
177 | self.qemu, self.s = qemu_launch(machine='qemux86-64') | 176 | self.qemu, self.s = qemu_launch(machine='qemux86-64') |
177 | bitbake('build-sysroots -c build_native_sysroot') | ||
178 | 178 | ||
179 | def tearDownLocal(self): | 179 | def tearDownLocal(self): |
180 | qemu_terminate(self.s) | 180 | qemu_terminate(self.s) |
@@ -201,8 +201,8 @@ class DeviceCredProvTests(OESelftestTestCase): | |||
201 | # Run aktualizr-cert-provider. | 201 | # Run aktualizr-cert-provider. |
202 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') | 202 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') |
203 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] | 203 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] |
204 | bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-device-prov') | 204 | bb_vars_prov = get_bb_vars(['WORKDIR', 'libdir'], 'aktualizr-device-prov') |
205 | config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota-device-cred.toml' | 205 | config = bb_vars_prov['WORKDIR'] + '/sysroot-destdir' + bb_vars_prov['libdir'] + '/sota/conf.d/20-sota-device-cred.toml' |
206 | 206 | ||
207 | print('Provisining at root@localhost:%d' % self.qemu.ssh_port) | 207 | print('Provisining at root@localhost:%d' % self.qemu.ssh_port) |
208 | akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -s -u -r -g {config}' | 208 | akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -s -u -r -g {config}' |
@@ -231,8 +231,8 @@ class DeviceCredProvHsmTests(OESelftestTestCase): | |||
231 | self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"') | 231 | self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"') |
232 | self.append_config('SOTA_CLIENT_FEATURES = "hsm"') | 232 | self.append_config('SOTA_CLIENT_FEATURES = "hsm"') |
233 | self.append_config('IMAGE_INSTALL_append = " softhsm-testtoken"') | 233 | self.append_config('IMAGE_INSTALL_append = " softhsm-testtoken"') |
234 | runCmd('bitbake -c cleanall aktualizr aktualizr-device-prov-hsm') | ||
235 | self.qemu, self.s = qemu_launch(machine='qemux86-64') | 234 | self.qemu, self.s = qemu_launch(machine='qemux86-64') |
235 | bitbake('build-sysroots -c build_native_sysroot') | ||
236 | 236 | ||
237 | def tearDownLocal(self): | 237 | def tearDownLocal(self): |
238 | qemu_terminate(self.s) | 238 | qemu_terminate(self.s) |
@@ -269,8 +269,8 @@ class DeviceCredProvHsmTests(OESelftestTestCase): | |||
269 | # Run aktualizr-cert-provider. | 269 | # Run aktualizr-cert-provider. |
270 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') | 270 | bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') |
271 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] | 271 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] |
272 | bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-device-prov-hsm') | 272 | bb_vars_prov = get_bb_vars(['WORKDIR', 'libdir'], 'aktualizr-device-prov-hsm') |
273 | config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota-device-cred-hsm.toml' | 273 | config = bb_vars_prov['WORKDIR'] + '/sysroot-destdir' + bb_vars_prov['libdir'] + '/sota/conf.d/20-sota-device-cred-hsm.toml' |
274 | 274 | ||
275 | akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -r -s -u -g {config}' | 275 | akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -r -s -u -g {config}' |
276 | .format(creds=creds, port=self.qemu.ssh_port, config=config)) | 276 | .format(creds=creds, port=self.qemu.ssh_port, config=config)) |