]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/lib/options.exp
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / lib / options.exp
CommitLineData
f1717362 1# Copyright (C) 2009-2016 Free Software Foundation, Inc.
fcdee8f1 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# We set LC_ALL and LANG to C so that we get the same error messages as expected.
18setenv LC_ALL C
19setenv LANG C
20
9cf0a538 21# Many hosts now default to a non-ASCII C locale, however, so
22# they can set a charset encoding here if they need.
23if { [ishost "*-*-cygwin*"] } {
24 setenv LC_ALL C.ASCII
25 setenv LANG C.ASCII
26}
27
fcdee8f1 28# Run the LANGUAGE compiler with GCC_OPTIONS and inspect the compiler
29# output to make sure that they match the newline-separated patterns
30# in COMPILER_PATTERNS but not the patterns in COMPILER_NON_PATTERNS.
31# In case of failure, xfail if XFAIL is nonempty.
32
33proc check_for_options {language gcc_options compiler_patterns compiler_non_patterns expected_failure} {
34 set filename test-[pid]
35 set fd [open $filename.c w]
36 puts $fd "int main (void) { return 0; }"
37 close $fd
38 remote_download host $filename.c
39
40 set test "compiler driver $gcc_options option(s):"
41 set gcc_options "\{additional_flags=$gcc_options\}"
42
43 switch "$language" {
44 "c" { set compiler cc1 }
45 default { error "unknown language" }
46 }
47 set gcc_output [gcc_target_compile $filename.c $filename.x executable $gcc_options]
48 remote_file build delete $filename.c $filename.x $filename.gcno
49
8fb42bbc 50 # Verify that COMPILER_PATTERRNS appear in gcc output.
fcdee8f1 51 foreach pattern [split $compiler_patterns "\n"] {
a68c4c50 52 if {$pattern != ""} {
377ecba0 53 if {[regexp -line -- "$pattern" $gcc_output]} {
fcdee8f1 54 pass "$test $pattern"
55 } else {
a68c4c50 56 if {$expected_failure != ""} {
8fb42bbc 57 xfail "$test \"$pattern\" present in output"
fcdee8f1 58 } else {
8fb42bbc 59 fail "$test \"$pattern\" present in output"
fcdee8f1 60 }
61 }
62 }
63 }
8fb42bbc 64
65 # Verify that COMPILER_NON_PATTERRNS do not appear in gcc output.
fcdee8f1 66 foreach pattern [split $compiler_non_patterns "\n"] {
a68c4c50 67 if {$pattern != ""} {
377ecba0 68 if {![regexp -line -- "$pattern" $gcc_output result]} {
fcdee8f1 69 pass "$test $pattern"
70 } else {
a68c4c50 71 if {$expected_failure != ""} {
8fb42bbc 72 xfail "$test \"$pattern\" absent from output"
fcdee8f1 73 } else {
377ecba0 74 # Print the unexpected line that caused the failure
75 # to make it easier to find in the multiline output.
76 fail "$test \"$pattern\" absent from output: \"$result\""
fcdee8f1 77 }
78 }
79 }
80 }
81}