[Piglit] [PATCH] framework/backends/json: Handle updating results without pid field
Dylan Baker
dylan at pnwbakers.com
Fri Nov 4 19:34:10 UTC 2016
If it's not present make it an empty list.
cc: Brian Paul <brianp at vmware.com>
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/backends/json.py | 5 ++++-
unittests/framework/backends/test_json_update.py | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/framework/backends/json.py b/framework/backends/json.py
index 17002ed..5516919 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -380,7 +380,10 @@ def _update_eight_to_nine(result):
"""
for test in compat.viewvalues(result['tests']):
- test['pid'] = [test['pid']]
+ if 'pid' in test:
+ test['pid'] = [test['pid']]
+ else:
+ test['pid'] = []
result['results_version'] = 9
diff --git a/unittests/framework/backends/test_json_update.py b/unittests/framework/backends/test_json_update.py
index c8e3ee6..be12d31 100644
--- a/unittests/framework/backends/test_json_update.py
+++ b/unittests/framework/backends/test_json_update.py
@@ -173,6 +173,26 @@ class TestV8toV9(object):
'__type__': 'Subtests',
},
'exception': None,
+ },
+ 'b at test': {
+ "time": {
+ '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': '',
+ 'subtests': {
+ '__type__': 'Subtests',
+ },
+ 'exception': None,
}
},
"time_elapsed": {
@@ -193,6 +213,10 @@ class TestV8toV9(object):
def test_pid(self, result):
assert result['tests']['a at test']['pid'] == [5]
+ def test_no_pid(self, result):
+ assert result['tests']['b at test']['pid'] == []
+
+
def test_valid(self, result):
with open(os.path.join(os.path.dirname(__file__), 'schema',
'piglit-9.json'),
--
2.10.2
More information about the Piglit
mailing list