OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / gcc-dg.exp
1 #   Copyright (C) 1997 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 2 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 this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gcc@prep.ai.mit.edu
19
20 # Define gcc callbacks for dg.exp.
21
22 load_lib dg.exp
23
24 proc gcc-dg-test { prog do_what extra_tool_flags } {
25     # Set up the compiler flags, based on what we're going to do.
26
27     switch $do_what {
28         "preprocess" {
29             set compile_type "preprocess"
30             set output_file "[file rootname [file tail $prog]].i"
31         }
32         "compile" {
33             set compile_type "object"
34             set output_file "[file rootname [file tail $prog]].s"
35         }
36         "assemble" {
37             set compile_type "assembly"
38             set output_file "[file rootname [file tail $prog]].o"
39         }
40         "link" {
41             set compile_type "executable"
42             set output_file "a.out"
43             # The following line is needed for targets like the i960 where
44             # the default output file is b.out.  Sigh.
45         }
46         "run" {
47             set compile_type "executable"
48             # FIXME: "./" is to cope with "." not being in $PATH.
49             # Should this be handled elsewhere?
50             # YES.
51             set output_file "./a.out"
52             # This is the only place where we care if an executable was
53             # created or not.  If it was, dg.exp will try to run it.
54             remote_file build delete $output_file;
55         }
56         default {
57             perror "$do_what: not a valid dg-do keyword"
58             return ""
59         }
60     }
61     set options ""
62     if { $extra_tool_flags != "" } {
63         lappend options "additional_flags=$extra_tool_flags"
64     }
65
66     set comp_output [gcc_target_compile "$prog" "$output_file" "$compile_type" $options];
67
68     return [list $comp_output $output_file]
69 }
70
71
72 proc gcc-dg-prune { system text } {
73     set text [prune_gcc_output $text]
74
75     # If we see "region xxx is full" then the testcase is too big for ram.
76     # This is tricky to deal with in a large testsuite like c-torture so
77     # deal with it here.  Just mark the testcase as unsupported.
78     if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
79         # The format here is important.  See dg.exp.
80         return "::unsupported::memory full"
81     }
82
83     return $text
84 }