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