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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [testsuite/] [sim/] [cris/] [c/] [c.exp] - Blame information for rev 834

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

Line No. Rev Author Line
1 227 jeremybenn
# Copyright (C) 2005, 2007, 2008, 2009, 2010 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 this program.  If not, see .
15
 
16
# Miscellaneous CRIS simulator testcases testing syscall sequences.
17
 
18
if ![istarget cris*-*-*] {
19
    return
20
}
21
 
22
set CFLAGS_FOR_TARGET "-O2"
23
if [istarget cris-*-*] {
24
    set mach "crisv10"
25
} {
26
    set mach "crisv32"
27
}
28
 
29
# Using target_compile, since it is less noisy,
30
if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
31
          "executable" "" ] == "" } {
32
    set has_cc 1
33
 
34
    # Now check if we can link a program dynamically, and where
35
    # libc.so is located.  If it is, we provide a sym link to the
36
    # directory (which must end in /lib) in [pwd], so /lib/ld.so.1 is
37
    # found (which must reside along libc.so).  We don't bother
38
    # replacing the board ldflags like below as we don't care about
39
    # detrimental effects on the executable from the specs and
40
    # -static in the board ldflags, we just add -Bdynamic.
41
    if [regexp "(.*/lib)/libc.so" \
42
            [target_compile $srcdir/$subdir/hello.c compilercheck.x \
43
                 "executable" \
44
                 "ldflags=-print-file-name=libc.so -Wl,-Bdynamic"] \
45
            xxx libcsodir]  {
46
        file delete lib
47
        verbose -log "Creating link to $libcsodir in [pwd]"
48
        file link lib $libcsodir
49
    }
50
} {
51
    verbose -log "Can't execute C compiler"
52
    set has_cc 0
53
}
54
 
55
# Like istarget, except take a list of targets as a string.
56
proc anytarget { targets } {
57
    set targetlist [split $targets]
58
    set argc [llength $targetlist]
59
    for { set i 0 } { $i < $argc } { incr i } {
60
        if [istarget [lindex $targetlist $i]] {
61
            return 1
62
        }
63
    }
64
    return 0
65
}
66
 
67
foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
68
    set orig_ldflags ""
69
 
70
    if ![runtest_file_p $runtests $src] {
71
        continue
72
    }
73
    set testname "[file tail $src]"
74
 
75
    set opt_array [slurp_options $src]
76
    if { $opt_array == -1 } {
77
        unresolved $testname
78
        return
79
    }
80
 
81
    # And again, to simplify specifying tests.
82
    if ![runtest_file_p $runtests $src] {
83
        continue
84
    }
85
 
86
    # Note absence of CC in results, but don't make a big fuss over it.
87
    if { $has_cc == 0 } {
88
        untested $testname
89
        continue
90
    }
91
 
92
    # Clear default options
93
    set opts(cc) ""
94
    set opts(sim) ""
95
    set opts(output) ""
96
    set opts(progoptions) ""
97
    set opts(timeout) ""
98
    set opts(mach) ""
99
    set opts(xerror) "no"
100
    set opts(dest) "$testname.x"
101
    set opts(simenv) ""
102
    set opts(kfail) ""
103
    set opts(xfail) ""
104
    set opts(target) ""
105
    set opts(notarget) ""
106
    set opts(dynamic) ""
107
 
108
    # Clear any machine specific options specified in a previous test case
109
    if [info exists opts(sim,$mach)] {
110
        unset opts(sim,$mach)
111
    }
112
 
