]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/dwp-symlink.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dwp-symlink.exp
CommitLineData
b811d2c2 1# Copyright 2013-2020 Free Software Foundation, Inc.
82bf32bc
JK
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
16standard_testfile
17
149b30ff
DE
18remote_file host delete [standard_output_file ${testfile}.dwp]
19if [remote_file host exists [standard_output_file ${testfile}.dwp]] {
82bf32bc
JK
20 unsupported "dwp file cannot be deleted"
21 return 0
22}
23if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
24 return -1
25}
149b30ff 26if ![remote_file host exists [standard_output_file ${testfile}.dwp]] {
82bf32bc
JK
27 unsupported "testsuite run does not produce dwp files"
28 return 0
29}
30
31set thelink "${testfile}-thelink"
32
149b30ff
DE
33remote_file host delete [standard_output_file ${thelink}]
34remote_file host delete [standard_output_file ${thelink}.dwp]
82bf32bc 35# file link is only Tcl 8.4+.
149b30ff
DE
36remote_exec host "ln -sf ${testfile} [standard_output_file $thelink]"
37if ![remote_file host exists [standard_output_file $thelink]] {
82bf32bc
JK
38 unsupported "host does not support symbolic links (binary symlink is missing)"
39 return 0
40}
149b30ff 41if [remote_file host exists [standard_output_file $thelink.dwp]] {
82bf32bc
JK
42 unsupported "host does not support symbolic links (we tried to delete a file and it is still there)"
43 return 0
44}
45
46clean_restart "$testfile"
47
48gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary default, dwp default"
49
50clean_restart "$thelink"
51
52gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp default"
53
54gdb_exit
149b30ff
DE
55remote_exec host "mv -f [standard_output_file ${testfile}.dwp] [standard_output_file ${thelink}.dwp]"
56if [remote_file host exists [standard_output_file ${testfile}.dwp]] {
82bf32bc
JK
57 unsupported "host does not support symbolic links (binary symlink exists)"
58 return 0
59}
149b30ff 60if ![remote_file host exists [standard_output_file ${thelink}.dwp]] {
82bf32bc
JK
61 unsupported "host does not support symbolic links (dwp symlink is missing)"
62 return 0
63}
64
65clean_restart "$testfile"
66
67# This case cannot work.
68gdb_test "ptype main" {type = int \(\)} "binary default, dwp at symlink"
69
70clean_restart "$thelink"
71
72gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp at symlink"
04affae3
JK
73
74# Verify we can still find the dwp if we change directories and we specified
75# a relative path for the program.
76
04affae3
JK
77# This is clean_restart, but specifying a relative path to the binary.
78gdb_exit
79gdb_start
80gdb_reinitialize_dir $srcdir/$subdir
81gdb_test "cd [file dirname [standard_output_file ${thelink}]]" \
82 "Working directory .*"
83gdb_load "./${thelink}"
84
85gdb_test "cd .." "Working directory .*"
86
87gdb_test "ptype main" {type = int \(int, char \*\*\)} \
88 "relative path, binary symlink, dwp at symlink"
89
85f224e7
DE
90# Rename the dwp file back to its original name.
91remote_exec host "mv -f [standard_output_file ${thelink}.dwp] [standard_output_file ${testfile}.dwp]"
92
149b30ff
DE
93# N.B. At this point the active gdb is in, essentially, some random directory.
94# Restart a new copy if you add more tests here.
85f224e7
DE
95
96# Now verify that the following scenario works:
97# dir1/real-binary-with-random-name
98# dir2/real-dwp-with-random-name
99# dir3/symlink-to-real-binary
100# dir3/symlink-to-real-binary.dwp
101
102set dwp_bin_dir [standard_output_file dwp-dir1]
103set dwp_dwp_dir [standard_output_file dwp-dir2]
104set dwp_symlink_dir [standard_output_file dwp-dir3]
105set dwp_real_binary "dwp-abc"
106set dwp_real_dwp "dwp-def"
107set dwp_symlink_binary "dwp-symlink-binary"
108set dwp_symlink_dwp "${dwp_symlink_binary}.dwp"
109
110remote_exec host "rm -rf ${dwp_bin_dir}"
111remote_exec host "rm -rf ${dwp_dwp_dir}"
112remote_exec host "rm -rf ${dwp_symlink_dir}"
113remote_exec host "mkdir ${dwp_bin_dir}"
114remote_exec host "mkdir ${dwp_dwp_dir}"
115remote_exec host "mkdir ${dwp_symlink_dir}"
116remote_exec host "cp [standard_output_file $testfile] ${dwp_bin_dir}/${dwp_real_binary}"
117remote_exec host "cp [standard_output_file ${testfile}.dwp] ${dwp_dwp_dir}/${dwp_real_dwp}"
118# We don't test for failure to create the symlink here.
119# We assume that if the above symlinks are created ok, these will be too.
120remote_exec host "ln -sf ${dwp_bin_dir}/${dwp_real_binary} ${dwp_symlink_dir}/${dwp_symlink_binary}"
121remote_exec host "ln -sf ${dwp_dwp_dir}/${dwp_real_dwp} ${dwp_symlink_dir}/${dwp_symlink_dwp}"
122
123clean_restart "${dwp_symlink_dir}/${dwp_symlink_binary}"
124
125if ![runto_main] {
126 return -1
127}
128
129gdb_test {print argv[0]} "/${dwp_symlink_binary}\"" \
130 "separate executable/dwp symlinks"