From ee663961bb3e22a50580e53b527dab0a72d427a7 Mon Sep 17 00:00:00 2001 From: Lucian Musat Date: Wed, 10 Jun 2015 18:32:50 +0300 Subject: 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 Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- meta/lib/oeqa/runtime/parselogs.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'meta/lib/oeqa') 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 @@ import os import unittest +import subprocess from oeqa.oetest import oeRuntimeTest from oeqa.utils.decorators import * @@ -132,6 +133,20 @@ class ParseLogsTest(oeRuntimeTest): logs.append(os.path.join(location,str(logfile))) return logs + #copy the log files to be parsed locally + def transfer_logs(self, log_list): + target_logs = 'target_logs' + if not os.path.exists(target_logs): + os.makedirs(target_logs) + for f in log_list: + self.target.copy_from(f, target_logs) + + #get the local list of logs + def get_local_log_list(self, log_locations): + self.transfer_logs(self.getLogList(log_locations)) + logs = [ os.path.join('target_logs',f) for f in os.listdir('target_logs') if os.path.isfile(os.path.join('target_logs',f)) ] + return logs + #build the grep command to be used with filters and exclusions def build_grepcmd(self, errors, ignore_errors, log): grepcmd = "grep " @@ -163,21 +178,22 @@ class ParseLogsTest(oeRuntimeTest): results = {} rez = [] for log in logs: + result = None thegrep = self.build_grepcmd(errors, ignore_errors, log) try: - (status, result) = self.target.run(thegrep) + result = subprocess.check_output(thegrep, shell=True) except: pass - if result: - results[log] = {} + if (result is not None): + results[log.replace('target_logs/','')] = {} rez = result.splitlines() for xrez in rez: command = "grep \"\\"+str(xrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log) try: - (status, yrez) = self.target.run(command) + yrez = subprocess.check_output(command, shell=True) except: pass - results[log][xrez]=yrez + results[log.replace('target_logs/','')][xrez]=yrez return results #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): @skipUnlessPassed('test_ssh') def test_parselogs(self): self.write_dmesg() - log_list = self.getLogList(self.log_locations) + log_list = self.get_local_log_list(self.log_locations) result = self.parse_logs(self.errors, self.ignore_errors, log_list) print self.getHardwareInfo() errcount = 0 @@ -203,4 +219,4 @@ class ParseLogsTest(oeRuntimeTest): self.msg += result[str(log)][str(error)]+"\n" self.msg += "***********************\n" self.msg += "%s errors found in logs." % errcount - self.assertEqual(errcount, 0, msg=self.msg) + self.assertEqual(errcount, 0, msg=self.msg) \ No newline at end of file -- cgit v1.2.3-54-g00ecf