| 1 |
# Copyright (C) 2021-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 |
load_lib gm2.exp |
| 19 |
|
| 20 |
# Define gm2 callbacks for dg.exp. |
| 21 |
|
| 22 |
proc gm2-dg-test { prog do_what extra_tool_flags } { |
| 23 |
verbose "begin:gm2-dg-test" 1 |
| 24 |
upvar dg-do-what dg-do-what |
| 25 |
|
| 26 |
# For now demote link and run tests to compile-only. |
| 27 |
switch $do_what { |
| 28 |
link - |
| 29 |
run { |
| 30 |
set do_what compile |
| 31 |
set dg-do-what compile |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
set result \ |
| 36 |
[gcc-dg-test-1 gm2_target_compile $prog $do_what $extra_tool_flags] |
| 37 |
|
| 38 |
set comp_output [lindex $result 0] |
| 39 |
set output_file [lindex $result 1] |
| 40 |
verbose "end:gm2-dg-test" 1 |
| 41 |
return [list $comp_output $output_file] |
| 42 |
} |
| 43 |
|
| 44 |
proc gm2-dg-prune { system text } { |
| 45 |
return [gcc-dg-prune $system $text] |
| 46 |
} |
| 47 |
|
| 48 |
# Utility routines. |
| 49 |
|
| 50 |
# Modified dg-runtest that can cycle through a list of optimization options |
| 51 |
# as c-torture does. |
| 52 |
proc gm2-dg-runtest { testcases flags default-extra-flags } { |
| 53 |
global runtests |
| 54 |
global TORTURE_OPTIONS |
| 55 |
|
| 56 |
foreach test $testcases { |
| 57 |
# If we're only testing specific files and this isn't one of |
| 58 |
# them, skip it. |
| 59 |
if ![runtest_file_p $runtests $test] { |
| 60 |
continue |
| 61 |
} |
| 62 |
|
| 63 |
# look if this is dg-do run test, in which case |
| 64 |
# we cycle through the option list, otherwise we don't |
| 65 |
if [expr [search_for $test "dg-do run"]] { |
| 66 |
set option_list $TORTURE_OPTIONS |
| 67 |
} else { |
| 68 |
set option_list [list { -O -O2 } ] |
| 69 |
} |
| 70 |
|
| 71 |
set nshort [file tail [file dirname $test]]/[file tail $test] |
| 72 |
|
| 73 |
foreach flags_t $option_list { |
| 74 |
verbose "Testing $nshort, $flags $flags_t" 1 |
| 75 |
dg-test $test "$flags $flags_t" ${default-extra-flags} |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
# Check if frontend has been configured with option. |
| 82 |
# This checks a configure build option was used and not |
| 83 |
# the availability of a compiler command line option. |
| 84 |
|
| 85 |
proc gm2-dg-frontend-configure-check { option } { |
| 86 |
global GCC_UNDER_TEST |
| 87 |
|
| 88 |
# ignore any arguments after the command |
| 89 |
set compiler [lindex $GCC_UNDER_TEST 0] |
| 90 |
|
| 91 |
if ![is_remote host] { |
| 92 |
set compiler_name [which $compiler] |
| 93 |
} else { |
| 94 |
set compiler_name $compiler |
| 95 |
} |
| 96 |
|
| 97 |
# verify that the compiler exists |
| 98 |
if { $compiler_name != 0 } then { |
| 99 |
set tmp [remote_exec host "$compiler -v"] |
| 100 |
set status [lindex $tmp 0] |
| 101 |
set output [lindex $tmp 1] |
| 102 |
regexp "Configured with.*\[\n\r\]" $output config |
| 103 |
set option "*${option}*" |
| 104 |
if { [string match $option $config] } { |
| 105 |
return 1 |
| 106 |
} else { |
| 107 |
return 0 |
| 108 |
} |
| 109 |
} else { |
| 110 |
# compiler does not exist (this should have already been detected) |
| 111 |
warning "$compiler does not exist" |
| 112 |
return 0 |
| 113 |
} |
| 114 |
} |