* gdb.dwarf2/dwp-symlink.exp: Rewrite to use remote_* commands instead
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dwp-symlink.exp
1 # Copyright 2013-2014 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 standard_testfile
17
18 remote_file host delete [standard_output_file ${testfile}.dwp]
19 if [remote_file host exists [standard_output_file ${testfile}.dwp]] {
20 unsupported "dwp file cannot be deleted"
21 return 0
22 }
23 if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
24 return -1
25 }
26 if ![remote_file host exists [standard_output_file ${testfile}.dwp]] {
27 unsupported "testsuite run does not produce dwp files"
28 return 0
29 }
30
31 set thelink "${testfile}-thelink"
32
33 remote_file host delete [standard_output_file ${thelink}]
34 remote_file host delete [standard_output_file ${thelink}.dwp]
35 # file link is only Tcl 8.4+.
36 remote_exec host "ln -sf ${testfile} [standard_output_file $thelink]"
37 if ![remote_file host exists [standard_output_file $thelink]] {
38 unsupported "host does not support symbolic links (binary symlink is missing)"
39 return 0
40 }
41 if [remote_file host exists [standard_output_file $thelink.dwp]] {
42 unsupported "host does not support symbolic links (we tried to delete a file and it is still there)"
43 return 0
44 }
45
46 clean_restart "$testfile"
47
48 gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary default, dwp default"
49
50 clean_restart "$thelink"
51
52 gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp default"
53
54 gdb_exit
55 remote_exec host "mv -f [standard_output_file ${testfile}.dwp] [standard_output_file ${thelink}.dwp]"
56 if [remote_file host exists [standard_output_file ${testfile}.dwp]] {
57 unsupported "host does not support symbolic links (binary symlink exists)"
58 return 0
59 }
60 if ![remote_file host exists [standard_output_file ${thelink}.dwp]] {
61 unsupported "host does not support symbolic links (dwp symlink is missing)"
62 return 0
63 }
64
65 clean_restart "$testfile"
66
67 # This case cannot work.
68 gdb_test "ptype main" {type = int \(\)} "binary default, dwp at symlink"
69
70 clean_restart "$thelink"
71
72 gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp at symlink"
73
74 # Verify we can still find the dwp if we change directories and we specified
75 # a relative path for the program.
76
77 # This is clean_restart, but specifying a relative path to the binary.
78 gdb_exit
79 gdb_start
80 gdb_reinitialize_dir $srcdir/$subdir
81 gdb_test "cd [file dirname [standard_output_file ${thelink}]]" \
82 "Working directory .*"
83 gdb_load "./${thelink}"
84
85 gdb_test "cd .." "Working directory .*"
86
87 gdb_test "ptype main" {type = int \(int, char \*\*\)} \
88 "relative path, binary symlink, dwp at symlink"
89
90 # N.B. At this point the active gdb is in, essentially, some random directory.
91 # Restart a new copy if you add more tests here.