Skip to content

Commit

Permalink
[web] Fix storage of control points
Browse files Browse the repository at this point in the history
In the `6.18.0` release Ericsson#3462 patch introduced a bug that not all of the
control points are stored to the server, because the plist format what the
report converter produced and the plist parser expected was invalid:
- `range` key was used instead of `ranges`.
- Control events are not stored as separated items but as a single control event.
  • Loading branch information
csordasmarton committed Jan 11, 2022
1 parent eaeddd9 commit 9918798
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,17 @@ def convert(
if report.analyzer_name:
diagnostic['type'] = report.analyzer_name

control_edges = []
path = []
if report.bug_path_positions:
for i in range(len(report.bug_path_positions) - 1):
start = report.bug_path_positions[i]
end = report.bug_path_positions[i + 1]
if start.range and end.range:
control_edges.append(self._create_control_edge(
edge = self._create_control_edge(
start.range, start.file,
end.range, end.file,
file_index_map))
file_index_map)
path.append(self._create_control_edges([edge]))
elif len(report.bug_path_events) > 1:
# Create bug path positions from bug path events.
for i in range(len(report.bug_path_events) - 1):
Expand All @@ -497,14 +498,11 @@ def convert(
if start_range == end_range:
continue

control_edges.append(self._create_control_edge(
edge = self._create_control_edge(
start_range, start.file,
end_range, end.file,
file_index_map))

path = []
if control_edges:
path.append(self._create_control_edges(control_edges))
file_index_map)
path.append(self._create_control_edges([edge]))

# Add bug path events after control points.
if report.bug_path_events:
Expand Down Expand Up @@ -572,8 +570,8 @@ def _create_event(
'message': event.message}

if event.range:
data['range'] = self._create_range(
event.range, file_index_map[event.file.original_path])
data['ranges'] = [self._create_range(
event.range, file_index_map[event.file.original_path])]

return data

Expand Down Expand Up @@ -609,8 +607,8 @@ def _create_note(
'message': note.message}

if note.range:
data['range'] = self._create_range(
note.range, file_index_map[note.file.original_path])
data['ranges'] = [self._create_range(
note.range, file_index_map[note.file.original_path])]

return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@
</dict>
<key>message</key>
<string>Division by zero</string>
<key>range</key>
<key>ranges</key>
<array>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
<array>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
</array>
</array>
</dict>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -107,6 +114,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -147,6 +161,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -107,6 +114,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -147,6 +161,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -187,6 +208,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
16 changes: 16 additions & 0 deletions web/tests/functional/report_viewer_api/test_get_run_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ def test_unqiue_report_details(self):

self.assertTrue(any(res.details for res in run_results))

def test_report_path_and_events(self):
"""
Test that bug path events and control points are stored properly.
"""
sort_mode = SortMode(SortType.FILENAME, Order.ASC)

report_filter = ReportFilter(
checkerName=['core.DivideZero'],
filepath=['*path_begin.cpp'])

report = self._cc_client.getRunResults(
[self._runid], 1, 0, [sort_mode], report_filter, None, True)[0]

self.assertEqual(len(report.details.executionPath), 7)
self.assertEqual(len(report.details.pathEvents), 5)

def test_get_checker_labels(self):
checker_labels = self._cc_client.getCheckerLabels([])
self.assertEqual(len(checker_labels), 0)
Expand Down

0 comments on commit 9918798

Please sign in to comment.