OSDN Git Service

* lib/target-libpath.exp (set_ld_library_path_env_vars):
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / torture-options.exp
1 # Copyright (C) 2008 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 # Prepare to use a new set of torture options. 
18 #
19 # Letting options leak from one set of tests to another can be confusing.
20 # Make sure variables are not set at the time we're called, because that
21 # would mean they were set without being cleared.
22 proc torture-init { args } {
23     global torture_without_loops global_with_loops
24
25     if [info exists torture_without_loops] {
26         error "torture-init: torture_without_loops is not empty as expected"
27     }
28     if [info exists torture_with_loops] {
29         error "torture-init: torture_with_loops is not empty as expected"
30     }
31 }
32
33 # Return 1 if torture options have already been set, 0 otherwise.
34 proc torture-options-exist { args } {
35     global torture_with_loops
36     return [info exists torture_with_loops]
37 }
38
39 # Return 1 if compiler option ARG only affects loops, 0 otherwise.
40 proc contains-loop-option-p { arg } {
41     switch -glob -- $arg {
42       "*loop*"          { return 1 }
43       default           { return 0 }
44     }
45 }
46
47 # Set torture options variables for tests with and without loops.
48 #
49 # Argument 0 is the list to use as torture options
50 # Argument 1 is the list to combine with the torture options.
51 proc set-torture-options { args } {
52     global torture_with_loops torture_without_loops
53
54     set torture_list [lindex $args 0]
55
56     if { [llength $args] != 1 } {
57         set other_list [lindex $args 1]
58     } else {
59         set other_list [list {}]
60     }
61
62     set torture_with_loops ""
63     set torture_without_loops ""
64     foreach torture_opts $torture_list {
65         foreach other_opts $other_list {
66             # Remove trailing space[s] to match previous output.
67             set torture_opts [string trimright $torture_opts]
68             if ![contains-loop-option-p $torture_opts] {
69                 lappend torture_without_loops "$torture_opts $other_opts"
70             }
71             lappend torture_with_loops "$torture_opts $other_opts"
72         }
73     }
74 }
75
76 # Finish up after using a set of torture options.
77 #
78 # Letting options leak from one set of tests to another can be confusing.
79 # Make sure variables are set at the time we're called, and then unset
80 # them to prevent interference with other sets of tests.
81 proc torture-finish { args } {
82     global torture_without_loops torture_with_loops
83
84     if [info exists torture_without_loops] {
85         unset torture_without_loops
86     } else {
87         error "torture-finish: torture_without_loops is not defined"
88     }
89
90     if [info exists torture_with_loops] {
91         unset torture_with_loops
92     } else {
93         error "torture-finish: torture_with_loops is not defined"
94     }
95 }
96
97 # Useful for debugging .exp files.
98 proc dump-torture-options { args } {
99     global torture_without_loops torture_with_loops
100
101     if [info exists torture_without_loops] {
102         verbose "torture_without_loops = \"${torture_without_loops}\"" 1
103     } else {
104         verbose "torture_without_loops is not defined" 1
105     }
106
107     if [info exists torture_with_loops] {
108         verbose "torture_with_loops = \"${torture_with_loops}\"" 1
109     } else {
110         verbose "torture_with_loops is not defined" 1
111     }
112 }