[Piglit] [PATCH 04/26] framework/backends/json.py: store totals data in json
Dylan Baker
baker.dylan.c at gmail.com
Fri Sep 11 15:55:30 PDT 2015
Because compression is so awesome even a full run of quick.py is only
~50kb with all of this extra data. This isn't a big drain, and saves us
a lot of time calculating this data over and over.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/backends/json.py | 18 +++++++++-
framework/tests/json_results_update_tests.py | 51 ++++++++++++++++++++++++++--
2 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/framework/backends/json.py b/framework/backends/json.py
index b5a38d0..5eeab44 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -42,7 +42,7 @@ __all__ = [
]
# The current version of the JSON results
-CURRENT_JSON_VERSION = 6
+CURRENT_JSON_VERSION = 7
# The level to indent a final file
INDENT = 4
@@ -274,6 +274,8 @@ def _resume(results_dir):
except ValueError:
continue
+ testrun.calculate_group_totals()
+
return testrun
@@ -301,6 +303,7 @@ def _update_results(results, filepath):
3: _update_three_to_four,
4: _update_four_to_five,
5: _update_five_to_six,
+ 6: _update_six_to_seven,
}
while results.results_version < CURRENT_JSON_VERSION:
@@ -565,6 +568,19 @@ def _update_five_to_six(result):
return result
+def _update_six_to_seven(result):
+ """Update json results from version 6 to 7.
+
+ Version 7 results always contain the totals member.
+
+ """
+ if not result.totals:
+ result.calculate_group_totals()
+ result.results_version = 7
+
+ return result
+
+
REGISTRY = Registry(
extensions=['', '.json'],
backend=JSONBackend,
diff --git a/framework/tests/json_results_update_tests.py b/framework/tests/json_results_update_tests.py
index 3552506..9ae1102 100644
--- a/framework/tests/json_results_update_tests.py
+++ b/framework/tests/json_results_update_tests.py
@@ -693,12 +693,59 @@ class TestV5toV6(object):
"""backends.json.update_results (5 -> 6): A test result is converted to a TestResult instance"""
nt.ok_(isinstance(self.result.tests['a at test'], results.TestResult))
+
+class TestV6toV7(object):
+ DATA = {
+ "results_version": 6,
+ "name": "test",
+ "options": {
+ "profile": ['quick'],
+ "dmesg": False,
+ "verbose": False,
+ "platform": "gbm",
+ "sync": False,
+ "valgrind": False,
+ "filter": [],
+ "concurrent": "all",
+ "test_count": 0,
+ "exclude_tests": [],
+ "exclude_filter": [],
+ "env": {
+ "lspci": "stuff",
+ "uname": "more stuff",
+ "glxinfo": "and stuff",
+ "wglinfo": "stuff"
+ }
+ },
+ "tests": {
+ 'a at test': results.TestResult('pass'),
+ 'a at nother@test': results.TestResult('fail'),
+ 'a at nother@thing': results.TestResult('crash'),
+ }
+ }
+
+ @classmethod
+ def setup_class(cls):
+ """Class setup. Create a TestrunResult with v4 data."""
+ with utils.tempfile(
+ json.dumps(cls.DATA, default=backends.json.piglit_encoder)) as t:
+ with open(t, 'r') as f:
+ cls.result = backends.json._update_six_to_seven(backends.json._load(f))
+
+ def test_is_TestrunResult(self):
+ """backends.json.update_results (6 -> 7): makes TestrunResult"""
+ nt.ok_(isinstance(self.result, results.TestrunResult))
+
+ def test_totals(self):
+ """backends.json.update_results (6 -> 7): Totals are populated"""
+ nt.ok_(self.result.totals != {})
+
def test_load_results(self):
- """backends.json.update_results (5 -> 6): load_results properly updates."""
+ """backends.json.update_results (6 -> 7): load_results properly updates."""
with utils.tempdir() as d:
tempfile = os.path.join(d, 'results.json')
with open(tempfile, 'w') as f:
json.dump(self.DATA, f, default=backends.json.piglit_encoder)
with open(tempfile, 'r') as f:
result = backends.json.load_results(tempfile, 'none')
- nt.assert_equal(result.results_version, 6)
+ nt.eq_(result.results_version, 7)
--
2.5.1
More information about the Piglit
mailing list