Debian Codegraph @

gcc/testsuite/lib/gdc-dg.exp

raw
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 gdc callbacks for dg.exp.
20
21 proc gdc-dg-test { prog do_what extra_tool_flags } {
22 upvar dg-do-what dg-do-what
23
24 # Demote link and run tests to compile-only if D runtime is missing.
25 if ![check_effective_target_d_runtime] {
26 switch $do_what {
27 link -
28 run {
29 set do_what compile
30 set dg-do-what compile
31 }
32 }
33 }
34
35 # Strip gdc.test prefix off test names to avoid pathname failures in
36 # some tests.
37 set prog [dg-trim-dirname gdc.test $prog]
38
39 set result \
40 [gcc-dg-test-1 gdc_target_compile $prog $do_what $extra_tool_flags]
41
42 set comp_output [lindex $result 0]
43 set output_file [lindex $result 1]
44
45 return [list $comp_output $output_file]
46 }
47
48 proc gdc-dg-prune { system text } {
49 return [gcc-dg-prune $system $text]
50 }
51
52 # Utility routines.
53
54 #
55 # Modified dg-runtest that can cycle through a list of optimization options
56 # as c-torture does.
57 #
58
59 proc gdc-dg-runtest { testcases flags default-extra-flags } {
60 global runtests
61
62 foreach test $testcases {
63 # If we're only testing specific files and this isn't one of
64 # them, skip it.
65 if ![runtest_file_p $runtests $test] {
66 continue
67 }
68
69 # Use TORTURE_OPTIONS to cycle through an option list.
70 if [torture-options-exist] then {
71 global torture_with_loops
72 set option_list $torture_with_loops
73 } else {
74 set option_list { "" }
75 }
76
77 set nshort [file tail [file dirname $test]]/[file tail $test]
78
79 foreach flags_t $option_list {
80 verbose "Testing $nshort, $flags $flags_t" 1
81 dg-test $test "$flags $flags_t" ${default-extra-flags}
82 }
83 }
84 }
85
86 #
87 # gdc_load -- wrapper around default gdc_load to handle tests that
88 # require program arguments passed to them.
89 #
90
91 if { [info procs gdc_load] != [list] \
92 && [info procs prev_gdc_load] == [list] } {
93 rename gdc_load prev_gdc_load
94
95 proc gdc_load { program args } {
96 global GDC_EXECUTE_ARGS
97 if [info exists GDC_EXECUTE_ARGS] then {
98 set args [concat "{$GDC_EXECUTE_ARGS}"]
99 }
100 #print "Running: $program [lindex $args 0]"
101 set result [eval [list prev_gdc_load $program] $args ]
102 return $result
103 }
104 }
105