diff options
author | lbonn <lbonn@users.noreply.github.com> | 2019-07-17 09:58:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-17 09:58:39 +0200 |
commit | b11e4ab227bed2e368646cb348e41a4603ed55e0 (patch) | |
tree | 8f5430210f314fc3ef7aead29beecf99047b8894 /lib/oeqa/selftest/cases/testutils.py | |
parent | f68e1d59f0a0ed4341dad3b16d4979b1b63336d7 (diff) | |
parent | 5463396b1d47a122f5aef9a619244fd1777c0b56 (diff) | |
download | meta-updater-b11e4ab227bed2e368646cb348e41a4603ed55e0.tar.gz |
Merge pull request #537 from advancedtelematic/ci/oe-selftest
Ci/oe selftest
Diffstat (limited to 'lib/oeqa/selftest/cases/testutils.py')
-rw-r--r-- | lib/oeqa/selftest/cases/testutils.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py index f8b1904..8d618a6 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 |
@@ -33,6 +34,7 @@ def qemu_boot_image(imagename, **kwargs): | |||
33 | args.dir = 'tmp/deploy/images' | 34 | args.dir = 'tmp/deploy/images' |
34 | args.efi = kwargs.get('efi', False) | 35 | args.efi = kwargs.get('efi', False) |
35 | args.machine = kwargs.get('machine', None) | 36 | args.machine = kwargs.get('machine', None) |
37 | args.mem = kwargs.get('mem', '128M') | ||
36 | qemu_use_kvm = get_bb_var("QEMU_USE_KVM") | 38 | qemu_use_kvm = get_bb_var("QEMU_USE_KVM") |
37 | if qemu_use_kvm and \ | 39 | if qemu_use_kvm and \ |
38 | (qemu_use_kvm == 'True' and 'x86' in args.machine or | 40 | (qemu_use_kvm == 'True' and 'x86' in args.machine or |
@@ -60,7 +62,7 @@ def qemu_bake_image(imagename): | |||
60 | bitbake(imagename) | 62 | bitbake(imagename) |
61 | 63 | ||
62 | 64 | ||
63 | def qemu_send_command(port, command, timeout=60): | 65 | def qemu_send_command(port, command, timeout=120): |
64 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | 66 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + |
65 | str(port) + ' "' + command + '"'] | 67 | str(port) + ' "' + command + '"'] |
66 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 68 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
@@ -68,24 +70,30 @@ def qemu_send_command(port, command, timeout=60): | |||
68 | return stdout, stderr, s2.returncode | 70 | return stdout, stderr, s2.returncode |
69 | 71 | ||
70 | 72 | ||
73 | def metadir(): | ||
74 | # Assume the directory layout for finding other layers. We could also | ||
75 | # make assumptions by using 'show-layers', but either way, if the | ||
76 | # layers we need aren't where we expect them, we are out of luck. | ||
77 | path = os.path.abspath(os.path.dirname(__file__)) | ||
78 | metadir = path + "/../../../../../" | ||
79 | |||
80 | return metadir | ||
81 | |||
82 | |||
71 | def akt_native_run(testInst, cmd, **kwargs): | 83 | def akt_native_run(testInst, cmd, **kwargs): |
72 | # run a command supplied by aktualizr-native and checks that: | 84 | # run a command supplied by aktualizr-native and checks that: |
73 | # - the executable exists | 85 | # - the executable exists |
74 | # - the command runs without error | 86 | # - the command runs without error |
75 | # NOTE: the base test class must have built aktualizr-native (in | 87 | # |
76 | # setUpClass, for example) | 88 | # Requirements in base test class (setUpClass for example): |
77 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'base_prefix', 'libdir', 'bindir'], | 89 | # bitbake aktualizr-native |
78 | 'aktualizr-native') | 90 | # bitbake build-sysroots -c build_native_sysroot |
79 | sysroot = bb_vars['SYSROOT_DESTDIR'] + bb_vars['base_prefix'] | 91 | # |
80 | sysrootbin = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] | 92 | # (technique found in poky/meta/lib/oeqa/selftest/cases/package.py) |
81 | libdir = bb_vars['libdir'] | 93 | bb_vars = get_bb_vars(['STAGING_DIR', 'BUILD_ARCH']) |
82 | 94 | sysroot = oe.path.join(bb_vars['STAGING_DIR'], bb_vars['BUILD_ARCH']) | |
83 | program, *_ = cmd.split(' ') | 95 | |
84 | p = '{}/{}'.format(sysrootbin, program) | 96 | 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) | 97 | testInst.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) |
90 | 98 | ||
91 | 99 | ||