[Piglit] [PATCH 2/3] Test Reporting: simplify subtest reporting

Dylan Baker baker.dylan.c at gmail.com
Wed Jun 11 16:32:32 PDT 2014


Since we're using json to decode our results, we can simplify the way we
pass information between C/C++ tests and the python framework. This
replaces the PIGLIT:subtest {"<name>": "<status>"} syntax with
PIGLIT: {"subtest": {"<name>": "<status>"}}.

This is a very clean solution, and eliminates the need for several if
branches and loop iterations in the python framework.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/exectest.py            | 8 +-------
 framework/tests/exectest_test.py | 2 +-
 tests/util/piglit-util.c         | 4 ++--
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/framework/exectest.py b/framework/exectest.py
index d2c550d..3c447c3 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -264,12 +264,6 @@ class PiglitTest(Test):
         outpiglit = (s[7:] for s in outlines if s.startswith('PIGLIT:'))
 
         for piglit in outpiglit:
-            if piglit.startswith('subtest'):
-                if not 'subtest' in self.result:
-                    self.result['subtest'] = {}
-                self.result['subtest'].update(
-                    json.loads(piglit[7:]))
-            else:
-                self.result.update(json.loads(piglit))
+            self.result.update(json.loads(piglit))
         self.result['out'] = '\n'.join(
             s for s in outlines if not s.startswith('PIGLIT:'))
diff --git a/framework/tests/exectest_test.py b/framework/tests/exectest_test.py
index dbc748a..c950499 100644
--- a/framework/tests/exectest_test.py
+++ b/framework/tests/exectest_test.py
@@ -45,6 +45,6 @@ def test_piglittest_interpret_result_subtest():
     """ PiglitTest.interpret_result() works with subtests """
     test = PiglitTest('foo')
     test.result['out'] = ('PIGLIT: {"result": "pass"}\n'
-                          'PIGLIT:subtest {"subtest": "pass"}\n')
+                          'PIGLIT: {"subtest": {"subtest": "pass"}}\n')
     test.interpret_result()
     assert test.result['subtest']['subtest'] == 'pass'
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index a6da456..dd6134e 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -241,9 +241,9 @@ piglit_report_subtest_result(enum piglit_result result, const char *format, ...)
 
 	va_start(ap, format);
 
-	printf("PIGLIT:subtest {\"");
+	printf("PIGLIT: {\"subtest\": {\"");
 	vprintf(format, ap);
-	printf("\" : \"%s\"}\n", result_str);
+	printf("\" : \"%s\"}}\n", result_str);
 	fflush(stdout);
 
 	va_end(ap);
-- 
2.0.0



More information about the Piglit mailing list