summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
diff options
context:
space:
mode:
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):