113
    foreach i $opt_array {
114
        set opt_name [lindex $i 0]
115
        set opt_machs [lindex $i 1]
116
        set opt_val [lindex $i 2]
117
        if ![info exists opts($opt_name)] {
118
            perror "unknown option $opt_name in file $src"
119
            unresolved $testname
120
            return
121
        }
122
 
123
        # Replace specific substitutions:
124
        # @exedir@ is where the test-program is located.
125
        regsub -all "@exedir@" $opt_val "[pwd]" opt_val
126
        # @srcdir@ is where the source of the test-program is located.
127
        regsub -all "@srcdir@" $opt_val "$srcdir/$subdir" opt_val
128
 
129
        # Multiple of these options concatenate, they don't override.
130
        if { $opt_name == "output" || $opt_name == "progoptions" } {
131
            set opt_val "$opts($opt_name)$opt_val"
132
        }
133
 
134
        # Similar with "xfail", "kfail", "target" and "notarget", but
135
        # arguments are space-separated.
136
        if { $opt_name == "xfail" || $opt_name == "kfail" \
137
                 || $opt_name == "target"  || $opt_name == "notarget" } {
138
            if { $opts($opt_name) != "" } {
139
                set opt_val "$opts($opt_name) $opt_val"
140
            }
141
        }
142
 
143
        if { $opt_name == "dynamic" \
144
                 && [info exists board_info([target_info name],ldflags)] } {
145
            # Weed out -static from ldflags, but keep the original in
146
            # $orig_ldflags.
147
            set orig_ldflags $board_info([target_info name],ldflags)
148
            set ldflags " $orig_ldflags "
149
            regsub -all " -static " $ldflags " " ldflags
150
            set board_info([target_info name],ldflags) $ldflags
151
        }
152
 
153
        foreach m $opt_machs {
154
            set opts($opt_name,$m) $opt_val
155
        }
156
        if { "$opt_machs" == "" } {
157
            set opts($opt_name) $opt_val
158
        }
159
    }
160
 
161
    if { $opts(output) == "" } {
162
        if { "$opts(xerror)" == "no" } {
163
            set opts(output) "pass\n"
164
        } else {
165
            set opts(output) "fail\n"
166
        }
167
    }
168
 
169
    if { $opts(target) != "" && ![anytarget $opts(target)] } {
170
        continue
171
    }
172
 
173
    if { $opts(notarget) != "" && [anytarget $opts(notarget)] } {
174
        continue
175
    }
176
 
177
    # If no machine specific options, default to the general version.
178
    if ![info exists opts(sim,$mach)] {
179
        set opts(sim,$mach) $opts(sim)
180
    }
181
 
182
    # Change \n sequences to newline chars.
183
    regsub -all "\\\\n" $opts(output) "\n" opts(output)
184
 
185
    verbose -log "Compiling $src with $opts(cc)"
186
 
187
    set dest "$opts(dest)"
188
    if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } {
189
        unresolved $testname
190
        continue
191
    }
192
 
193
    if { $orig_ldflags != "" } {
194
        set board_info([target_info name],ldflags) $orig_ldflags
195
    }
196
 
197
    verbose -log "Simulating $src with $opts(sim,$mach)"
198
 
199
    # Time to setup xfailures and kfailures.
200
    if { "$opts(xfail)" != "" } {
201
        verbose -log "xfail: $opts(xfail)"
202
        # Using eval to make $opts(xfail) appear as individual
203
        # arguments.
204
        eval setup_xfail $opts(xfail)
205
    }
206
    if { "$opts(kfail)" != "" } {
207
        verbose -log "kfail: $opts(kfail)"
208
        eval setup_kfail $opts(kfail)
209
    }
210
 
211
    set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \
212
        "" "$opts(simenv)"]
213
    set status [lindex $result 0]
214
    set output [lindex $result 1]
215
 
216
    if { "$status" == "pass" } {
217
        if { "$opts(xerror)" == "no" } {
218
            if [string match $opts(output) $output] {
219
                pass "$mach $testname"
220
            } else {
221
                verbose -log "output:  $output" 3
222
                verbose -log "pattern: $opts(output)" 3
223
                fail "$mach $testname (execution)"
224
            }
225
        } else {
226
            verbose -log "`pass' return code when expecting failure" 3
227
            fail "$mach $testname (execution)"
228
        }
229
    } elseif { "$status" == "fail" } {
230
        if { "$opts(xerror)" == "no" } {
231
            fail "$mach $testname (execution)"
232
        } else {
233
            if [string match $opts(output) $output] {
234
                pass "$mach $testname"
235
            } else {
236
                verbose -log "output:  $output" 3
237
                verbose -log "pattern: $opts(output)" 3
238
                fail "$mach $testname (execution)"
239
            }
240
        }
241
    } else {
242
        $status "$mach $testname"
243
    }
244
}

powered by: WebSVN 2.1.0

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