OSDN Git Service

1d4b779fe118294ce0928c93b74e6103156ea3c8
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.misc-tests / options.exp
1 # Copyright (C) 2005, 2007 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 # Run the LANGUAGE compiler with GCC_OPTIONS and inspect the compiler,
18 # assembler and linker output (from gcc -v) to make sure that they
19 # match the patterns COMPILER_PATTERN, AS_PATTERN and LD_PATTERN,
20 # respectively.
21
22 proc check_for_options {language gcc_options compiler_pattern as_pattern ld_pattern} {
23     set filename test-[pid]
24     set fd [open $filename.c w]
25     puts $fd "int main (void) \{ return 0; \}"
26     close $fd
27     remote_download host $filename.c
28
29     set test "compiler driver $gcc_options option(s)"
30     set gcc_options "\{additional_flags=$gcc_options -v\}"
31
32     switch "$language" {
33         "c" { set compiler cc1 }
34         default { error "unknown language" }
35     }
36     set gcc_output [gcc_target_compile $filename.c $filename.x executable $gcc_options]
37     remote_file build delete $filename.c $filename.x $filename.gcno
38
39     if {![regexp -- "/${compiler}(\\.exe)? -quiet.*$compiler_pattern" $gcc_output]} {
40         fail "$test (compiler options)"
41         return
42     }
43     if {![regexp -- " *as(\\.exe)? .*$as_pattern" $gcc_output]} {
44         fail "$test (assembler options)"
45         return
46     }
47     if {![regexp -- "/collect2(\\.exe)? .*$ld_pattern" $gcc_output]} {
48         fail "$test (linker options)"
49         return
50     }
51     pass $test
52 }
53
54 check_for_options c {--coverage} {-fprofile-arcs -ftest-coverage} {} {-lgcov}