* gdb.stabs/weird.exp (print_weird_var): Don't send extra \n.
[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 50
2db8e78e
MC
51 global gdb_file_cmd_debug_info
52 set gdb_file_cmd_debug_info "unset"
53
3e3ffd2b 54 set result [gdb_load $executable]
989d314b
JB
55 set timeout $oldtimeout
56 verbose "Timeout is now $timeout seconds" 2
57
2db8e78e
MC
58 if { $result != 0 } then {
59 return -1
60 }
61
62 if { $gdb_file_cmd_debug_info != "debug" } then {
63 untested "No debug information, skipping testcase."
3e3ffd2b
MC
64 return -1
65 }
66
989d314b
JB
67 # Set a breakpoint at main
68 gdb_test "break captured_main" \
69 "Breakpoint.*at.* file.*, line.*" \
70 "breakpoint in captured_main"
71
72 # run yourself
73 # It may take a very long time for the inferior gdb to start (lynx),
74 # so we bump it back up for the duration of this command.
75 set timeout 600
76
77 set description "run until breakpoint at captured_main"
78 send_gdb "run -nw\n"
79 gdb_expect {
80 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
81 pass "$description"
82 }
83 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" {
84 xfail "$description (line numbers scrambled?)"
85 }
86 -re "vfork: No more processes.*$gdb_prompt $" {
87 fail "$description (out of virtual memory)"
88 set timeout $oldtimeout
89 verbose "Timeout is now $timeout seconds" 2
90 return -1
91 }
92 -re ".*$gdb_prompt $" {
93 fail "$description"
94 set timeout $oldtimeout
95 verbose "Timeout is now $timeout seconds" 2
96 return -1
97 }
98 timeout {
99 fail "$description (timeout)"
100 }
101 }
102
103 set timeout $oldtimeout
104 verbose "Timeout is now $timeout seconds" 2
105
106 return 0
107}
108
109proc test_with_self { executable } {
110
111 set setup_result [setup_test $executable]
112 if {$setup_result <0} then {
113 return -1
114 }
115
116 # A file which contains a directory prefix
117 gdb_test "print xfullpath (\"./xfullpath.exp\")" \
118 ".\[0-9\]+ =.*\".*/xfullpath.exp\"" \
119 "A filename with ./ as the directory prefix"
120
121 # A file which contains a directory prefix
122 gdb_test "print xfullpath (\"../../defs.h\")" \
123 ".\[0-9\]+ =.*\".*/defs.h\"" \
124 "A filename with ../ in the directory prefix"
125
126 # A one-character filename
127 gdb_test "print xfullpath (\"./a\")" \
128 ".\[0-9\]+ =.*\".*/a\"" \
129 "A one-char filename in the current directory"
130
131 # A file in the root directory
132 gdb_test "print xfullpath (\"/root_file_which_should_exist\")" \
133 ".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \
134 "A filename in the root directory"
135
136 # A file which does not have a directory prefix
137 gdb_test "print xfullpath (\"xfullpath.exp\")" \
138 ".\[0-9\]+ =.*\"xfullpath.exp\"" \
139 "A filename without any directory prefix"
140
141 # A one-char filename without any directory prefix
142 gdb_test "print xfullpath (\"a\")" \
143 ".\[0-9\]+ =.*\"a\"" \
144 "A one-char filename without any directory prefix"
145
146 # An empty filename
147 gdb_test "print xfullpath (\"\")" \
148 ".\[0-9\]+ =.*\"\"" \
149 "An empty filename"
150
151 return 0
152}
153
154# Find a pathname to a file that we would execute if the shell was asked
155# to run $arg using the current PATH.
156
157proc find_gdb { arg } {
158
159 # If the arg directly specifies an existing executable file, then
160 # simply use it.
161
162 if [file executable $arg] then {
163 return $arg
164 }
165
166 set result [which $arg]
167 if [string match "/" [ string range $result 0 0 ]] then {
168 return $result
169 }
170
171 # If everything fails, just return the unqualified pathname as default
172 # and hope for best.
173
174 return $arg
175}
176
177# Run the test with self.
178# Copy the file executable file in case this OS doesn't like to edit its own
179# text space.
180
181set GDB_FULLPATH [find_gdb $GDB]
182
183# Remove any old copy lying around.
184remote_file host delete x$tool
185
186gdb_start
187set file [remote_download host $GDB_FULLPATH x$tool]
188set result [test_with_self $file];
189gdb_exit;
190catch "remote_file host delete $file";
191
192if {$result <0} then {
193 warning "Couldn't test self"
194 return -1
195}
This page took 0.454576 seconds and 4 git commands to generate.