2 # Copyright (c) 2016, 2019 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person
5 # obtaining a copy of this software and associated documentation
6 # files (the "Software"), to deal in the Software without
7 # restriction, including without limitation the rights to use,
8 # copy, modify, merge, publish, distribute, sublicense, and/or
9 # sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following
13 # This permission notice shall be included in all copies or
14 # substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR(S) BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 # DEALINGS IN THE SOFTWARE.
27 from framework
import profile
, status
30 class FeatResults(object): # pylint: disable=too-few-public-methods
31 """Container object for results.
33 Has the results, feature profiles and feature computed results.
36 def __init__(self
, results
, json_file
):
38 with
open(json_file
) as data
:
39 feature_data
= json
.load(data
)
41 self
.feat_fractions
= {}
44 self
.results
= results
48 # we expect all the result sets to be for the same profile
49 profile_orig
= profile
.load_test_profile(results
[0].options
['profile'][0])
51 for feature
in feature_data
:
52 self
.features
.add(feature
)
54 profiles
[feature
] = profile_orig
.copy()
56 incl_str
= feature_data
[feature
]["include_tests"]
57 excl_str
= feature_data
[feature
]["exclude_tests"]
59 profiles
[feature
].filters
.append(
61 [incl_str
] if incl_str
and not incl_str
.isspace() else []))
62 profiles
[feature
].filters
.append(
64 [excl_str
] if excl_str
and not excl_str
.isspace() else [],
67 for results
in self
.results
:
68 self
.feat_fractions
[results
.name
] = {}
69 self
.feat_status
[results
.name
] = {}
71 for feature
in feature_data
:
72 result_set
= set(results
.tests
)
73 profile_set
= set(a
for a
, _
in profiles
[feature
].itertests())
75 common_set
= profile_set
& result_set
76 passed_list
= [x
for x
in common_set
if results
.tests
[x
].result
== status
.PASS
]
78 total
= len(common_set
)
79 passed
= len(passed_list
)
81 self
.feat_fractions
[results
.name
][feature
] = (passed
, total
)
83 self
.feat_status
[results
.name
][feature
] = status
.NOTRUN
85 if 100 * passed
// total
>= feature_data
[feature
]["target_rate"]:
86 self
.feat_status
[results
.name
][feature
] = status
.PASS
88 self
.feat_status
[results
.name
][feature
] = status
.FAIL