[Piglit] [PATCH] Add user-specified test name suffix to junit output.

Mark Janes mark.a.janes at intel.com
Tue Sep 16 13:27:55 PDT 2014


When summarizing piglit results from a set of hardware, it is
necessary to differentiate failures from the various platforms.  Tools
like jenkins are confused when a test name is repeated in test
results, especially when it both passes and fails in separate result
files.

Provide the --junit_suffix parameter to piglit to append a string to
the name of each test in the junit output.  Multiple invocations of
piglit can be summarized together in jenkins with different suffixes.
---
 framework/programs/run.py | 5 +++++
 framework/results.py      | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/framework/programs/run.py b/framework/programs/run.py
index 9a6276f..6971701 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -163,6 +163,10 @@ def _run_parser(input_):
     parser.add_argument("-s", "--sync",
                         action="store_true",
                         help="Sync results to disk after every test")
+    parser.add_argument("--junit_suffix",
+                        type=str,
+                        default="",
+                        help="suffix string to append to each test name in junit")
     parser.add_argument("test_profile",
                         metavar="<Path to one or more test profile(s)>",
                         nargs='+',
@@ -245,6 +249,7 @@ def run(input_):
     # refactored to make that possible because of the flattening pass that is
     # part of profile.run
     options['test_count'] = 0
+    options['test_suffix'] = args.junit_suffix
 
     # Begin json.
     backend = framework.results.get_backend(args.backend)(
diff --git a/framework/results.py b/framework/results.py
index e73519a..b567553 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -391,6 +391,7 @@ class JUnitBackend(FSyncMixin, Backend):
         self._file.write(
             '<testsuite name="piglit" tests="{}">\n'.format(
                 metadata['test_count']))
+        self._test_suffix = metadata["test_suffix"]
 
     def finalize(self, metadata=None):
         self._file.write('</testsuite>\n')
@@ -414,7 +415,7 @@ class JUnitBackend(FSyncMixin, Backend):
         classname = 'piglit.' + classname
 
         # Create the root element
-        element = etree.Element('testcase', name=testname,
+        element = etree.Element('testcase', name=testname + self._test_suffix,
                                 classname=classname,
                                 time=str(data['time']),
                                 status=str(data['result']))
-- 
2.1.0



More information about the Piglit mailing list