Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 2/2] resulttool: Add log subcommand
Date: Thu, 18 Apr 2019 21:57:18 -0500	[thread overview]
Message-ID: <20190419025718.15348-3-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20190419025718.15348-1-JPEWhacker@gmail.com>

Adds a subcommand for dumping various logs from test results

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 scripts/lib/resulttool/log.py        | 56 ++++++++++++++++++++++++++++
 scripts/lib/resulttool/regression.py |  2 +-
 scripts/resulttool                   |  2 +
 3 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 scripts/lib/resulttool/log.py

diff --git a/scripts/lib/resulttool/log.py b/scripts/lib/resulttool/log.py
new file mode 100644
index 00000000000..5584f2d0a99
--- /dev/null
+++ b/scripts/lib/resulttool/log.py
@@ -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')
+
diff --git a/scripts/lib/resulttool/regression.py b/scripts/lib/resulttool/regression.py
index aecb9da9ce5..fa90ab1e522 100644
--- a/scripts/lib/resulttool/regression.py
+++ b/scripts/lib/resulttool/regression.py
@@ -64,7 +64,7 @@ def regression_common(args, logger, base_results, target_results):
         if a in target_results:
             base = list(base_results[a].keys())
             target = list(target_results[a].keys())
-            # We may have multiple base/targets which are for different configurations. Start by 
+            # We may have multiple base/targets which are for different configurations. Start by
             # removing any pairs which match
             for c in base.copy():
                 for b in target.copy():
diff --git a/scripts/resulttool b/scripts/resulttool
index 18ac1019236..9477667a870 100755
--- a/scripts/resulttool
+++ b/scripts/resulttool
@@ -49,6 +49,7 @@ import resulttool.store
 import resulttool.regression
 import resulttool.report
 import resulttool.manualexecution
+import resulttool.log
 logger = scriptutils.logger_create('resulttool')
 
 def main():
@@ -66,6 +67,7 @@ def main():
     subparsers.add_subparser_group('analysis', 'analysis', 100)
     resulttool.regression.register_commands(subparsers)
     resulttool.report.register_commands(subparsers)
+    resulttool.log.register_commands(subparsers)
 
     args = parser.parse_args()
     if args.debug:
-- 
2.20.1



  parent reply	other threads:[~2019-04-19  2:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19  2:57 [PATCH 0/2] resulttool improvements Joshua Watt
2019-04-19  2:57 ` [PATCH 1/2] resulttool: Load results from URL Joshua Watt
2019-04-19  2:57 ` Joshua Watt [this message]
2019-04-19  5:05   ` [PATCH 2/2] resulttool: Add log subcommand akuster808
2019-04-19 13:14     ` Joshua Watt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190419025718.15348-3-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox