mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
oeqa/runtime/parselogs: don't pass around members
There's no point in passing around member fields, just access them directly. (From OE-Core rev: a24d6eda061363cdcfa95980cd2698a674737d23) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
c7957aeeb5
commit
50c637e6dc
@@ -263,19 +263,19 @@ class ParseLogsTest(OERuntimeTestCase):
|
|||||||
return logs
|
return logs
|
||||||
|
|
||||||
# Build the grep command to be used with filters and exclusions
|
# Build the grep command to be used with filters and exclusions
|
||||||
def build_grepcmd(self, errors, ignore_errors, log):
|
def build_grepcmd(self, log):
|
||||||
grepcmd = 'grep '
|
grepcmd = 'grep '
|
||||||
grepcmd += '-Ei "'
|
grepcmd += '-Ei "'
|
||||||
for error in errors:
|
for error in self.errors:
|
||||||
grepcmd += r'\<' + error + r'\>' + '|'
|
grepcmd += r'\<' + error + r'\>' + '|'
|
||||||
grepcmd = grepcmd[:-1]
|
grepcmd = grepcmd[:-1]
|
||||||
grepcmd += '" ' + str(log) + " | grep -Eiv \'"
|
grepcmd += '" ' + str(log) + " | grep -Eiv \'"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
errorlist = ignore_errors[self.td.get('MACHINE')]
|
errorlist = self.ignore_errors[self.td.get('MACHINE')]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.msg += 'No ignore list found for this machine, using default\n'
|
self.msg += 'No ignore list found for this machine, using default\n'
|
||||||
errorlist = ignore_errors['default']
|
errorlist = self.ignore_errors['default']
|
||||||
|
|
||||||
for ignore_error in errorlist:
|
for ignore_error in errorlist:
|
||||||
ignore_error = ignore_error.replace('(', r'\(')
|
ignore_error = ignore_error.replace('(', r'\(')
|
||||||
@@ -292,17 +292,21 @@ class ParseLogsTest(OERuntimeTestCase):
|
|||||||
|
|
||||||
return grepcmd
|
return grepcmd
|
||||||
|
|
||||||
# Grep only the errors so that their context could be collected.
|
def parse_logs(self, logs, lines_before=10, lines_after=10):
|
||||||
# Default context is 10 lines before and after the error itself
|
"""
|
||||||
def parse_logs(self, errors, ignore_errors, logs,
|
Search the log files @logs looking for error lines (marked by
|
||||||
lines_before = 10, lines_after = 10):
|
@self.errors), ignoring anything listed in @self.ignore_errors.
|
||||||
|
|
||||||
|
Returns a dictionary of log filenames to a dictionary of error lines to
|
||||||
|
the error context (controlled by @lines_before and @lines_after).
|
||||||
|
"""
|
||||||
results = {}
|
results = {}
|
||||||
rez = []
|
rez = []
|
||||||
grep_output = ''
|
grep_output = ''
|
||||||
|
|
||||||
for log in logs:
|
for log in logs:
|
||||||
result = None
|
result = None
|
||||||
thegrep = self.build_grepcmd(errors, ignore_errors, log)
|
thegrep = self.build_grepcmd(log)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = check_output(thegrep, shell=True).decode('utf-8')
|
result = check_output(thegrep, shell=True).decode('utf-8')
|
||||||
@@ -333,7 +337,7 @@ class ParseLogsTest(OERuntimeTestCase):
|
|||||||
def test_parselogs(self):
|
def test_parselogs(self):
|
||||||
self.write_dmesg()
|
self.write_dmesg()
|
||||||
log_list = self.get_local_log_list(self.log_locations)
|
log_list = self.get_local_log_list(self.log_locations)
|
||||||
result = self.parse_logs(self.errors, self.ignore_errors, log_list)
|
result = self.parse_logs(log_list)
|
||||||
errcount = 0
|
errcount = 0
|
||||||
for log in result:
|
for log in result:
|
||||||
self.msg += 'Log: ' + log + '\n'
|
self.msg += 'Log: ' + log + '\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user