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 v4: - actually check that test module into git... Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com> --- framework/backends/json_.py | 2 +- framework/results.py | 29 +++++++ framework/tests/results_v1_tests.py | 161 ++++++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 framework/tests/results_v1_tests.py 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 diff --git a/framework/tests/results_v1_tests.py b/framework/tests/results_v1_tests.py new file mode 100644 index 0000000..bf14231 --- /dev/null +++ b/framework/tests/results_v1_tests.py @@ -0,0 +1,161 @@ +# Copyright (c) 2014 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +"""Tests for version 1 to version 2.""" + +import json + +import nose.tools as nt + +import framework.results as results +import framework.tests.utils as utils + + +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') + + +class TestV2NoUpdate(object): + """Test a version 1 to 2 update when version 1 was correct.""" + @classmethod + def setup_class(cls): + data = { + "results_version": 1, + "name": "test", + "lspci": "stuff", + "uname": "more stuff", + "glxinfo": "and stuff", + "wglinfo": "stuff", + "options": { + "profile": ['quick'], + "dmesg": False, + "verbose": False, + "platform": "gbm", + "sync": False, + "valgrind": False, + "filter": [], + "concurrent": "all", + "test_count": 0, + "exclude_tests": [], + "exclude_filter": [], + }, + "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) no change: The result version is updated to 2. + """ + nt.assert_equal(self.result.results_version, 2) + + def test_glxinfo(self): + """update_results (v2) no change: doesn't clobber glxinfo.""" + nt.assert_equal(self.result.glxinfo, 'and stuff') + + def test_lspci(self): + """update_results (v2) no change: doesn't clobber lspci.""" + nt.assert_equal(self.result.lspci, 'stuff') + + def test_uname(self): + """update_results (v2) no change: doesn't clobber uname.""" + nt.assert_equal(self.result.uname, 'more stuff') + + def test_wglinfo(self): + """update_results (v2) no change: doesn't clobber wglinfo.""" + nt.assert_equal(self.result.wglinfo, 'stuff') -- 2.1.2 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit