[Piglit] [PATCH v3] core.py: fix subtest json reporting
Dylan Baker
baker.dylan.c at gmail.com
Fri Aug 30 07:38:16 PDT 2013
Previously every subtest wrote an entry in the file as a full test, this
is a bug since the fake-fulltest (actually subtest) reported with the
full test value, not it's own value.
The new behavior tweaks that slightly, with this patch each subtest is
still written into the json. If there is only one subtest it is treated
as a normaltest, if there are more than one subtests then the parent
test is treated as a group, and each subtest is treated as a full test.
In this way each subtest gets exactly one entry in the summary.
v3: - Change behavior such that subtests get recorded in summary output
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
Tested-by: Homer Xing <homer.xing at intel.com>
---
framework/core.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/framework/core.py b/framework/core.py
index b1a5726..e66e53f 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -469,14 +469,23 @@ class Test:
status(result['result'])
+ # If there is more than one subtest, write each subtest as a full
+ # test, with the parent test treated as the highest group
if 'subtest' in result and len(result['subtest'].keys()) > 1:
def serious_level(result):
return {'skip':0, 'pass':1, 'warn':2, 'fail':3, 'crash':4}.get(result, 0)
- for test in result['subtest'].keys():
- if serious_level(result['subtest'][test]) >= serious_level(result['result']):
- result['result'] = result['subtest'][test]
- json_writer.write_dict_item(path + '/' + test, result)
+ for test, value in result.pop('subtest').items():
+ if serious_level(value) > serious_level(result['result']):
+ result['result'] = value
+
+ json_writer.write_dict_item(os.path.join(path, test),
+ result)
+ # if there is only one subtest remove the subtest attribute, it is
+ # redundant
+ elif 'subtest' in result:
+ result.pop('subtest')
+ json_writer.write_dict_item(path, result)
else:
json_writer.write_dict_item(path, result)
else:
--
1.8.1.5
More information about the Piglit
mailing list