OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [lib/] [treelang.exp] - Blame information for rev 844

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004,
2
# 2007 Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with GCC; see the file COPYING3.  If not see
16
# .
17
 
18
# This file was written by Rob Savoye (rob@cygnus.com)
19
# Currently maintained by James A. Morrison (ja2morri@uwaterloo.ca)
20
 
21
# Having this file here magically tells dejagnu that the treelang
22
# directory is worthy of testing
23
 
24
# This file is basically gcc.exp with gcc replaced with treelang.
25
 
26
# This file is loaded by the tool init file (eg: unix.exp).  It provides
27
# default definitions for treelang_start, etc. and other supporting cast
28
# members.
29
 
30
# These globals are used by treelang_start if no compiler arguments are
31
# provided.  They are also used by the various testsuites to define the
32
# environment: where to find stdio.h, libc.a, etc.
33
 
34
load_lib libgloss.exp
35
load_lib prune.exp
36
load_lib gcc-defs.exp
37
load_lib target-libpath.exp
38
 
39
#
40
# TREELANG_UNDER_TEST is the compiler under test.
41
#
42
 
43
#
44
# default_treelang_version -- extract and print the version number of the compiler
45
#
46
 
47
proc default_treelang_version { } {
48
    global TREELANG_UNDER_TEST
49
 
50
    treelang_init
51
 
52
    # ignore any arguments after the command
53
    set compiler [lindex $TREELANG_UNDER_TEST 0]
54
 
55
    if ![is_remote host] {
56
        set compiler_name [which $compiler]
57
    } else {
58
        set compiler_name $compiler
59
    }
60
 
61
    # verify that the compiler exists
62
    if { $compiler_name != 0 } then {
63
        set tmp [remote_exec host "$compiler -v"]
64
        set status [lindex $tmp 0]
65
        set output [lindex $tmp 1]
66
        regexp " version \[^\n\r\]*" $output version
67
        if { $status == 0 && [info exists version] } then {
68
            clone_output "$compiler_name $version\n"
69
        } else {
70
            clone_output "Couldn't determine version of $compiler_name: $output\n"
71
        }
72
    } else {
73
        # compiler does not exist (this should have already been detected)
74
        warning "$compiler does not exist"
75
    }
76
}
77
 
78
# treelang_init -- called at the start of each .exp script.
79
#
80
# There currently isn't much to do, but always using it allows us to
81
# make some enhancements without having to go back and rewrite the scripts.
82
#
83
 
84
set treelang_initialized 0
85
 
86
proc treelang_init { args } {
87
    global tmpdir
88
    global libdir
89
    global gluefile wrap_flags
90
    global treelang_initialized
91
    global TREELANG_UNDER_TEST
92
    global TOOL_EXECUTABLE
93
    global treelang_libgcc_s_path
94
 
95
 
96
    # We set LC_ALL and LANG to C so that we get the same error messages as expected.
97
    setenv LC_ALL C
98
    setenv LANG C
99
 
100
 
101
    if { $treelang_initialized == 1 } { return; }
102
 
103
    if ![info exists TREELANG_UNDER_TEST] then {
104
        if [info exists TOOL_EXECUTABLE] {
105
            set TREELANG_UNDER_TEST $TOOL_EXECUTABLE
106
        } else {
107
            set TREELANG_UNDER_TEST [find_gcc]
108
        }
109
    }
110
 
111
    if ![info exists tmpdir] then {
112
        set tmpdir /tmp
113
    }
114
 
115
    treelang_maybe_build_wrapper "${tmpdir}/treelang-testglue.o"
116
 
117
    set treelang_libgcc_s_path \
118
        [gcc-set-multilib-library-path $TREELANG_UNDER_TEST]
119
}
120
 
121
proc treelang_target_compile { source dest type options } {
122
    global rootme
123
    global tmpdir
124
    global gluefile wrap_flags
125
    global srcdir
126
    global TREELANG_UNDER_TEST
127
    global TOOL_OPTIONS
128
    global ld_library_path
129
    global treelang_libgcc_s_path
130
 
131
    set ld_library_path ".:${treelang_libgcc_s_path}"
132
    set_ld_library_path_env_vars
133
 
134
    if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
135
        lappend options "libs=${gluefile}"
136
        lappend options "ldflags=$wrap_flags"
137
    }
