mirror of
https://git.yoctoproject.org/poky
synced 2026-09-24 22:36:21 +02:00
resulttool: Add log subcommand
Adds a subcommand for dumping various logs from test results (From OE-Core rev: 454b8d2cdc6f79a51e610dae92c22352850c3f7c) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3326a902db
commit
e567c3761b
56
scripts/lib/resulttool/log.py
Normal file
56
scripts/lib/resulttool/log.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# resulttool - Show logs
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Garmin International
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms and conditions of the GNU General Public License,
|
||||||
|
# version 2, as published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
# more details.
|
||||||
|
#
|
||||||
|
import resulttool.resultutils as resultutils
|
||||||
|
|
||||||
|
def show_ptest(result, ptest, logger):
|
||||||
|
if 'ptestresult.sections' in result:
|
||||||
|
if ptest in result['ptestresult.sections'] and 'log' in result['ptestresult.sections'][ptest]:
|
||||||
|
print(result['ptestresult.sections'][ptest]['log'])
|
||||||
|
return 0
|
||||||
|
|
||||||
|
print("ptest '%s' not found" % ptest)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def log(args, logger):
|
||||||
|
results = resultutils.load_resultsdata(args.source)
|
||||||
|
for path in results:
|
||||||
|
for res in results[path]:
|
||||||
|
if 'result' not in results[path][res]:
|
||||||
|
continue
|
||||||
|
r = results[path][res]['result']
|
||||||
|
|
||||||
|
if args.raw:
|
||||||
|
if 'ptestresult.rawlogs' in r:
|
||||||
|
print(r['ptestresult.rawlogs']['log'])
|
||||||
|
else:
|
||||||
|
print('Raw logs not found')
|
||||||
|
return 1
|
||||||
|
|
||||||
|
for ptest in args.ptest:
|
||||||
|
if not show_ptest(r, ptest, logger):
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def register_commands(subparsers):
|
||||||
|
"""Register subcommands from this plugin"""
|
||||||
|
parser = subparsers.add_parser('log', help='show logs',
|
||||||
|
description='show the logs from test results',
|
||||||
|
group='analysis')
|
||||||
|
parser.set_defaults(func=log)
|
||||||
|
parser.add_argument('source',
|
||||||
|
help='the results file/directory/URL to import')
|
||||||
|
parser.add_argument('--ptest', action='append', default=[],
|
||||||
|
help='show logs for a ptest')
|
||||||
|
parser.add_argument('--raw', action='store_true',
|
||||||
|
help='show raw logs')
|
||||||
|
|
||||||
@@ -49,6 +49,7 @@ import resulttool.store
|
|||||||
import resulttool.regression
|
import resulttool.regression
|
||||||
import resulttool.report
|
import resulttool.report
|
||||||
import resulttool.manualexecution
|
import resulttool.manualexecution
|
||||||
|
import resulttool.log
|
||||||
logger = scriptutils.logger_create('resulttool')
|
logger = scriptutils.logger_create('resulttool')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -66,6 +67,7 @@ def main():
|
|||||||
subparsers.add_subparser_group('analysis', 'analysis', 100)
|
subparsers.add_subparser_group('analysis', 'analysis', 100)
|
||||||
resulttool.regression.register_commands(subparsers)
|
resulttool.regression.register_commands(subparsers)
|
||||||
resulttool.report.register_commands(subparsers)
|
resulttool.report.register_commands(subparsers)
|
||||||
|
resulttool.log.register_commands(subparsers)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.debug:
|
if args.debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user