1# Copyright (C) 2009-2021 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 17load_lib gcc-dg.exp 18 19# Define go callbacks for dg.exp. 20 21proc go-dg-test { prog do_what extra_tool_flags } { 22 set result \ 23 [gcc-dg-test-1 go_target_compile $prog $do_what $extra_tool_flags] 24 25 set comp_output [lindex $result 0] 26 set output_file [lindex $result 1] 27 28 return [list $comp_output $output_file] 29} 30 31proc go-dg-prune { system text } { 32 return [gcc-dg-prune $system $text] 33} 34 35# Utility routines. 36 37# Modified dg-runtest that can cycle through a list of optimization options 38# as c-torture does. 39proc go-dg-runtest { testcases flags default-extra-flags } { 40 global runtests 41 global TORTURE_OPTIONS 42 43 foreach test $testcases { 44 # If we're only testing specific files and this isn't one of 45 # them, skip it. 46 if ![runtest_file_p $runtests $test] { 47 continue 48 } 49 50 # look if this is dg-do-run test, in which case 51 # we cycle through the option list, otherwise we don't 52 if [expr [search_for $test "dg-do run"]] { 53 set option_list $TORTURE_OPTIONS 54 } else { 55 set option_list [list { -O } ] 56 } 57 58 set nshort [file tail [file dirname $test]]/[file tail $test] 59 60 foreach flags_t $option_list { 61 verbose "Testing $nshort, $flags $flags_t" 1 62 dg-test $test "$flags $flags_t" ${default-extra-flags} 63 } 64 } 65} 66