]>
Commit | Line | Data |
---|---|---|
a5544970 | 1 | # Copyright (C) 2008-2019 Free Software Foundation, Inc. |
84ab8b8a GJL |
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 | # GCC testsuite that uses the `dg.exp' driver. | |
18 | ||
19 | # This folder contains compile tests that set dg-options to | |
20 | # some -mmcu=<MCU> which might collide with the MCU set by the | |
21 | # target board. This in turn will fail the test case due to | |
22 | # "error: specified option '-mmcu' more than once". | |
23 | # | |
24 | # Hence we filter out -mmcu= from cflags and --tool_opts before | |
25 | # running the tests in this folder. | |
26 | ||
27 | # Exit immediately if this isn't an AVR target. | |
28 | if ![istarget avr-*-*] then { | |
29 | return | |
30 | } | |
31 | ||
32 | # Return the saved values of the variable_list | |
33 | proc save_variables { variable_list } { | |
34 | set saved_variable { } | |
35 | ||
36 | foreach variable $variable_list { | |
37 | upvar 1 $variable var | |
38 | ||
39 | set save($variable) $var | |
40 | lappend saved_variable $save($variable) | |
41 | } | |
42 | return $saved_variable | |
43 | } | |
44 | ||
45 | # Restore the values of the variable_list | |
46 | proc restore_variables { variable_list saved_variable } { | |
47 | foreach variable $variable_list value $saved_variable { | |
48 | upvar 1 $variable var | |
49 | set var $value | |
50 | } | |
51 | } | |
52 | ||
53 | # Filter out -mmcu= options | |
54 | proc filter_out_mmcu { options } { | |
55 | set reduced {} | |
56 | ||
57 | foreach option [ split $options ] { | |
58 | if { ![ regexp "\-mmcu=.*" $option ] } { | |
59 | lappend reduced $option | |
60 | } | |
61 | } | |
62 | ||
63 | return [ join $reduced " " ] | |
64 | } | |
65 | ||
66 | # Load support procs. | |
67 | load_lib gcc-dg.exp | |
68 | ||
69 | # If a testcase doesn't have special options, use these. | |
70 | global DEFAULT_CFLAGS | |
71 | if ![info exists DEFAULT_CFLAGS] then { | |
72 | set DEFAULT_CFLAGS " -ansi -pedantic-errors" | |
73 | } | |
74 | ||
75 | # If no --tool_opts were specified, use empty ones. | |
76 | if ![info exists TOOL_OPTIONS] then { | |
77 | set TOOL_OPTIONS "" | |
78 | } | |
79 | ||
80 | # Initialize `dg'. | |
81 | dg-init | |
82 | ||
83 | # Save | |
84 | set variablelist [ list TOOL_OPTIONS board_info([target_info name],cflags) ] | |
85 | set saved_value [ save_variables $variablelist ] | |
86 | ||
87 | # Filter-out -mmcu= | |
88 | set TOOL_OPTIONS [ filter_out_mmcu $TOOL_OPTIONS ] | |
89 | set board_info([ target_info name ],cflags) [ filter_out_mmcu $board_info([ target_info name ],cflags) ] | |
90 | ||
91 | # Main loop. | |
92 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cCS\],cpp}]] \ | |
93 | "" $DEFAULT_CFLAGS | |
94 | ||
95 | # Restore | |
96 | restore_variables $variablelist $saved_value | |
97 | ||
98 | set dg_runtest_extra_prunes "" | |
99 | ||
100 | # All done. | |
101 | dg-finish |