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

Dylan Baker baker.dylan.c at gmail.com
Thu Oct 30 16:32:42 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
v3: - Only add each element if it exists
    - Put the tests in their own module

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/backends/json_.py |  2 +-
 framework/results.py        | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 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..7d9d0bd 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,31 @@ 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.
+
+    Namely uname, glxinfo, wglinfo, and lspci were put in the options['env']
+    instead of in the root.
+
+    """
+    if 'env' in results.options:
+        env = results.options['env']
+        if env.get('glxinfo'):
+            results.glxinfo = env['glxinfo']
+        if env.get('lspci'):
+            results.lspci = env['lspci']
+        if env.get('uname'):
+            results.uname = env['uname']
+        if env.get('wglinfo'):
+            results.wglinfo = env['wglinfo']
+        del results.options['env']
+
+    results.results_version = 2
+
+    return results
-- 
2.1.2



More information about the Piglit mailing list