Skip to contentSkip to conversation

openssl: Fix ptest test output translation

PATCH New Richard Purdie 1 participant 5 messages Feb 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 openssl: Fix ptest test output translation

openssl-ptest was recording now results, despite most tests passing. Fix so that the successes/skips/failures are reported correctly.

---
 meta/recipes-connectivity/openssl/openssl/run-ptest | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-connectivity/openssl/openssl/run-ptest +1 -1
index 0a620dea74a..3fb22471f8c 100644
@@ -9,4 +9,4 @@ export TOP=.
 # OPENSSL_ENGINES is relative from the test binaries
 export OPENSSL_ENGINES=../engines
 
-perl ./test/run_tests.pl $*
+perl ./test/run_tests.pl $* | perl -0pe 's#(.*) \.*.ok#PASS: \1#g; s#(.*) \.*.skipped: (.*)#SKIP: \1 (\2)#g; s#(.*) \.*.\nDubious#FAIL: \1#;'
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/5 resulttool/store: Handle results files for multiple revisions

Currently we cant store results if the results files span multiple different build revisons. Remove this limitation by iterating.

---
 scripts/lib/resulttool/store.py | 39 +++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 16 deletions(-)
scripts/lib/resulttool/store.py +23 -16
index 6744fb3c05d..43e57b913c6 100644
@@ -29,7 +29,7 @@ def store(args, logger):
     try:
         results = {}
         logger.info('Reading files from %s' % args.source)
-        for root, dirs, files in os.walk(args.source):
+        for root, dirs,  files in os.walk(args.source):
             for name in files:
                 f = os.path.join(root, name)
                 if name == "testresults.json":
@@ -38,7 +38,8 @@ def store(args, logger):
                     dst = f.replace(args.source, tempdir + "/")
                     os.makedirs(os.path.dirname(dst), exist_ok=True)
                     shutil.copyfile(f, dst)
-        resultutils.save_resultsdata(results, tempdir)
+
+        revisions = {}
 
         if not results and not args.all:
             if args.allow_empty:
@@ -47,26 +48,32 @@ def store(args, logger):
             logger.error("No results found to store")
             return 1
 
-        keywords = {'branch': None, 'commit': None, 'commit_count': None}
-
         # Find the branch/commit/commit_count and ensure they all match
         for suite in results:
             for result in results[suite]:
                 config = results[suite][result]['configuration']['LAYERS']['meta']
-                for k in keywords:
-                    if keywords[k] is None:
-                        keywords[k] = config.get(k)
-                    if config.get(k) != keywords[k]:
-                        logger.error("Mismatched source commit/branch/count: %s vs %s" % (config.get(k), keywords[k]))
-                        return 1
+                revision = (config['commit'], config['branch'], str(config['commit_count']))
+                if revision not in revisions:
+                    revisions[revision] = {}
+                if suite not in revisions[revision]:
+                    revisions[revision][suite] = {}
+                revisions[revision][suite] = results[suite][result]
+
+        logger.info("Found %d revisions to store" % len(revisions))
+
+        for r in revisions:
+            results = revisions[r]
+            keywords = {'commit': r[0], 'branch': r[1], "commit_count": r[2]}
+            subprocess.check_call(["find", tempdir, "!", "-path", "./.git/*", "-delete"])
+            resultutils.save_resultsdata(results, tempdir)
 
-        logger.info('Storing test result into git repository %s' % args.git_dir)
+            logger.info('Storing test result into git repository %s' % args.git_dir)
 
-        gitarchive.gitarchive(tempdir, args.git_dir, False, False,
-                              "Results of {branch}:{commit}", "branch: {branch}\ncommit: {commit}", "{branch}",
-                              False, "{branch}/{commit_count}-g{commit}/{tag_number}",
-                              'Test run #{tag_number} of {branch}:{commit}', '',
-                              [], [], False, keywords, logger)
+            gitarchive.gitarchive(tempdir, args.git_dir, False, False,
+                                  "Results of {branch}:{commit}", "branch: {branch}\ncommit: {commit}", "{branch}",
+                                  False, "{branch}/{commit_count}-g{commit}/{tag_number}",
+                                  'Test run #{tag_number} of {branch}:{commit}', '',
+                                  [], [], False, keywords, logger)
 
     finally:
         subprocess.check_call(["rm", "-rf",  tempdir])
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/5 resulttool/report: Handle missing metadata sections more cleanly

In reply to Richard Purdie

Currently some older results files cause the code to give tracebacks. Handle these missing sections more cleanly.

---
 scripts/lib/resulttool/report.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/lib/resulttool/report.py +6 -3