138
 
139
    # TOOL_OPTIONS must come first, so that it doesn't override testcase
140
    # specific options.
141
    if [info exists TOOL_OPTIONS] {
142
        set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
143
    }
144
 
145
    # If we have built libtreelang along with the compiler (which usually
146
    # _is not_ the case on Mac OS X systems), point the test harness
147
    # at it (and associated headers).
148
 
149
    return [target_compile $source $dest $type $options]
150
}
151
 
152
#
153
# treelang_pass -- utility to record a testcase passed
154
#
155
 
156
proc treelang_pass { testcase cflags } {
157
    if { "$cflags" == "" } {
158
        pass "$testcase"
159
    } else {
160
        pass "$testcase, $cflags"
161
    }
162
}
163
 
164
#
165
# treelang_fail -- utility to record a testcase failed
166
#
167
 
168
proc treelang_fail { testcase cflags } {
169
    if { "$cflags" == "" } {
170
        fail "$testcase"
171
    } else {
172
        fail "$testcase, $cflags"
173
    }
174
}
175
 
176
#
177
# treelang_finish -- called at the end of every .exp script that calls treelang_init
178
#
179
# The purpose of this proc is to hide all quirks of the testing environment
180
# from the testsuites.  It also exists to undo anything that treelang_init did
181
# (that needs undoing).
182
#
183
 
184
proc treelang_finish { } {
185
    # The testing harness apparently requires this.
186
    global errorInfo
187
 
188
    if [info exists errorInfo] then {
189
        unset errorInfo
190
    }
191
 
192
    # Might as well reset these (keeps our caller from wondering whether
193
    # s/he has to or not).
194
    global prms_id bug_id
195
    set prms_id 0
196
    set bug_id 0
197
}
198
 
199
proc treelang_exit { } {
200
    global gluefile
201
 
202
    if [info exists gluefile] {
203
        file_on_build delete $gluefile
204
        unset gluefile
205
    }
206
}
207
 
208
# If this is an older version of dejagnu (without runtest_file_p),
209
# provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
210
# This can be deleted after next dejagnu release.
211
 
212
if { [info procs runtest_file_p] == "" } then {
213
    proc runtest_file_p { runtests testcase } {
214
        if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
215
            if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
216
                return 1
217
            } else {
218
                return 0
219
            }
220
        }
221
        return 1
222
    }
223
}
224
 
225
# Provide a definition of this if missing (delete after next dejagnu release).
226
 
227
if { [info procs prune_warnings] == "" } then {
228
    proc prune_warnings { text } {
229
        return $text
230
    }
231
}
232
 
233
# Utility used by mike-gcc.exp and c-torture.exp.
234
# Check the compiler(/assembler/linker) output for text indicating that
235
# the testcase should be marked as "unsupported".
236
#
237
# When dealing with a large number of tests, it's difficult to weed out the
238
# ones that are too big for a particular cpu (eg: 16 bit with a small amount
239
# of memory).  There are various ways to deal with this.  Here's one.
240
# Fortunately, all of the cases where this is likely to happen will be using
241
# gld so we can tell what the error text will look like.
242
 
243
proc ${tool}_check_unsupported_p { output } {
244
    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
245
        return "memory full"
246
    }
247
    return ""
248
}
249
 
250
# Prune messages from treelang that aren't useful.
251
 
252
proc prune_treelang_output { text } {
253
    #send_user "Before:$text\n"
254
    regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
255
    regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
256
 
257
    # It would be nice to avoid passing anything to treelang that would cause it to
258
    # issue these messages (since ignoring them seems like a hack on our part),
259
    # but that's too difficult in the general case.  For example, sometimes
260
    # you need to use -B to point treelang at crt0.o, but there are some targets
261
    # that don't have crt0.o.
262
    regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
263
    regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
264
 
265
    #send_user "After:$text\n"
266
 
267
    return $text
268
}
269
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.