| 1 |
# Copyright (C) 2004-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 torture-options.exp |
| 19 |
|
| 20 |
# Define cobol callbacks for dg.exp. |
| 21 |
|
| 22 |
proc cobol-dg-test { prog do_what extra_tool_flags } { |
| 23 |
set result \ |
| 24 |
[gcc-dg-test-1 cobol_target_compile $prog $do_what $extra_tool_flags] |
| 25 |
|
| 26 |
set comp_output [lindex $result 0] |
| 27 |
set output_file [lindex $result 1] |
| 28 |
|
| 29 |
return [list $comp_output $output_file] |
| 30 |
} |
| 31 |
|
| 32 |
proc cobol-dg-prune { system text } { |
| 33 |
# cobol prints an extra stray error at the end when compilation fails |
| 34 |
regsub -all "(^|\n)cobol1: error: failed compiling \[^\n\]*" $text "" text |
| 35 |
return [gcc-dg-prune $system $text] |
| 36 |
} |
| 37 |
|
| 38 |
# Utility routines. |
| 39 |
|
| 40 |
# Modified dg-runtest that can cycle through a list of optimization options |
| 41 |
# as c-torture does. |
| 42 |
proc cobol-dg-runtest { testcases flags default-extra-flags } { |
| 43 |
global runtests |
| 44 |
global torture_with_loops |
| 45 |
|
| 46 |
# Some callers initialize torture testing themselves; don't override those. |
| 47 |
set existing_torture_init [torture-init-done] |
| 48 |
if { $existing_torture_init == 0 } { |
| 49 |
torture-init |
| 50 |
} |
| 51 |
# Some callers set torture options themselves; don't override those. |
| 52 |
set existing_torture_options [torture-options-exist] |
| 53 |
if { $existing_torture_options == 0 } { |
| 54 |
global DG_TORTURE_OPTIONS |
| 55 |
set-torture-options $DG_TORTURE_OPTIONS |
| 56 |
} |
| 57 |
dump-torture-options |
| 58 |
|
| 59 |
foreach test $testcases { |
| 60 |
# If we're only testing specific files and this isn't one of |
| 61 |
# them, skip it. |
| 62 |
if ![runtest_file_p $runtests $test] { |
| 63 |
continue |
| 64 |
} |
| 65 |
|
| 66 |
# look if this is dg-do run test, in which case |
| 67 |
# we cycle through the option list, otherwise we don't |
| 68 |
if [expr [search_for $test "dg-do run"]] { |
| 69 |
set option_list $torture_with_loops |
| 70 |
} else { |
| 71 |
set option_list [list { -O } ] |
| 72 |
} |
| 73 |
|
| 74 |
set nshort [file tail [file dirname $test]]/[file tail $test] |
| 75 |
|
| 76 |
foreach flags_t $option_list { |
| 77 |
verbose "Testing $nshort, $flags $flags_t" 1 |
| 78 |
dg-test $test "$flags $flags_t" ${default-extra-flags} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
if { $existing_torture_init == 0 } { |
| 83 |
torture-finish |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
proc check_effective_target_cobol {} { |
| 88 |
# Check if the COBOL FE can compile trivial programs. |
| 89 |
return [check_no_compiler_messages cobol assembly { |
| 90 |
*> COBOL |
| 91 |
IDENTIFICATION DIVISION. |
| 92 |
PROGRAM-ID. pass. |
| 93 |
PROCEDURE DIVISION. |
| 94 |
STOP RUN. |
| 95 |
}] |
| 96 |
} |