index 2f5ea308e21..5ffe262f89b 100644
@@ -31,9 +31,12 @@ class ResultsTextReport(object):
     def handle_ptest_result(self, k, status, result):
         if k == 'ptestresult.sections':
             return
-        _, suite, test = k.split(".", 2)
+        try:
+            _, suite, test = k.split(".", 2)
+        except ValueError:
+            return
         # Handle 'glib-2.0'
-        if suite not in result['ptestresult.sections']:
+        if 'ptestresult.sections' in result and suite not in result['ptestresult.sections']:
             try:
                 _, suite, suite1, test = k.split(".", 3)
                 if suite + "." + suite1 in result['ptestresult.sections']:
@@ -45,7 +48,7 @@ class ResultsTextReport(object):
         for tk in self.result_types:
             if status in self.result_types[tk]:
                 self.ptests[suite][tk] += 1
-        if suite in result['ptestresult.sections']:
+        if 'ptestresult.sections' in result and suite in result['ptestresult.sections']:
             if 'duration' in result['ptestresult.sections'][suite]:
                 self.ptests[suite]['duration'] = result['ptestresult.sections'][suite]['duration']
             if 'timeout' in result['ptestresult.sections'][suite]:
Signature · 1 line
2.20.1
#3 lore raw

PATCH 4/5 resulttool/report: Ensure test suites with no results show up on the report

In reply to Richard Purdie

ptest suites with no results don't show up on the reports even though we have a duration for them. Fix this so the fact they report no tests is visible.

---
 scripts/lib/resulttool/report.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
scripts/lib/resulttool/report.py +8 -5
index 5ffe262f89b..ff1b32c7706 100644
@@ -30,6 +30,14 @@ class ResultsTextReport(object):
 
     def handle_ptest_result(self, k, status, result):
         if k == 'ptestresult.sections':
+            # Ensure tests without any test results still show up on the report
+            for suite in result['ptestresult.sections']:
+                if suite not in self.ptests:
+                    self.ptests[suite] = {'passed': 0, 'failed': 0, 'skipped': 0, 'duration' : '-', 'failed_testcases': []}
+                if 'duration' in result['ptestresult.sections'][suite]:
+                    self.ptests[suite]['duration'] = result['ptestresult.sections'][suite]['duration']
+                if 'timeout' in result['ptestresult.sections'][suite]:
+                    self.ptests[suite]['duration'] += " T"
             return
         try:
             _, suite, test = k.split(".", 2)
@@ -48,11 +56,6 @@ class ResultsTextReport(object):
         for tk in self.result_types:
             if status in self.result_types[tk]:
                 self.ptests[suite][tk] += 1
-        if 'ptestresult.sections' in result and suite in result['ptestresult.sections']:
-            if 'duration' in result['ptestresult.sections'][suite]:
-                self.ptests[suite]['duration'] = result['ptestresult.sections'][suite]['duration']
-            if 'timeout' in result['ptestresult.sections'][suite]:
-                self.ptests[suite]['duration'] += " T"
 
     def get_aggregated_test_result(self, logger, testresult):
         test_count_report = {'passed': 0, 'failed': 0, 'skipped': 0, 'failed_testcases': []}
Signature · 1 line
2.20.1
#4 lore raw

PATCH 5/5 resulttool/report: Ensure ptest results are sorted

In reply to Richard Purdie
---
 scripts/lib/resulttool/template/test_report_full_text.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/resulttool/template/test_report_full_text.txt +1 -1
index 5081594cf27..590f35c7dd8 100644
@@ -16,7 +16,7 @@ PTest Result Summary
 --------------------------------------------------------------------------------------------------------------
 {{ 'Recipe'.ljust(maxlen['ptest']) }} | {{ 'Passed'.ljust(maxlen['passed']) }} | {{ 'Failed'.ljust(maxlen['failed']) }} | {{ 'Skipped'.ljust(maxlen['skipped']) }} | {{ 'Time(s)'.ljust(10) }}
 --------------------------------------------------------------------------------------------------------------
-{% for ptest in ptests %}
+{% for ptest in ptests |sort %}
 {{ ptest.ljust(maxlen['ptest']) }} | {{ (ptests[ptest]['passed']|string).ljust(maxlen['passed']) }} | {{ (ptests[ptest]['failed']|string).ljust(maxlen['failed']) }} | {{ (ptests[ptest]['skipped']|string).ljust(maxlen['skipped']) }} | {{ (ptests[ptest]['duration']|string) }}
 {% endfor %}
 --------------------------------------------------------------------------------------------------------------
Signature · 1 line
2.20.1