1 # Copyright (c) 2016-2016 Intel Corporation
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation
5 # files (the "Software"), to deal in the Software without
6 # restriction, including without limitation the rights to use,
7 # copy, modify, merge, publish, distribute, sublicense, and/or
8 # sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following
12 # This permission notice shall be included in all copies or
13 # substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR(S) BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
21 # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
24 from __future__
import (
25 absolute_import
, division
, print_function
, unicode_literals
29 import simplejson
as json
33 from framework
import profile
, status
36 class FeatResults(object): # pylint: disable=too-few-public-methods
37 """Container object for results.
39 Has the results, feature profiles and feature computed results.
42 def __init__(self
, results
, json_file
):
44 with
open(json_file
) as data
:
45 feature_data
= json
.load(data
)
47 self
.feat_fractions
= {}
50 self
.results
= results
54 # we expect all the result sets to be for the same profile
55 profile_orig
= profile
.load_test_profile(results
[0].options
['profile'][0])
57 for feature
in feature_data
:
58 self
.features
.add(feature
)
60 profiles
[feature
] = profile_orig
.copy()
62 incl_str
= feature_data
[feature
]["include_tests"]
63 excl_str
= feature_data
[feature
]["exclude_tests"]
65 profiles
[feature
].filters
.append(
67 [incl_str
] if incl_str
and not incl_str
.isspace() else []))
68 profiles
[feature
].filters
.append(
70 [excl_str
] if excl_str
and not excl_str
.isspace() else [],
73 for results
in self
.results
:
74 self
.feat_fractions
[results
.name
] = {}
75 self
.feat_status
[results
.name
] = {}
77 for feature
in feature_data
:
78 result_set
= set(results
.tests
)
79 profile_set
= set(a
for a
, _
in profiles
[feature
].itertests())
81 common_set
= profile_set
& result_set
82 passed_list
= [x
for x
in common_set
if results
.tests
[x
].result
== status
.PASS
]
84 total
= len(common_set
)
85 passed
= len(passed_list
)
87 self
.feat_fractions
[results
.name
][feature
] = (passed
, total
)
89 self
.feat_status
[results
.name
][feature
] = status
.NOTRUN
91 if 100 * passed
// total
>= feature_data
[feature
]["target_rate"]:
92 self
.feat_status
[results
.name
][feature
] = status
.PASS
94 self
.feat_status
[results
.name
][feature
] = status
.FAIL