framework/backends/json: Handle updating results without pid field

Submitted by Dylan Baker on Nov. 4, 2016, 7:34 p.m.

Details

Message ID 20161104193410.14535-1-dylan@pnwbakers.com
State New
Headers show
Series "framework/backends/json: Handle updating results without pid field" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Dylan Baker Nov. 4, 2016, 7:34 p.m.
If it's not present make it an empty list.

cc: Brian Paul <brianp@vmware.com>
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
---
 framework/backends/json.py                       |  5 ++++-
 unittests/framework/backends/test_json_update.py | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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@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@test']['pid'] == [5]
 
+    def test_no_pid(self, result):
+        assert result['tests']['b@test']['pid'] == []
+
+
     def test_valid(self, result):
         with open(os.path.join(os.path.dirname(__file__), 'schema',
                                'piglit-9.json'),

Comments

On 11/04/2016 01:34 PM, Dylan Baker wrote:
> If it's not present make it an empty list.
>
> cc: Brian Paul <brianp@vmware.com>
> Signed-off-by: Dylan Baker <dylanx.c.baker@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@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@test']['pid'] == [5]
>
> +    def test_no_pid(self, result):
> +        assert result['tests']['b@test']['pid'] == []
> +
> +
>       def test_valid(self, result):
>           with open(os.path.join(os.path.dirname(__file__), 'schema',
>                                  'piglit-9.json'),
>

Thanks!  Works here.

Tested-by: Brian Paul <brianp@vmware.com>