diff options
-rw-r--r-- | meta/lib/oeqa/runtime/parselogs.py | 30 |
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 @@ | |||
1 | import os | 1 | import os |
2 | import unittest | 2 | import unittest |
3 | import subprocess | ||
3 | from oeqa.oetest import oeRuntimeTest | 4 | from oeqa.oetest import oeRuntimeTest |
4 | from oeqa.utils.decorators import * | 5 | from 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 |