Debian Codegraph @

gcc/testsuite/gcc.dg/plugin/crash-test-ice-in-header-sarif-2_1.py

raw
1 # We expect a warning with this textual form:
2 #
3 # | In file included from PATH/crash-test-ice-header-sarif-2.1.c:5:
4 # | PATH/crash-test-ice-in-header-sarif-2.1.c: In function 'test_inject_ice':
5 # | PATH/crash-test-ice-in-header.h:3:22: internal compiler error: I'm sorry Dave, I'm afraid I can't do that
6 # | 3 | #define INJECT_ICE() inject_ice ()
7 # | | ^~~~~~~~~~~~~
8 # | PATH/crash-test-ice-in-header-sarif-2.1.c:9:3: note: in expansion of macro 'INJECT_ICE'
9 # | 9 | INJECT_ICE (); /* { dg-ice "" } */
10 # | | ^~~~~~~~~~
11
12 from sarif import *
13
14 import pytest
15
16 @pytest.fixture(scope='function', autouse=True)
17 def sarif():
18 return sarif_from_env()
19
20 def test_basics(sarif):
21 # We expect SARIF 2.1
22 schema = sarif['$schema']
23 assert schema == "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json"
24
25 version = sarif['version']
26 assert version == "2.1.0"
27
28 def test_no_result(sarif):
29 # We expect no results in the run
30 runs = sarif['runs']
31 run = runs[0]
32 results = run['results']
33 assert len(results) == 0
34
35 def test_notification(sarif):
36 # We expect an execution notification for the ICE in the invocation
37 runs = sarif['runs']
38 run = runs[0]
39
40 invocations = run['invocations']
41 assert len(invocations) == 1
42 invocation = invocations[0]
43
44 assert invocation['executionSuccessful'] == False
45
46 notifications = invocation['toolExecutionNotifications']
47 assert len(notifications) == 1
48
49 notification = notifications[0]
50
51 assert notification['message']['text'] == "I'm sorry Dave, I'm afraid I can't do that"
52 assert notification['level'] == 'error'
53
54 loc0 = notification['locations'][0]
55 assert get_location_artifact_uri(loc0).endswith('crash-test-ice-in-header.h')
56 assert 'inject_ice ();' in get_location_snippet_text(loc0)
57
58 # We may have backtrace information
59 if 'properties' in notification:
60 backtrace = notification['properties']['gcc/backtrace']
61 assert 'frames' in backtrace
62 # Ideally we should have a frame for pass_crash_test::execute(function*)
63 # but we can't rely on this.
64
65 # In SARIF 2.1 and earlier we aren't able to capture the include path
66 # as a related location within the notification
67 assert 'relationships' not in loc0
68 assert 'relatedLocations' not in notification