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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.gdb/] [xfullpath.exp] - Blame information for rev 231

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

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
2
# 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 this program.  If not, see .
16
 
17
# This file was written by Joel Brobecker. (brobecker@gnat.com), derived
18
# from selftest.exp, written by Rob Savoye.
19
 
20
if $tracelevel then {
21
    strace $tracelevel
22
}
23
 
24
set prms_id 0
25
set bug_id 0
26
 
27
# are we on a target board
28
if { [is_remote target] || ![isnative] } then {
29
    return
30
}
31
 
32
proc setup_test { executable } {
33
    global gdb_prompt
34
    global timeout
35
 
36
    # load yourself into the debugger
37
    # This can take a relatively long time, particularly for testing where
38
    # the executable is being accessed over a network, or where gdb does not
39
    # support partial symbols for a particular target and has to load the
40
    # entire symbol table.  Set the timeout to 10 minutes, which should be
41
    # adequate for most environments (it *has* timed out with 5 min on a
42
    # SPARCstation SLC under moderate load, so this isn't unreasonable).
43
    # After gdb is started, set the timeout to 30 seconds for the duration
44
    # of this test, and then back to the original value.
45
 
46
    set oldtimeout $timeout
47
    set timeout 600
48
    verbose "Timeout is now $timeout seconds" 2
49
 
50
    global gdb_file_cmd_debug_info
51
    set gdb_file_cmd_debug_info "unset"
52
 
53
    set result [gdb_load $executable]
54
    set timeout $oldtimeout
55
    verbose "Timeout is now $timeout seconds" 2
56
 
57
    if { $result != 0 } then {
58
        return -1
59
    }
60
 
61
    if { $gdb_file_cmd_debug_info != "debug" } then {
62
        untested "No debug information, skipping testcase."
63
        return -1
64
    }
65
 
66
    # Set a breakpoint at main
67
    gdb_test "break captured_main" \
68
            "Breakpoint.*at.* file.*, line.*" \
69
            "breakpoint in captured_main"
70
 
71
    # run yourself
72
    # It may take a very long time for the inferior gdb to start (lynx),
73
    # so we bump it back up for the duration of this command.
74
    set timeout 600
75
 
76
    set description "run until breakpoint at captured_main"
77
    send_gdb "run -nw\n"
78
    gdb_expect {
79
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
80
            pass "$description"
81
        }
82
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" {
83
            xfail "$description (line numbers scrambled?)"
84
        }
85
        -re "vfork: No more processes.*$gdb_prompt $" {
86
            fail "$description (out of virtual memory)"
87
            set timeout $oldtimeout
88
            verbose "Timeout is now $timeout seconds" 2
89
            return -1
90
        }
91
        -re ".*$gdb_prompt $" {
92
            fail "$description"
93
            set timeout $oldtimeout
94
            verbose "Timeout is now $timeout seconds" 2
95
            return -1
96
        }
97
        timeout {
98
            fail "$description (timeout)"
99
        }
100
    }
101
 
102
    set timeout $oldtimeout
103
    verbose "Timeout is now $timeout seconds" 2
104
 
105
    return 0
106
}
107
 
108
proc test_with_self { executable } {
109
 
110
    set setup_result [setup_test $executable]
111
    if {$setup_result <0} then {
112
        return -1
113
    }
114
 
115
    # A file which contains a directory prefix
116
    gdb_test "print xfullpath (\"./xfullpath.exp\")" \
117
             ".\[0-9\]+ =.*\".*/xfullpath.exp\"" \
118
             "A filename with ./ as the directory prefix"
119
 
120
    # A file which contains a directory prefix
121
    gdb_test "print xfullpath (\"../../defs.h\")" \
122
             ".\[0-9\]+ =.*\".*/defs.h\"" \
123
             "A filename with ../ in the directory prefix"
124
 
125
    # A one-character filename
126
    gdb_test "print xfullpath (\"./a\")" \
127
             ".\[0-9\]+ =.*\".*/a\"" \
128
             "A one-char filename in the current directory"
129
 
130
    # A file in the root directory
131
    gdb_test "print xfullpath (\"/root_file_which_should_exist\")" \
132
             ".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \
133
             "A filename in the root directory"
134
 
135
    # A file which does not have a directory prefix
136
    gdb_test "print xfullpath (\"xfullpath.exp\")" \
137
             ".\[0-9\]+ =.*\"xfullpath.exp\"" \
138
             "A filename without any directory prefix"
139
 
140
    # A one-char filename without any directory prefix
141
    gdb_test "print xfullpath (\"a\")" \
142
             ".\[0-9\]+ =.*\"a\"" \
143
             "A one-char filename without any directory prefix"
144
 
145
    # An empty filename
146
    gdb_test "print xfullpath (\"\")" \
147
             ".\[0-9\]+ =.*\"\"" \
148
             "An empty filename"
149
 
150
    return 0
151
}
152
 
153
# Find a pathname to a file that we would execute if the shell was asked
154
# to run $arg using the current PATH.
155
 
156
proc find_gdb { arg } {
157
 
158
    # If the arg directly specifies an existing executable file, then
159
    # simply use it.
160
 
161
    if [file executable $arg] then {
162
        return $arg
163
    }
164
 
165
    set result [which $arg]
166
    if [string match "/" [ string range $result 0 0 ]] then {
167
        return $result
168
    }
169
 
170
    # If everything fails, just return the unqualified pathname as default
171
    # and hope for best.
172
 
173
    return $arg
174
}
175
 
176
# Run the test with self.
177
# Copy the file executable file in case this OS doesn't like to edit its own
178
# text space.
179
 
180
set GDB_FULLPATH [find_gdb $GDB]
181
 
182
# Remove any old copy lying around.
183
remote_file host delete x$tool
184
 
185
gdb_start
186
set file [remote_download host $GDB_FULLPATH x$tool]
187
set result [test_with_self $file];
188
gdb_exit;
189
catch "remote_file host delete $file";
190
 
191
if {$result <0} then {
192
    warning "Couldn't test self"
193
    return -1
194
}

powered by: WebSVN 2.1.0

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