summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-recipe/testexport.bbclass6
-rw-r--r--meta/classes-recipe/testimage.bbclass20
-rw-r--r--meta/lib/oeqa/core/target/qemu.py5
-rw-r--r--meta/lib/oeqa/runtime/context.py11
-rw-r--r--meta/lib/oeqa/targetcontrol.py2
-rw-r--r--meta/lib/oeqa/utils/dump.py20
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py18
7 files changed, 8 insertions, 74 deletions
diff --git a/meta/classes-recipe/testexport.bbclass b/meta/classes-recipe/testexport.bbclass
index 0f0c56107f..572f5d9e76 100644
--- a/meta/classes-recipe/testexport.bbclass
+++ b/meta/classes-recipe/testexport.bbclass
@@ -61,16 +61,12 @@ def testexport_main(d):
61 d.getVar("TEST_TARGET"), None, d.getVar("TEST_TARGET_IP"), 61 d.getVar("TEST_TARGET"), None, d.getVar("TEST_TARGET_IP"),
62 d.getVar("TEST_SERVER_IP")) 62 d.getVar("TEST_SERVER_IP"))
63 63
64 host_dumper = OERuntimeTestContextExecutor.getHostDumper(
65 d.getVar("testimage_dump_host"), d.getVar("TESTIMAGE_DUMP_DIR"))
66
67 image_manifest = "%s.manifest" % image_name 64 image_manifest = "%s.manifest" % image_name
68 image_packages = OERuntimeTestContextExecutor.readPackagesManifest(image_manifest) 65 image_packages = OERuntimeTestContextExecutor.readPackagesManifest(image_manifest)
69 66
70 extract_dir = d.getVar("TEST_EXTRACTED_DIR") 67 extract_dir = d.getVar("TEST_EXTRACTED_DIR")
71 68
72 tc = OERuntimeTestContext(td, logger, target, host_dumper, 69 tc = OERuntimeTestContext(td, logger, target, image_packages, extract_dir)
73 image_packages, extract_dir)
74 70
75 copy_needed_files(d, tc) 71 copy_needed_files(d, tc)
76 72
diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass
index b48cd96575..cc3650ad42 100644
--- a/meta/classes-recipe/testimage.bbclass
+++ b/meta/classes-recipe/testimage.bbclass
@@ -115,18 +115,6 @@ testimage_dump_target () {
115 find /var/log/ -type f 2>/dev/null -exec echo "====================" \; -exec echo {} \; -exec echo "====================" \; -exec cat {} \; -exec echo "" \; 115 find /var/log/ -type f 2>/dev/null -exec echo "====================" \; -exec echo {} \; -exec echo "====================" \; -exec cat {} \; -exec echo "" \;
116} 116}
117 117
118testimage_dump_host () {
119 top -bn1
120 iostat -x -z -N -d -p ALL 20 2
121 ps -ef
122 free
123 df
124 memstat
125 dmesg
126 ip -s link
127 netstat -an
128}
129
130testimage_dump_monitor () { 118testimage_dump_monitor () {
131 query-status 119 query-status
132 query-block 120 query-block
@@ -339,19 +327,13 @@ def testimage_main(d):
339 # runtime use network for download projects for build 327 # runtime use network for download projects for build
340 export_proxies(d) 328 export_proxies(d)
341 329
342 # we need the host dumper in test context
343 host_dumper = OERuntimeTestContextExecutor.getHostDumper(
344 d.getVar("testimage_dump_host"),
345 d.getVar("TESTIMAGE_DUMP_DIR"))
346
347 # the robot dance 330 # the robot dance
348 target = OERuntimeTestContextExecutor.getTarget( 331 target = OERuntimeTestContextExecutor.getTarget(
349 d.getVar("TEST_TARGET"), logger, d.getVar("TEST_TARGET_IP"), 332 d.getVar("TEST_TARGET"), logger, d.getVar("TEST_TARGET_IP"),
350 d.getVar("TEST_SERVER_IP"), **target_kwargs) 333 d.getVar("TEST_SERVER_IP"), **target_kwargs)
351 334
352 # test context 335 # test context
353 tc = OERuntimeTestContext(td, logger, target, host_dumper, 336 tc = OERuntimeTestContext(td, logger, target, image_packages, extract_dir)
354 image_packages, extract_dir)
355 337
356 # Load tests before starting the target 338 # Load tests before starting the target
357 test_paths = get_runtime_paths(d) 339 test_paths = get_runtime_paths(d)
diff --git a/meta/lib/oeqa/core/target/qemu.py b/meta/lib/oeqa/core/target/qemu.py
index 79fd724f7d..6893d10226 100644
--- a/meta/lib/oeqa/core/target/qemu.py
+++ b/meta/lib/oeqa/core/target/qemu.py
@@ -22,7 +22,7 @@ supported_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
22class OEQemuTarget(OESSHTarget): 22class OEQemuTarget(OESSHTarget):
23 def __init__(self, logger, server_ip, timeout=300, user='root', 23 def __init__(self, logger, server_ip, timeout=300, user='root',
24 port=None, machine='', rootfs='', kernel='', kvm=False, slirp=False, 24 port=None, machine='', rootfs='', kernel='', kvm=False, slirp=False,
25 dump_dir='', dump_host_cmds='', display='', bootlog='', 25 dump_dir='', display='', bootlog='',
26 tmpdir='', dir_image='', boottime=60, serial_ports=2, 26 tmpdir='', dir_image='', boottime=60, serial_ports=2,
27 boot_patterns = defaultdict(str), ovmf=False, tmpfsdir=None, **kwargs): 27 boot_patterns = defaultdict(str), ovmf=False, tmpfsdir=None, **kwargs):
28 28
@@ -44,8 +44,7 @@ class OEQemuTarget(OESSHTarget):
44 self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir, 44 self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir,
45 deploy_dir_image=dir_image, display=display, 45 deploy_dir_image=dir_image, display=display,
46 logfile=bootlog, boottime=boottime, 46 logfile=bootlog, boottime=boottime,
47 use_kvm=kvm, use_slirp=slirp, dump_dir=dump_dir, 47 use_kvm=kvm, use_slirp=slirp, dump_dir=dump_dir, logger=logger,
48 dump_host_cmds=dump_host_cmds, logger=logger,
49 serial_ports=serial_ports, boot_patterns = boot_patterns, 48 serial_ports=serial_ports, boot_patterns = boot_patterns,
50 use_ovmf=ovmf, tmpfsdir=tmpfsdir) 49 use_ovmf=ovmf, tmpfsdir=tmpfsdir)
51 dump_monitor_cmds = kwargs.get("testimage_dump_monitor") 50 dump_monitor_cmds = kwargs.get("testimage_dump_monitor")
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 0c5d1869ab..cb7227a8df 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -10,7 +10,6 @@ import sys
10from oeqa.core.context import OETestContext, OETestContextExecutor 10from oeqa.core.context import OETestContext, OETestContextExecutor
11from oeqa.core.target.ssh import OESSHTarget 11from oeqa.core.target.ssh import OESSHTarget
12from oeqa.core.target.qemu import OEQemuTarget 12from oeqa.core.target.qemu import OEQemuTarget
13from oeqa.utils.dump import HostDumper
14 13
15from oeqa.runtime.loader import OERuntimeTestLoader 14from oeqa.runtime.loader import OERuntimeTestLoader
16 15
@@ -20,12 +19,11 @@ class OERuntimeTestContext(OETestContext):
20 os.path.dirname(os.path.abspath(__file__)), "files") 19 os.path.dirname(os.path.abspath(__file__)), "files")
21 20
22 def __init__(self, td, logger, target, 21 def __init__(self, td, logger, target,
23 host_dumper, image_packages, extract_dir): 22 image_packages, extract_dir):
24 super(OERuntimeTestContext, self).__init__(td, logger) 23 super(OERuntimeTestContext, self).__init__(td, logger)
25 24
26 self.target = target 25 self.target = target
27 self.image_packages = image_packages 26 self.image_packages = image_packages
28 self.host_dumper = host_dumper
29 self.extract_dir = extract_dir 27 self.extract_dir = extract_dir
30 self._set_target_cmds() 28 self._set_target_cmds()
31 29
@@ -199,10 +197,6 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
199 197
200 return image_packages 198 return image_packages
201 199
202 @staticmethod
203 def getHostDumper(cmds, directory):
204 return HostDumper(cmds, directory)
205
206 def _process_args(self, logger, args): 200 def _process_args(self, logger, args):
207 if not args.packages_manifest: 201 if not args.packages_manifest:
208 raise TypeError('Manifest file not provided') 202 raise TypeError('Manifest file not provided')
@@ -215,9 +209,6 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
215 self.tc_kwargs['init']['target'] = \ 209 self.tc_kwargs['init']['target'] = \
216 OERuntimeTestContextExecutor.getTarget(args.target_type, 210 OERuntimeTestContextExecutor.getTarget(args.target_type,
217 None, args.target_ip, args.server_ip, **target_kwargs) 211 None, args.target_ip, args.server_ip, **target_kwargs)
218 self.tc_kwargs['init']['host_dumper'] = \
219 OERuntimeTestContextExecutor.getHostDumper(None,
220 args.host_dumper_dir)
221 self.tc_kwargs['init']['image_packages'] = \ 212 self.tc_kwargs['init']['image_packages'] = \
222 OERuntimeTestContextExecutor.readPackagesManifest( 213 OERuntimeTestContextExecutor.readPackagesManifest(
223 args.packages_manifest) 214 args.packages_manifest)
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index d686fe07ec..e21655c979 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -104,7 +104,6 @@ class QemuTarget(BaseTarget):
104 self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin') 104 self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin')
105 self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) 105 self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime)
106 dump_target_cmds = d.getVar("testimage_dump_target") 106 dump_target_cmds = d.getVar("testimage_dump_target")
107 dump_host_cmds = d.getVar("testimage_dump_host")
108 dump_monitor_cmds = d.getVar("testimage_dump_monitor") 107 dump_monitor_cmds = d.getVar("testimage_dump_monitor")
109 dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") 108 dump_dir = d.getVar("TESTIMAGE_DUMP_DIR")
110 if not dump_dir: 109 if not dump_dir:
@@ -141,7 +140,6 @@ class QemuTarget(BaseTarget):
141 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")), 140 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")),
142 use_kvm = use_kvm, 141 use_kvm = use_kvm,
143 dump_dir = dump_dir, 142 dump_dir = dump_dir,
144 dump_host_cmds = dump_host_cmds,
145 logger = logger, 143 logger = logger,
146 tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"), 144 tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"),
147 serial_ports = len(d.getVar("SERIAL_CONSOLES").split())) 145 serial_ports = len(d.getVar("SERIAL_CONSOLES").split()))
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py
index d420b497f9..d4d271369f 100644
--- a/meta/lib/oeqa/utils/dump.py
+++ b/meta/lib/oeqa/utils/dump.py
@@ -51,9 +51,7 @@ class BaseDumper(object):
51 self.dump_dir = dump_dir 51 self.dump_dir = dump_dir
52 52
53 def _construct_filename(self, command): 53 def _construct_filename(self, command):
54 if isinstance(self, HostDumper): 54 if isinstance(self, TargetDumper):
55 prefix = "host"
56 elif isinstance(self, TargetDumper):
57 prefix = "target" 55 prefix = "target"
58 elif isinstance(self, MonitorDumper): 56 elif isinstance(self, MonitorDumper):
59 prefix = "qmp" 57 prefix = "qmp"
@@ -76,22 +74,6 @@ class BaseDumper(object):
76 with open(fullname, 'w') as dump_file: 74 with open(fullname, 'w') as dump_file:
77 dump_file.write(output) 75 dump_file.write(output)
78 76
79class HostDumper(BaseDumper):
80 """ Class to get dumps from the host running the tests """
81
82 def __init__(self, cmds, parent_dir):
83 super(HostDumper, self).__init__(cmds, parent_dir)
84
85 def dump_host(self, dump_dir=""):
86 if dump_dir:
87 self.dump_dir = dump_dir
88 env = os.environ.copy()
89 env['PATH'] = '/usr/sbin:/sbin:/usr/bin:/bin'
90 env['COLUMNS'] = '9999'
91 for cmd in self.cmds:
92 result = runCmd(cmd, ignore_status=True, env=env)
93 self._write_dump(cmd.split()[0], result.output)
94
95class TargetDumper(BaseDumper): 77class TargetDumper(BaseDumper):
96 """ Class to get dumps from target, it only works with QemuRunner. 78 """ Class to get dumps from target, it only works with QemuRunner.
97 Will give up permanently after 5 errors from running commands over 79 Will give up permanently after 5 errors from running commands over
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 49c70727a2..2ba0596ba1 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -21,7 +21,6 @@ import threading
21import codecs 21import codecs
22import logging 22import logging
23import tempfile 23import tempfile
24from oeqa.utils.dump import HostDumper
25from collections import defaultdict 24from collections import defaultdict
26import importlib 25import importlib
27 26
@@ -33,8 +32,8 @@ re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
33 32
34class QemuRunner: 33class QemuRunner:
35 34
36 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds, 35 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, use_kvm, logger, use_slirp=False,
37 use_kvm, logger, use_slirp=False, serial_ports=2, boot_patterns = defaultdict(str), use_ovmf=False, workdir=None, tmpfsdir=None): 36 serial_ports=2, boot_patterns = defaultdict(str), use_ovmf=False, workdir=None, tmpfsdir=None):
38 37
39 # Popen object for runqemu 38 # Popen object for runqemu
40 self.runqemu = None 39 self.runqemu = None
@@ -69,7 +68,6 @@ class QemuRunner:
69 if not workdir: 68 if not workdir:
70 workdir = os.getcwd() 69 workdir = os.getcwd()
71 self.qemu_pidfile = workdir + '/pidfile_' + str(os.getpid()) 70 self.qemu_pidfile = workdir + '/pidfile_' + str(os.getpid())
72 self.host_dumper = HostDumper(dump_host_cmds, dump_dir)
73 self.monitorpipe = None 71 self.monitorpipe = None
74 72
75 self.logger = logger 73 self.logger = logger
@@ -138,7 +136,6 @@ class QemuRunner:
138 self.logger.error('runqemu exited with code %d' % self.runqemu.returncode) 136 self.logger.error('runqemu exited with code %d' % self.runqemu.returncode)
139 self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout)) 137 self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout))
140 self.stop() 138 self.stop()
141 self._dump_host()
142 139
143 def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): 140 def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True):
144 env = os.environ.copy() 141 env = os.environ.copy()
@@ -286,7 +283,6 @@ class QemuRunner:
286 if self.runqemu.returncode: 283 if self.runqemu.returncode:
287 # No point waiting any longer 284 # No point waiting any longer
288 self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) 285 self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode)
289 self._dump_host()
290 self.logger.warning("Output from runqemu:\n%s" % self.getOutput(output)) 286 self.logger.warning("Output from runqemu:\n%s" % self.getOutput(output))
291 self.stop() 287 self.stop()
292 return False 288 return False
@@ -314,7 +310,6 @@ class QemuRunner:
314 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command '], stdout=subprocess.PIPE).communicate()[0] 310 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command '], stdout=subprocess.PIPE).communicate()[0]
315 processes = ps.decode("utf-8") 311 processes = ps.decode("utf-8")
316 self.logger.debug("Running processes:\n%s" % processes) 312 self.logger.debug("Running processes:\n%s" % processes)
317 self._dump_host()
318 op = self.getOutput(output) 313 op = self.getOutput(output)
319 self.stop() 314 self.stop()
320 if op: 315 if op:
@@ -430,7 +425,6 @@ class QemuRunner:
430 self.logger.error("Couldn't get ip from qemu command line and runqemu output! " 425 self.logger.error("Couldn't get ip from qemu command line and runqemu output! "
431 "Here is the qemu command line used:\n%s\n" 426 "Here is the qemu command line used:\n%s\n"
432 "and output from runqemu:\n%s" % (cmdline, out)) 427 "and output from runqemu:\n%s" % (cmdline, out))
433 self._dump_host()
434 self.stop() 428 self.stop()
435 return False 429 return False
436 430
@@ -508,7 +502,6 @@ class QemuRunner:
508 lines = tail(bootlog if bootlog else self.msg) 502 lines = tail(bootlog if bootlog else self.msg)
509 self.logger.warning("Last 25 lines of text (%d):\n%s" % (len(bootlog), lines)) 503 self.logger.warning("Last 25 lines of text (%d):\n%s" % (len(bootlog), lines))
510 self.logger.warning("Check full boot log: %s" % self.logfile) 504 self.logger.warning("Check full boot log: %s" % self.logfile)
511 self._dump_host()
512 self.stop() 505 self.stop()
513 return False 506 return False
514 507
@@ -689,13 +682,6 @@ class QemuRunner:
689 status = 1 682 status = 1
690 return (status, str(data)) 683 return (status, str(data))
691 684
692
693 def _dump_host(self):
694 self.host_dumper.create_dir("qemu")
695 self.logger.warning("Qemu ended unexpectedly, dump data from host"
696 " is in %s" % self.host_dumper.dump_dir)
697 self.host_dumper.dump_host()
698
699# This class is for reading data from a socket and passing it to logfunc 685# This class is for reading data from a socket and passing it to logfunc
700# to be processed. It's completely event driven and has a straightforward 686# to be processed. It's completely event driven and has a straightforward
701# event loop. The mechanism for stopping the thread is a simple pipe which 687# event loop. The mechanism for stopping the thread is a simple pipe which