summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-08-24 19:04:02 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-30 12:36:12 +0100
commit85fd1a7a121daffc3c5c530930f832ecc61ef83d (patch)
treeee70ad65c0392775d8a4da174bd992e8e760c2e9 /meta/lib/oeqa/oetest.py
parentd14ffaf6a366442bcf88e44ee3e105f9dea1e69c (diff)
downloadpoky-85fd1a7a121daffc3c5c530930f832ecc61ef83d.tar.gz
dump: Created new classes for dump host and target
It makes sense to separate the dump commands from the oeRuntimeTest class, this way it can be used in all the test context. These are the changes included in this patch: - Created classes: BaseDumper, HostDumper, TargetDumper - Create an instance of HostDumper in imagetest.bbclass and add it to TestContext class, this way any class that have access to the TestContext would be able to dump logs from the host - Create an instance of TargetDumper in QemuTarget class after get the runner, this way it is accessible during the tests. [YOCTO #8118] (From OE-Core rev: ad10af6be343b5425fde43055263b0744c161cb3) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/oetest.py')
-rw-r--r--meta/lib/oeqa/oetest.py52
1 files changed, 6 insertions, 46 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index fbf6c56376..9cb8a53795 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -11,8 +11,6 @@ import os, re, mmap
11import unittest 11import unittest
12import inspect 12import inspect
13import subprocess 13import subprocess
14import datetime
15import commands
16import bb 14import bb
17from oeqa.utils.decorators import LogResults 15from oeqa.utils.decorators import LogResults
18from sys import exc_info, exc_clear 16from sys import exc_info, exc_clear
@@ -124,51 +122,13 @@ class oeRuntimeTest(oeTest):
124 # If a test fails or there is an exception 122 # If a test fails or there is an exception
125 if not exc_info() == (None, None, None): 123 if not exc_info() == (None, None, None):
126 exc_clear() 124 exc_clear()
127 dump_dir = self.create_dump_dir() 125 self.tc.host_dumper.create_dir(self._testMethodName)
126 self.target.target_dumper.dump_target(
127 self.tc.host_dumper.dump_dir)
128 self.tc.host_dumper.dump_host()
128 print ("%s dump data from host and target " 129 print ("%s dump data from host and target "
129 "stored in %s" % (self._testMethodName, dump_dir)) 130 "stored in %s" % (self._testMethodName,
130 self.dump_host_logs(dump_dir) 131 self.target.target_dumper.dump_dir))
131 self.dump_target_logs(dump_dir)
132
133 def create_dump_dir(self):
134 dump_sub_dir = ("%s_%s" % (
135 datetime.datetime.now().strftime('%Y%m%d%H%M'),
136 self._testMethodName))
137 dump_dir = os.path.join(self.target.dump_dir, dump_sub_dir)
138 os.makedirs(dump_dir)
139 return dump_dir
140
141 def dump_host_logs(self, dump_dir):
142 for cmd in self.target.dump_host.split('\n'):
143 cmd = cmd.lstrip()
144 if not cmd:
145 continue
146 output = commands.getoutput(cmd)
147 filename = "host_%s" % cmd.split()[0]
148 with open(os.path.join(dump_dir, filename), 'w') as f:
149 f.write(output)
150
151 def dump_target_logs(self, dump_dir):
152 for cmd in self.target.dump_target.split('\n'):
153 cmd = cmd.lstrip()
154 if not cmd:
155 continue
156 # This will ping the host from target
157 if cmd == "_ping":
158 comm = "ping -c3 %s" % self.target.server_ip
159 # This will get all the logs from /var/log/
160 elif cmd == "_logs":
161 comm = 'find /var/log/ -type f 2>/dev/null '
162 comm = '%s-exec echo "%s" \\; ' % (comm, '='*20)
163 comm = '%s-exec echo {} \\; ' % comm
164 comm = '%s-exec echo "%s" \\; ' % (comm, '='*20)
165 comm = '%s-exec cat {} \\; -exec echo "" \\;' % comm
166 else:
167 comm = cmd
168 (status, output) = self.target.run_serial(comm)
169 filename = "target_%s" % cmd.split()[0]
170 with open(os.path.join(dump_dir, filename), 'w') as f:
171 f.write(output)
172 132
173 #TODO: use package_manager.py to install packages on any type of image 133 #TODO: use package_manager.py to install packages on any type of image
174 def install_packages(self, packagelist): 134 def install_packages(self, packagelist):