[Piglit] [Patch v2 5/5] json_.py: Bump results version to 2

Dylan Baker baker.dylan.c at gmail.com
Thu Oct 30 14:27:01 PDT 2014


This corrects in a permanent and automatic way the changes in the
results that were fixed in the previous patch.

v2: - add this patch

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---

Emil, this should solve the manually editing files problem you reported
with the original series.

 framework/backends/json_.py      |  2 +-
 framework/results.py             | 22 +++++++++++++
 framework/tests/results_tests.py | 69 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/framework/backends/json_.py b/framework/backends/json_.py
index f4a740f..75d00cd 100644
--- a/framework/backends/json_.py
+++ b/framework/backends/json_.py
@@ -37,7 +37,7 @@ __all__ = [
 
 
 # The current version of the JSON results
-CURRENT_JSON_VERSION = 1
+CURRENT_JSON_VERSION = 2
 
 
 def piglit_encoder(obj):
diff --git a/framework/results.py b/framework/results.py
index 912e739..a64b664 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -227,6 +227,7 @@ def update_results(results, filepath):
         # dictionary
         updates = {
             0: _update_zero_to_one,
+            1: _update_one_to_two,
         }
 
         while results.results_version < CURRENT_JSON_VERSION:
@@ -363,3 +364,24 @@ def _update_zero_to_one(results):
     results.results_version = 1
 
     return results
+
+
+def _update_one_to_two(results):
+    """Update version 1 results to version 2.
+
+    Version two results are actually identical to version one results, however,
+    there was an error in version 1 at the end causing metadata in the options
+    dictionary to be incorrect. Version 2 corrects that.
+
+    """
+    if 'env' in results.options:
+        env = results.options['env']
+        results.glxinfo = env.get('glxinfo')
+        results.lspci = env.get('lspci')
+        results.uname = env.get('uname')
+        results.wglinfo = env.get('wglinfo')
+        del results.options['env']
+
+    results.results_version = 2
+
+    return results
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 24b8926..a9a53cc 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -207,3 +207,72 @@ def test_resume_load_invalid():
             set(test.tests.keys()),
             set(['group1/test1', 'group1/test2', 'group2/test3']),
         )
+
+
+class TestV2Update(object):
+    """Test V1 to V2 of results."""
+    @classmethod
+    def setup_class(cls):
+        data = {
+            "results_version": 1,
+            "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": {
+                "test/is/a/test": {
+                    "returncode": 0,
+                    "err": None,
+                    "environment": None,
+                    "command": "foo",
+                    "result": "skip",
+                    "time": 0.123,
+                    "out": None,
+                }
+            }
+        }
+
+        with utils.with_tempfile(json.dumps(data)) as t:
+            with open(t, 'r') as f:
+                cls.result = results._update_one_to_two(
+                    results.TestrunResult.load(f))
+
+    def test_version_is_two(self):
+        """update_results (v2): The result version is updated to 2."""
+        nt.assert_equal(self.result.results_version, 2)
+
+    def test_no_env(self):
+        """update_results (v2): Removes options['env']."""
+        nt.ok_('env' not in self.result.options)
+
+    def test_glxinfo(self):
+        """update_results (v2): puts glxinfo in the root."""
+        nt.assert_equal(self.result.glxinfo, 'and stuff')
+
+    def test_lspci(self):
+        """update_results (v2): puts lspci in the root."""
+        nt.assert_equal(self.result.lspci, 'stuff')
+
+    def test_uname(self):
+        """update_results (v2): puts uname in the root."""
+        nt.assert_equal(self.result.uname, 'more stuff')
+
+    def test_wglinfo(self):
+        """update_results (v2): puts wglinfo in the root."""
+        nt.assert_equal(self.result.wglinfo, 'stuff')
-- 
2.1.2



More information about the Piglit mailing list