summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorLucian Musat <george.l.musat@intel.com>2015-06-10 18:32:50 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-11 23:59:18 +0100
commitee663961bb3e22a50580e53b527dab0a72d427a7 (patch)
tree49732f50e547004b6c4fb018ed264758b541cd5a /meta/lib/oeqa
parentf355baa21aa991b3d25ef1838da25c39e41d0513 (diff)
downloadpoky-ee663961bb3e22a50580e53b527dab0a72d427a7.tar.gz
oeqa/parselogs: The logs are now copied and parsed locally.
This is to fix a problem with reaching the limit of the whitelist size. (From OE-Core rev: 7f49f098cff1848ab7bd25a6a232b09b4f0b4b03) Signed-off-by: Lucian Musat <george.l.musat@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')
-rw-r--r--meta/lib/oeqa/runtime/parselogs.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py
index e9ccd0c0b9..e6413666f1 100644
--- a/meta/lib/oeqa/runtime/parselogs.py
+++ b/meta/lib/oeqa/runtime/parselogs.py
@@ -1,5 +1,6 @@
1import os 1import os
2import unittest 2import unittest
3import subprocess
3from oeqa.oetest import oeRuntimeTest 4from oeqa.oetest import oeRuntimeTest
4from oeqa.utils.decorators import * 5from oeqa.utils.decorators import *
5 6
@@ -132,6 +133,20 @@ class ParseLogsTest(oeRuntimeTest):
132 logs.append(os.path.join(location,str(logfile))) 133 logs.append(os.path.join(location,str(logfile)))
133 return logs 134 return logs
134 135
136 #copy the log files to be parsed locally
137 def transfer_logs(self, log_list):
138 target_logs = 'target_logs'
139 if not os.path.exists(target_logs):
140 os.makedirs(target_logs)
141 for f in log_list:
142 self.target.copy_from(f, target_logs)
143
144 #get the local list of logs
145 def get_local_log_list(self, log_locations):
146 self.transfer_logs(self.getLogList(log_locations))
147 logs = [ os.path.join('target_logs',f) for f in os.listdir('target_logs') if os.path.isfile(os.path.join('target_logs',f)) ]
148 return logs
149
135 #build the grep command to be used with filters and exclusions 150 #build the grep command to be used with filters and exclusions
136 def build_grepcmd(self, errors, ignore_errors, log): 151 def build_grepcmd(self, errors, ignore_errors, log):
137 grepcmd = "grep " 152 grepcmd = "grep "
@@ -163,21 +178,22 @@ class ParseLogsTest(oeRuntimeTest):
163 results = {} 178 results = {}
164 rez = [] 179 rez = []
165 for log in logs: 180 for log in logs:
181 result = None
166 thegrep = self.build_grepcmd(errors, ignore_errors, log) 182 thegrep = self.build_grepcmd(errors, ignore_errors, log)
167 try: 183 try:
168 (status, result) = self.target.run(thegrep) 184 result = subprocess.check_output(thegrep, shell=True)
169 except: 185 except:
170 pass 186 pass
171 if result: 187 if (result is not None):
172 results[log] = {} 188 results[log.replace('target_logs/','')] = {}
173 rez = result.splitlines() 189 rez = result.splitlines()
174 for xrez in rez: 190 for xrez in rez:
175 command = "grep \"\\"+str(xrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log) 191 command = "grep \"\\"+str(xrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log)
176 try: 192 try:
177 (status, yrez) = self.target.run(command) 193 yrez = subprocess.check_output(command, shell=True)
178 except: 194 except:
179 pass 195 pass
180 results[log][xrez]=yrez 196 results[log.replace('target_logs/','')][xrez]=yrez
181 return results 197 return results
182 198
183 #get the output of dmesg and write it in a file. This file is added to log_locations. 199 #get the output of dmesg and write it in a file. This file is added to log_locations.
@@ -189,7 +205,7 @@ class ParseLogsTest(oeRuntimeTest):
189 @skipUnlessPassed('test_ssh') 205 @skipUnlessPassed('test_ssh')
190 def test_parselogs(self): 206 def test_parselogs(self):
191 self.write_dmesg() 207 self.write_dmesg()
192 log_list = self.getLogList(self.log_locations) 208 log_list = self.get_local_log_list(self.log_locations)
193 result = self.parse_logs(self.errors, self.ignore_errors, log_list) 209 result = self.parse_logs(self.errors, self.ignore_errors, log_list)
194 print self.getHardwareInfo() 210 print self.getHardwareInfo()
195 errcount = 0 211 errcount = 0
@@ -203,4 +219,4 @@ class ParseLogsTest(oeRuntimeTest):
203 self.msg += result[str(log)][str(error)]+"\n" 219 self.msg += result[str(log)][str(error)]+"\n"
204 self.msg += "***********************\n" 220 self.msg += "***********************\n"
205 self.msg += "%s errors found in logs." % errcount 221 self.msg += "%s errors found in logs." % errcount
206 self.assertEqual(errcount, 0, msg=self.msg) 222 self.assertEqual(errcount, 0, msg=self.msg) \ No newline at end of file