| 1 |
# Copyright (C) 2012-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with GCC; see the file COPYING3. If not see |
| 15 |
# <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
load_lib gcc-dg.exp |
| 18 |
|
| 19 |
# Define sarif-replay callbacks for dg.exp. |
| 20 |
|
| 21 |
proc sarif-replay-dg-test { prog do_what extra_tool_flags } { |
| 22 |
upvar dg-do-what dg-do-what |
| 23 |
|
| 24 |
set result \ |
| 25 |
[gcc-dg-test-1 sarif-replay_target_compile $prog "replay-sarif" $extra_tool_flags] |
| 26 |
|
| 27 |
set comp_output [lindex $result 0] |
| 28 |
set output_file [lindex $result 1] |
| 29 |
|
| 30 |
return [list $comp_output $output_file] |
| 31 |
} |
| 32 |
|
| 33 |
proc sarif-replay-dg-prune { system text } { |
| 34 |
return [gcc-dg-prune $system $text] |
| 35 |
} |
| 36 |
|
| 37 |
# Utility routines. |
| 38 |
|
| 39 |
# |
| 40 |
# Modified dg-runtest that can cycle through a list of optimization options |
| 41 |
# as c-torture does. |
| 42 |
# |
| 43 |
|
| 44 |
proc sarif-replay-dg-runtest { testcases flags default-extra-flags } { |
| 45 |
global runtests |
| 46 |
|
| 47 |
foreach test $testcases { |
| 48 |
# If we're only testing specific files and this isn't one of |
| 49 |
# them, skip it. |
| 50 |
if ![runtest_file_p $runtests $test] { |
| 51 |
continue |
| 52 |
} |
| 53 |
|
| 54 |
# Use TORTURE_OPTIONS to cycle through an option list. |
| 55 |
if [torture-options-exist] then { |
| 56 |
global torture_with_loops |
| 57 |
set option_list $torture_with_loops |
| 58 |
} else { |
| 59 |
set option_list { "" } |
| 60 |
} |
| 61 |
|
| 62 |
set nshort [file tail [file dirname $test]]/[file tail $test] |
| 63 |
|
| 64 |
foreach flags_t $option_list { |
| 65 |
verbose "Testing $nshort, $flags $flags_t" 1 |
| 66 |
dg-test $test "$flags $flags_t" ${default-extra-flags} |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
# |
| 72 |
# sarif-replay_load -- wrapper around default sarif-replay_load to handle tests that |
| 73 |
# require program arguments passed to them. |
| 74 |
# |
| 75 |
|
| 76 |
if { [info procs sarif-replay_load] != [list] \ |
| 77 |
&& [info procs prev_sarif-replay_load] == [list] } { |
| 78 |
rename sarif-replay_load prev_sarif-replay_load |
| 79 |
|
| 80 |
proc sarif-replay_load { program args } { |
| 81 |
global SARIF_REPLAY_EXECUTE_ARGS |
| 82 |
if [info exists SARIF_REPLAY_EXECUTE_ARGS] then { |
| 83 |
set args [concat "{$SARIF_REPLAY_EXECUTE_ARGS}"] |
| 84 |
} |
| 85 |
#print "Running: $program [lindex $args 0]" |
| 86 |
set result [eval [list prev_sarif-replay_load $program] $args ] |
| 87 |
return $result |
| 88 |
} |
| 89 |
} |
| 90 |
|