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.py38
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 @@
1import os 1import os
2import oe.path
2import logging 3import logging
3import re 4import re
4import subprocess 5import 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
63def qemu_send_command(port, command, timeout=60): 65def 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
73def 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
71def akt_native_run(testInst, cmd, **kwargs): 83def 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