summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-08-12 10:58:53 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-16 09:25:00 +0100
commit9c72c1a5aa0b49d3895bbefee7a264adfcc6f4ca (patch)
treea26d2eb25afccb23d1951b927a08630911d83b86 /meta/lib/oeqa/oetest.py
parent51d8e8fb370ae5eb9ebaff722c181a693a7f4ca1 (diff)
downloadpoky-9c72c1a5aa0b49d3895bbefee7a264adfcc6f4ca.tar.gz
oetest.py: Added method tearDown for oeRuntimeTest
The tearDown method is triggered when a tests ends it doesn't matter if fails or succeeds. Inside this method added an evalution to check if fails and then run some commands in the target to get the data for later debugging. [YOCTO #8118] (From OE-Core rev: 8bbfef69828d9b053e2a33dfa9d8318d9572cf6b) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@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.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 22d76b35e1..a3f297acf6 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -11,6 +11,7 @@ import os, re, mmap
11import unittest 11import unittest
12import inspect 12import inspect
13import subprocess 13import subprocess
14import datetime
14import bb 15import bb
15from oeqa.utils.decorators import LogResults 16from oeqa.utils.decorators import LogResults
16 17
@@ -117,6 +118,42 @@ class oeRuntimeTest(oeTest):
117 self.target = oeRuntimeTest.tc.target 118 self.target = oeRuntimeTest.tc.target
118 super(oeRuntimeTest, self).__init__(methodName) 119 super(oeRuntimeTest, self).__init__(methodName)
119 120
121 def tearDown(self):
122 # If a test fails or there is an exception
123 if (self._resultForDoCleanups.failures or
124 self._resultForDoCleanups.errors):
125 commands = ["top -bn1", "ps", "free", "df", "_ping", "dmesg", "netstat -a", "ifconfig -a", "_logs"]
126 dump_dir = "/tmp/oe-saved-tests"
127 dump_dir = os.path.join(dump_dir,
128 datetime.datetime.now().strftime('%Y%m%d%H%M'))
129 os.makedirs(dump_dir)
130 bb.warn("Test failed, getting data from target "
131 "and saving it in %s" % dump_dir)
132 output = self.run_bulk_commands(commands)
133 for key,msg in output.iteritems():
134 filename = key.split()[0]
135 with open(os.path.join(dump_dir, filename), 'w') as f:
136 f.write(msg)
137
138 def run_bulk_commands(self, commands):
139 all_output = {}
140 for command in commands:
141 # This will ping the host from target
142 if command == "_ping":
143 comm = "ping -c3 %s" % self.target.server_ip
144 # This will get all the logs from /var/log/
145 elif command == "_logs":
146 comm = 'find /var/log/ -type f 2>/dev/null '
147 comm = '%s-exec echo "%s" \\; ' % (comm, '='*20)
148 comm = '%s-exec echo {} \\; ' % comm
149 comm = '%s-exec echo "%s" \\; ' % (comm, '='*20)
150 comm = '%s-exec cat {} \\; -exec echo "" \\;' % comm
151 else:
152 comm = command
153 (status, output) = self.target.run_serial(comm)
154 all_output[command] = output
155 return all_output
156
120 #TODO: use package_manager.py to install packages on any type of image 157 #TODO: use package_manager.py to install packages on any type of image
121 def install_packages(self, packagelist): 158 def install_packages(self, packagelist):
122 for package in packagelist: 159 for package in packagelist: