aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib/sarif.py
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/lib/sarif.py')
-rw-r--r--gcc/testsuite/lib/sarif.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/lib/sarif.py b/gcc/testsuite/lib/sarif.py
index 7daf35b..384de2f 100644
--- a/gcc/testsuite/lib/sarif.py
+++ b/gcc/testsuite/lib/sarif.py
@@ -1,5 +1,6 @@
import json
import os
+import xml.etree.ElementTree as ET
def sarif_from_env():
# return parsed JSON content a SARIF_PATH file
@@ -21,3 +22,17 @@ def get_location_snippet_text(location):
def get_location_relationships(location):
return location['relationships']
+
+def get_result_by_index(sarif, idx):
+ runs = sarif['runs']
+ run = runs[0]
+ results = run['results']
+ return results[idx]
+
+def get_xml_state(events, event_idx):
+ xml_src = events[event_idx]['properties']['gcc/diagnostic_event/xml_state']
+ if 0:
+ print(xml_src)
+ xml = ET.fromstring(xml_src)
+ assert xml.tag == 'state-diagram'
+ return xml