diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-08-24 15:14:01 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-10-07 13:21:19 -0700 |
commit | 97b9d2ddd95d5e6b7ae3a2aa089b360bee428039 (patch) | |
tree | a3523ce965e5eaadd6cc3a12a32a5f511c191462 | |
parent | 6c7793d04d529333f07a6396330b623a2f4c6d71 (diff) |
framework: Bump JSON on disk format to version 9
This change makes the TestResult.pid field into a list of ints instead
of a list. This will be used by the multiple test per process tests to
ensure that all PIDs are recorded when the cherry features is invoked.
This is groundwork for later patches in the series.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | framework/backends/json.py | 18 | ||||
-rw-r--r-- | framework/results.py | 2 | ||||
-rw-r--r-- | framework/test/base.py | 2 | ||||
-rw-r--r-- | unittests/framework/backends/schema/piglit-9.json | 122 | ||||
-rw-r--r-- | unittests/framework/backends/shared.py | 4 | ||||
-rw-r--r-- | unittests/framework/backends/test_json_update.py | 85 |
6 files changed, 228 insertions, 5 deletions
diff --git a/framework/backends/json.py b/framework/backends/json.py index 69f531936..f279f2fb6 100644 --- a/framework/backends/json.py +++ b/framework/backends/json.py @@ -53,7 +53,7 @@ __all__ = [ ] # The current version of the JSON results -CURRENT_JSON_VERSION = 8 +CURRENT_JSON_VERSION = 9 # The level to indent a final file INDENT = 4 @@ -339,6 +339,7 @@ def _update_results(results, filepath): 5: _update_five_to_six, 6: _update_six_to_seven, 7: _update_seven_to_eight, + 8: _update_eight_to_nine, } while results.results_version < CURRENT_JSON_VERSION: @@ -636,6 +637,21 @@ def _update_seven_to_eight(result): return result +def _update_eight_to_nine(result): + """Update json results from version 8 to 9. + + This changes the PID feild of the TestResult object to alist of Integers or + null rather than a single integer or null. + + """ + for test in compat.viewvalues(result.tests): + test.pid = [test.pid] + + result.results_version = 9 + + return result + + REGISTRY = Registry( extensions=['', '.json'], backend=JSONBackend, diff --git a/framework/results.py b/framework/results.py index 756d26109..f9ddcb4cd 100644 --- a/framework/results.py +++ b/framework/results.py @@ -162,7 +162,7 @@ class TestResult(object): self.images = None self.traceback = None self.exception = None - self.pid = None + self.pid = [] if result: self.result = result else: diff --git a/framework/test/base.py b/framework/test/base.py index 63fcaf4c4..b667b1569 100644 --- a/framework/test/base.py +++ b/framework/test/base.py @@ -322,7 +322,7 @@ class Test(object): universal_newlines=True, **_EXTRA_POPEN_ARGS) - self.result.pid = proc.pid + self.result.pid.append(proc.pid) if not _SUPPRESS_TIMEOUT: out, err = proc.communicate(timeout=self.timeout) else: diff --git a/unittests/framework/backends/schema/piglit-9.json b/unittests/framework/backends/schema/piglit-9.json new file mode 100644 index 000000000..1d401ae61 --- /dev/null +++ b/unittests/framework/backends/schema/piglit-9.json @@ -0,0 +1,122 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "TestrunResult", + "description": "The collection of all results", + "type": "object", + "properties": { + "__type__": { "type": "string" }, + "clinfo": { "type": ["string", "null"] }, + "glxinfo": { "type": ["string", "null"] }, + "lspci": { "type": ["string", "null"] }, + "wglinfo": { "type": ["string", "null"] }, + "name": { "type": "string" }, + "results_version": { "type": "number" }, + "uname": { "type": [ "string", "null" ] }, + "time_elapsed": { "$ref": "#/definitions/timeAttribute" }, + "options": { + "descrption": "The options that were invoked with this run. These are implementation specific and not required.", + "type": "object", + "properties": { + "exclude_tests": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true + }, + "include_filter": { + "type": "array", + "items": { "type": "string" } + }, + "exclude_filter": { + "type": "array", + "items": { "type": "string" } + }, + "sync": { "type": "boolean" }, + "valgrind": { "type": "boolean" }, + "monitored": { "type": "boolean" }, + "dmesg": { "type": "boolean" }, + "execute": { "type": "boolean" }, + "concurrent": { "enum": ["none", "all", "some"] }, + "platform": { "type": "string" }, + "log_level": { "type": "string" }, + "env": { + "description": "Environment variables that must be specified", + "type": "object", + "additionalProperties": { "type": "string" } + }, + "profile": { + "type": "array", + "items": { "type": "string" } + } + } + }, + "totals": { + "type": "object", + "description": "A calculation of the group totals.", + "additionalProperties": { + "type": "object", + "properties": { + "crash": { "type": "number" }, + "dmesg-fail": { "type": "number" }, + "dmesg-warn": { "type": "number" }, + "fail": { "type": "number" }, + "incomplete": { "type": "number" }, + "notrun": { "type": "number" }, + "pass": { "type": "number" }, + "skip": { "type": "number" }, + "timeout": { "type": "number" }, + "warn": { "type": "number" } + }, + "additionalProperties": false, + "required": [ "crash", "dmesg-fail", "dmesg-warn", "fail", "incomplete", "notrun", "pass", "skip", "timeout", "warn" ] + } + }, + "tests": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "__type__": { "type": "string" }, + "err": { "type": "string" }, + "exception": { "type": ["string", "null"] }, + "result": { + "type": "string", + "enum": [ "pass", "fail", "crash", "warn", "incomplete", "notrun", "skip", "dmesg-warn", "dmesg-fail" ] + }, + "environment": { "type": "string" }, + "command": { "type": "string" }, + "traceback": { "type": ["string", "null"] }, + "out": { "type": "string" }, + "dmesg": { "type": "string" }, + "pid": { + "type": "array", + "items": { "type": "number" } + }, + "returncode": { "type": [ "number", "null" ] }, + "time": { "$ref": "#/definitions/timeAttribute" }, + "subtests": { + "type": "object", + "properties": { "__type__": { "type": "string" } }, + "additionalProperties": { "type": "string" }, + "required": [ "__type__" ] + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "required": [ "__type__", "clinfo", "glxinfo", "lspci", "wglinfo", "name", "results_version", "uname", "time_elapsed", "tests" ], + "definitions": { + "timeAttribute": { + "type": "object", + "description": "An element containing a start and end time", + "properties": { + "__type__": { "type": "string" }, + "start": { "type": "number" }, + "end": { "type": "number" } + }, + "additionalProperties": false, + "required": [ "__type__", "start", "end" ] + } + } +} diff --git a/unittests/framework/backends/shared.py b/unittests/framework/backends/shared.py index dd90fc25d..ca2b478c0 100644 --- a/unittests/framework/backends/shared.py +++ b/unittests/framework/backends/shared.py @@ -42,7 +42,7 @@ INITIAL_METADATA = { # changes. This does not contain piglit specifc objects, only strings, floats, # ints, and Nones (instead of JSON's null) JSON = { - "results_version": 8, + "results_version": 9, "time_elapsed": { "start": 1469638791.2351687, "__type__": "TimeAttribute", @@ -67,7 +67,7 @@ JSON = { "__type__": "TimeAttribute", "end": 1469638791.2439244 }, - "pid": 11768, + "pid": [11768], "__type__": "TestResult", "returncode": 1, "result": "fail", diff --git a/unittests/framework/backends/test_json_update.py b/unittests/framework/backends/test_json_update.py index 33b4c0904..501a895a4 100644 --- a/unittests/framework/backends/test_json_update.py +++ b/unittests/framework/backends/test_json_update.py @@ -34,6 +34,7 @@ try: except ImportError: from unittest import mock +import jsonschema import pytest import six @@ -865,3 +866,87 @@ class TestV7toV8(object): """ assert result.time_elapsed.start == 0.0 assert result.time_elapsed.end == 1.2 + + def test_valid(self, result): + with open(os.path.join(os.path.dirname(__file__), 'schema', + 'piglit-8.json'), + 'r') as f: + schema = json.load(f) + jsonschema.validate( + json.loads(json.dumps(result, default=backends.json.piglit_encoder)), + schema) + + +class TestV8toV9(object): + """Tests for Version 8 to version 9.""" + + data = { + "results_version": 9, + "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@test': { + "time_elapsed": { + 'start': 1.2, + 'end': 1.8, + '__type__': 'TimeAttribute' + }, + 'dmesg': '', + 'result': 'fail', + '__type__': 'TestResult', + 'command': '/a/command', + 'traceback': None, + 'out': '', + 'environment': 'A=variable', + 'returncode': 0, + 'err': '', + 'pid': 5, + 'subtests': { + '__type__': 'Subtests', + }, + 'exception': None, + } + }, + "time_elapsed": { + 'start': 1.2, + 'end': 1.8, + '__type__': 'TimeAttribute' + } + } + + @pytest.fixture + def result(self, tmpdir): + p = tmpdir.join('result.json') + p.write(json.dumps(self.data, default=backends.json.piglit_encoder)) + with p.open('r') as f: + return backends.json._update_eight_to_nine(backends.json._load(f)) + + def test_pid(self, result): + assert result.tests['a@test'].pid == [5] + + def test_valid(self, result): + with open(os.path.join(os.path.dirname(__file__), 'schema', + 'piglit-9.json'), + 'r') as f: + schema = json.load(f) + jsonschema.validate( + json.loads(json.dumps(result, default=backends.json.piglit_encoder)), + schema) |