summaryrefslogtreecommitdiffstats
path: root/lib/oeqa/selftest/cases/testutils.py
diff options
context:
space:
mode:
authorMike Sul <ext-mykhaylo.sul@here.com>2019-05-23 15:38:42 +0300
committerMike Sul <ext-mykhaylo.sul@here.com>2019-05-27 10:40:00 +0300
commit5929016fad098a83286b4849f4ff96d3f5f26361 (patch)
tree259b11a3e6e9aff35d875e90c9d7a288b1dc00ff /lib/oeqa/selftest/cases/testutils.py
parent0b89fa5f5505891d8b358f8ef829b0200d238705 (diff)
downloadmeta-updater-5929016fad098a83286b4849f4ff96d3f5f26361.tar.gz
OTA-2541: IP Secondary tests (oe-selftest)
Signed-off-by: Mike Sul <ext-mykhaylo.sul@here.com>
Diffstat (limited to 'lib/oeqa/selftest/cases/testutils.py')
-rw-r--r--lib/oeqa/selftest/cases/testutils.py53
1 files changed, 30 insertions, 23 deletions
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py
index 2ad99ad..f8b1904 100644
--- a/lib/oeqa/selftest/cases/testutils.py
+++ b/lib/oeqa/selftest/cases/testutils.py
@@ -7,49 +7,57 @@ from time import sleep
7from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars 7from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
8from qemucommand import QemuCommand 8from qemucommand import QemuCommand
9 9
10logger = logging.getLogger("selftest")
10 11
11def qemu_launch(efi=False, machine=None, imagename=None): 12
12 logger = logging.getLogger("selftest") 13def qemu_launch(efi=False, machine=None, imagename='core-image-minimal', **kwargs):
13 if imagename is None: 14 qemu_bake_image(imagename)
14 imagename = 'core-image-minimal' 15 return qemu_boot_image(efi=efi, machine=machine, imagename=imagename, **kwargs)
15 logger.info('Running bitbake to build {}'.format(imagename)) 16
16 bitbake(imagename) 17
18def qemu_terminate(s):
19 try:
20 s.terminate()
21 s.wait(timeout=10)
22 except KeyboardInterrupt:
23 pass
24
25
26def qemu_boot_image(imagename, **kwargs):
17 # Create empty object. 27 # Create empty object.
18 args = type('', (), {})() 28 args = type('', (), {})()
19 args.imagename = imagename 29 args.imagename = imagename
20 args.mac = None 30 args.mac = kwargs.get('mac', None)
21 # Could use DEPLOY_DIR_IMAGE here but it's already in the machine 31 # Could use DEPLOY_DIR_IMAGE here but it's already in the machine
22 # subdirectory. 32 # subdirectory.
23 args.dir = 'tmp/deploy/images' 33 args.dir = 'tmp/deploy/images'
24 args.efi = efi 34 args.efi = kwargs.get('efi', False)
25 args.machine = machine 35 args.machine = kwargs.get('machine', None)
26 qemu_use_kvm = get_bb_var("QEMU_USE_KVM") 36 qemu_use_kvm = get_bb_var("QEMU_USE_KVM")
27 if qemu_use_kvm and \ 37 if qemu_use_kvm and \
28 (qemu_use_kvm == 'True' and 'x86' in machine or 38 (qemu_use_kvm == 'True' and 'x86' in args.machine or
29 get_bb_var('MACHINE') in qemu_use_kvm.split()): 39 get_bb_var('MACHINE') in qemu_use_kvm.split()):
30 args.kvm = True 40 args.kvm = True
31 else: 41 else:
32 args.kvm = None # Autodetect 42 args.kvm = None # Autodetect
33 args.no_gui = True 43 args.no_gui = kwargs.get('no_gui', True)
34 args.gdb = False 44 args.gdb = kwargs.get('gdb', False)
35 args.pcap = None 45 args.pcap = kwargs.get('pcap', None)
36 args.overlay = None 46 args.overlay = kwargs.get('overlay', None)
37 args.dry_run = False 47 args.dry_run = kwargs.get('dry_run', False)
38 args.secondary_network = False 48 args.secondary_network = kwargs.get('secondary_network', False)
39 49
40 qemu = QemuCommand(args) 50 qemu = QemuCommand(args)
41 cmdline = qemu.command_line() 51 cmdline = qemu.command_line()
42 print('Booting image with run-qemu-ota...') 52 print('Booting image with run-qemu-ota...')
43 s = subprocess.Popen(cmdline) 53 s = subprocess.Popen(cmdline)
44 sleep(10) 54 sleep(kwargs.get('wait_for_boot_time', 10))
45 return qemu, s 55 return qemu, s
46 56
47 57
48def qemu_terminate(s): 58def qemu_bake_image(imagename):
49 try: 59 logger.info('Running bitbake to build {}'.format(imagename))
50 s.terminate() 60 bitbake(imagename)
51 except KeyboardInterrupt:
52 pass
53 61
54 62
55def qemu_send_command(port, command, timeout=60): 63def qemu_send_command(port, command, timeout=60):
@@ -122,7 +130,6 @@ def verifyProvisioned(testInst, machine):
122 m = p.search(stdout.decode()) 130 m = p.search(stdout.decode())
123 testInst.assertTrue(m, 'Device ID could not be read: ' + stderr.decode() + stdout.decode()) 131 testInst.assertTrue(m, 'Device ID could not be read: ' + stderr.decode() + stdout.decode())
124 testInst.assertGreater(m.lastindex, 0, 'Device ID could not be read: ' + stderr.decode() + stdout.decode()) 132 testInst.assertGreater(m.lastindex, 0, 'Device ID could not be read: ' + stderr.decode() + stdout.decode())
125 logger = logging.getLogger("selftest")
126 logger.info('Device successfully provisioned with ID: ' + m.group(1)) 133 logger.info('Device successfully provisioned with ID: ' + m.group(1))
127 134
128# vim:set ts=4 sw=4 sts=4 expandtab: 135# vim:set ts=4 sw=4 sts=4 expandtab: