Skip to content

Commit 6a02908

Browse files
committed
fix some more boolean operations of groundtruth.result
1 parent 7f70c32 commit 6a02908

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

atf_core/scripts/analyser.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
import yaml
1414

1515
from atf_core import ATFConfigurationParser
16-
from atf_msgs.msg import AtfResult, TestResult, TestblockResult, MetricResult, TestblockStatus, KeyValue, DataStamped
16+
from atf_msgs.msg import AtfResult, TestResult, TestblockResult, MetricResult, TestblockStatus, KeyValue, DataStamped, Groundtruth
1717
from atf_metrics import metrics_helper
1818

1919
class Analyser:
2020
def __init__(self, package_name, test_generation_config_file = "atf/test_generation_config.yaml"):
2121
print "ATF analyser: started!"
2222
start_time = time.time()
2323
self.ns = "/atf/"
24-
self.error = False
2524
self.package_name = package_name
2625

2726
# parse configuration
@@ -182,7 +181,7 @@ def aggregate_results(self, atf_result):
182181
#print " tl_test=", tl_test
183182
metric_result = MetricResult()
184183
status = TestblockStatus.SUCCEEDED
185-
groundtruth_result = True
184+
groundtruth_result = Groundtruth.SUCCEEDED
186185
groundtruth_error_message = ""
187186
details = []
188187
for test in mbt[metric][testblock].keys():
@@ -201,8 +200,8 @@ def aggregate_results(self, atf_result):
201200

202201
# aggregate groundtruth from every metric_result
203202
groundtruth = mbt[metric][testblock][test].groundtruth
204-
if groundtruth.result == False:
205-
groundtruth_result = False
203+
if groundtruth.result != Groundtruth.SUCCEEDED:
204+
groundtruth_result = Groundtruth.FAILED
206205
if groundtruth_error_message != "":
207206
groundtruth_error_message += "\n"
208207
groundtruth_error_message += "groundtruth missmatch in subtest %s"%(test)
@@ -272,7 +271,7 @@ def aggregate_results(self, atf_result):
272271
metric_result = tbm[test][testblock][metric]
273272
testblock_result.results.append(metric_result)
274273
# aggregate metric result
275-
if metric_result.groundtruth.result == False:
274+
if metric_result.groundtruth.result != Groundtruth.SUCCEEDED:
276275
testblock_result.result = False
277276
testblock_result.error_message += "\n - metric '%s': %s"%(metric_result.name, metric_result.groundtruth.error_message)
278277

atf_core/src/atf_core/testblock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, name, metric_handles, recorder_handle):
1212
self.trigger = None
1313
self.timestamp = None
1414
self.exception = None
15-
self.status = None
15+
self.status = TestblockStatus.INACTIVE
1616

1717
def get_result(self):
1818

@@ -34,7 +34,7 @@ def get_result(self):
3434
testblock_result.results.append(metric_result)
3535

3636
# aggregate result
37-
if metric_result.groundtruth.result != None and metric_result.groundtruth.result != Groundtruth.SUCCEEDED:
37+
if metric_result.groundtruth.result != Groundtruth.SUCCEEDED:
3838
testblock_result.result = False
3939
testblock_result.error_message += "\n - metric '%s': %s"%(metric_result.name, metric_result.groundtruth.error_message)
4040
#print testblock_result.groundtruth_error_message

atf_metrics/src/atf_metrics/calculate_interface.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ def calculate_data_and_details(self):
159159
node_name = self.params['node']
160160
if node_name not in self.api_dict:
161161
details = "node " + node_name + " is not in api"
162-
groundtruth.result = False
162+
groundtruth.result = Groundtruth.FAILED
163163
data = 0.0
164164
else:
165165
details = "node " + node_name + " is in api"
166-
groundtruth.result = True
166+
groundtruth.result = Groundtruth.SUCCEEDED
167167
data = 100.0
168168
for interface, interface_data in self.params.items():
169169
if interface == "publishers" or interface == "subscribers" or interface == "services":
@@ -175,16 +175,16 @@ def calculate_data_and_details(self):
175175
name_check, type_check = self.check_interface(topic_name, topic_type, self.api_dict[node_name][interface])
176176
if not name_check:
177177
details += ", but " + topic_name + " is not an interface of node " + node_name + ". Interfaces are: " + str(self.api_dict[node_name][interface])
178-
groundtruth.result = False
178+
groundtruth.result = Groundtruth.FAILED
179179
data = 33.3
180180
else:
181181
if not type_check:
182182
details += ", but " + topic_name + " (with type " + topic_type + ") is not an interface of node " + node_name + ". Interfaces are: " + str(self.api_dict[node_name][interface])
183-
groundtruth.result = False
183+
groundtruth.result = Groundtruth.FAILED
184184
data = 66.0
185185
else: # all Ok
186186
details += ", all interfaces of node " + node_name + ": OK"
187-
groundtruth.result = True
187+
groundtruth.result = Groundtruth.SUCCEEDED
188188
data = 100.0
189189
return data, details
190190

atf_metrics/src/atf_metrics/calculate_user_result.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def get_result(self):
9494
# check if result is available
9595
if self.metric_result.groundtruth.result == Groundtruth.UNSET and not self.groundtruth.available:
9696
# let the analyzer know that this test failed
97-
print self.metric_result.groundtruth.result, self.status.status
9897
metric_result.groundtruth.result = Groundtruth.FAILED
9998
metric_result.groundtruth.error_message = "testblock %s stopped without user_result"%self.testblock_name
10099
return metric_result

atf_plotter/scripts/plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import matplotlib as mpl
66
mpl.style.use('classic')
77

8-
from atf_msgs.msg import AtfResult, MetricResult, TestblockStatus
8+
from atf_msgs.msg import AtfResult, MetricResult, TestblockStatus, Groundtruth
99
from atf_core import ATFConfigurationParser
1010

1111
import matplotlib.pyplot as plt
@@ -143,7 +143,7 @@ def plot_benchmark(self, style, sharey, hide_groundtruth, hide_min_max, filter_t
143143

144144
# set marker transparency (filled or transparent)
145145
if metric_result.status == TestblockStatus.SUCCEEDED\
146-
and (metric_result.groundtruth.result or not metric_result.groundtruth.available):
146+
and (metric_result.groundtruth.result == Groundtruth.SUCCEEDED or not metric_result.groundtruth.available):
147147
markerfacecolor = None # plot filled marker
148148
else:
149149
markerfacecolor = 'None' # plot transparent marker

0 commit comments

Comments
 (0)