summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-08-12 13:48:09 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-16 09:25:00 +0100
commit857da0884a645517e69407a8eafd0c33111ab8a3 (patch)
treedaed5d7c240d2b4869082766edccc5284aebcd34 /meta
parent9c72c1a5aa0b49d3895bbefee7a264adfcc6f4ca (diff)
downloadpoky-857da0884a645517e69407a8eafd0c33111ab8a3.tar.gz
oetest.py: Don't wait to write dump files
This allows to write the dump files immediately after get the data from the target. Before this, it would run all the commands and write the files. The old behavior could cause no log written at all if the serial console gets stuck. (From OE-Core rev: 73c98d38e94d3b1407620c134f3b00dcd9d6132c) 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')
-rw-r--r--meta/lib/oeqa/oetest.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index a3f297acf6..dfed3dea87 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -122,21 +122,18 @@ class oeRuntimeTest(oeTest):
122 # If a test fails or there is an exception 122 # If a test fails or there is an exception
123 if (self._resultForDoCleanups.failures or 123 if (self._resultForDoCleanups.failures or
124 self._resultForDoCleanups.errors): 124 self._resultForDoCleanups.errors):
125 commands = ["top -bn1", "ps", "free", "df", "_ping", "dmesg", "netstat -a", "ifconfig -a", "_logs"] 125 self.dump_target_logs()
126 dump_dir = "/tmp/oe-saved-tests" 126
127 dump_dir = os.path.join(dump_dir, 127 def dump_target_logs(self):
128 datetime.datetime.now().strftime('%Y%m%d%H%M')) 128 commands = ["top -bn1", "ps", "free", "df", "_ping", "dmesg", "netstat -a", "ifconfig -a", "_logs"]
129 os.makedirs(dump_dir) 129 dump_dir = "/tmp/oe-saved-tests"
130 bb.warn("Test failed, getting data from target " 130 dump_sub_dir = ("%s_%s" % (
131 "and saving it in %s" % dump_dir) 131 datetime.datetime.now().strftime('%Y%m%d%H%M'),
132 output = self.run_bulk_commands(commands) 132 self._testMethodName))
133 for key,msg in output.iteritems(): 133 dump_dir = os.path.join(dump_dir, dump_sub_dir)
134 filename = key.split()[0] 134 os.makedirs(dump_dir)
135 with open(os.path.join(dump_dir, filename), 'w') as f: 135 bb.warn("%s failed: getting data from target and "
136 f.write(msg) 136 "saving into %s" % (self._testMethodName, dump_dir))
137
138 def run_bulk_commands(self, commands):
139 all_output = {}
140 for command in commands: 137 for command in commands:
141 # This will ping the host from target 138 # This will ping the host from target
142 if command == "_ping": 139 if command == "_ping":
@@ -151,8 +148,9 @@ class oeRuntimeTest(oeTest):
151 else: 148 else:
152 comm = command 149 comm = command
153 (status, output) = self.target.run_serial(comm) 150 (status, output) = self.target.run_serial(comm)
154 all_output[command] = output 151 filename = command.split()[0]
155 return all_output 152 with open(os.path.join(dump_dir, filename), 'w') as f:
153 f.write(output)
156 154
157 #TODO: use package_manager.py to install packages on any type of image 155 #TODO: use package_manager.py to install packages on any type of image
158 def install_packages(self, packagelist): 156 def install_packages(self, packagelist):