blob: cc01575a92f389a1260567d68d8794767adb709a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# Copyright (C) 2008-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# Prepare to use a new set of torture options.
#
# Letting options leak from one set of tests to another can be confusing.
# Make sure variables are not set at the time we're called, because that
# would mean they were set without being cleared.
proc torture-init { args } {
global torture_without_loops global_with_loops
if [info exists torture_without_loops] {
error "torture-init: torture_without_loops is not empty as expected"
}
if [info exists torture_with_loops] {
error "torture-init: torture_with_loops is not empty as expected"
}
}
# Return 1 if torture options have already been set, 0 otherwise.
proc torture-options-exist { args } {
global torture_with_loops
return [info exists torture_with_loops]
}
# Return 1 if compiler option ARG only affects loops, 0 otherwise.
proc contains-loop-option-p { arg } {
switch -glob -- $arg {
"*loop*" { return 1 }
default { return 0 }
}
}
# Set torture options variables for tests with and without loops.
#
# Argument 0 is the list to use as torture options
# Argument 1 is the list to combine with the torture options.
# Argument 2 is the list to be appended to the torture options after
# combining argument 0 and 1.
proc set-torture-options { args } {
global torture_with_loops torture_without_loops
set torture_list [lindex $args 0]
if { [llength $args] > 1 } {
set other_list [lindex $args 1]
} else {
set other_list [list {}]
}
set torture_with_loops ""
set torture_without_loops ""
foreach torture_opts $torture_list {
foreach other_opts $other_list {
# Remove trailing space[s] to match previous output.
set torture_opts [string trimright $torture_opts]
if ![contains-loop-option-p $torture_opts] {
lappend torture_without_loops "$torture_opts $other_opts"
}
lappend torture_with_loops "$torture_opts $other_opts"
}
}
if { [llength $args] > 2 } {
set append_list [lindex $args 2]
append torture_with_loops " $append_list"
append torture_without_loops " $append_list"
}
}
# Finish up after using a set of torture options.
#
# Letting options leak from one set of tests to another can be confusing.
# Make sure variables are set at the time we're called, and then unset
# them to prevent interference with other sets of tests.
proc torture-finish { args } {
global torture_without_loops torture_with_loops
if [info exists torture_without_loops] {
unset torture_without_loops
} else {
error "torture-finish: torture_without_loops is not defined"
}
if [info exists torture_with_loops] {
unset torture_with_loops
} else {
error "torture-finish: torture_with_loops is not defined"
}
}
# Useful for debugging .exp files.
proc dump-torture-options { args } {
global torture_without_loops torture_with_loops
if [info exists torture_without_loops] {
verbose "torture_without_loops = \"${torture_without_loops}\"" 1
} else {
verbose "torture_without_loops is not defined" 1
}
if [info exists torture_with_loops] {
verbose "torture_with_loops = \"${torture_with_loops}\"" 1
} else {
verbose "torture_with_loops is not defined" 1
}
}
|