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