dwp-symlink.exp revision 1.1 1 1.1 christos # Copyright 2013-2014 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos standard_testfile
17 1.1 christos
18 1.1 christos if [is_remote host] {
19 1.1 christos untested "remote host"
20 1.1 christos return 0
21 1.1 christos }
22 1.1 christos
23 1.1 christos file delete [standard_output_file ${testfile}.dwp]
24 1.1 christos if [file exists [standard_output_file ${testfile}.dwp]] {
25 1.1 christos unsupported "dwp file cannot be deleted"
26 1.1 christos return 0
27 1.1 christos }
28 1.1 christos if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
29 1.1 christos return -1
30 1.1 christos }
31 1.1 christos if ![file exists [standard_output_file ${testfile}.dwp]] {
32 1.1 christos unsupported "testsuite run does not produce dwp files"
33 1.1 christos return 0
34 1.1 christos }
35 1.1 christos
36 1.1 christos set thelink "${testfile}-thelink"
37 1.1 christos
38 1.1 christos file delete [standard_output_file ${thelink}]
39 1.1 christos file delete [standard_output_file ${thelink}.dwp]
40 1.1 christos # file link is only Tcl 8.4+.
41 1.1 christos exec "ln" "-sf" "${testfile}" "[standard_output_file $thelink]"
42 1.1 christos if ![file exists [standard_output_file $thelink]] {
43 1.1 christos unsupported "host does not support symbolic links (binary symlink is missing)"
44 1.1 christos return 0
45 1.1 christos }
46 1.1 christos if [file exists [standard_output_file $thelink.dwp]] {
47 1.1 christos unsupported "host does not support symbolic links (we tried to delete a file and it is still there)"
48 1.1 christos return 0
49 1.1 christos }
50 1.1 christos
51 1.1 christos clean_restart "$testfile"
52 1.1 christos
53 1.1 christos gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary default, dwp default"
54 1.1 christos
55 1.1 christos clean_restart "$thelink"
56 1.1 christos
57 1.1 christos gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp default"
58 1.1 christos
59 1.1 christos gdb_exit
60 1.1 christos file rename [standard_output_file ${testfile}.dwp] [standard_output_file ${thelink}.dwp]
61 1.1 christos if [file exists [standard_output_file ${testfile}.dwp]] {
62 1.1 christos unsupported "host does not support symbolic links (binary symlink exists)"
63 1.1 christos return 0
64 1.1 christos }
65 1.1 christos if ![file exists [standard_output_file ${thelink}.dwp]] {
66 1.1 christos unsupported "host does not support symbolic links (dwp symlink is missing)"
67 1.1 christos return 0
68 1.1 christos }
69 1.1 christos
70 1.1 christos clean_restart "$testfile"
71 1.1 christos
72 1.1 christos # This case cannot work.
73 1.1 christos gdb_test "ptype main" {type = int \(\)} "binary default, dwp at symlink"
74 1.1 christos
75 1.1 christos clean_restart "$thelink"
76 1.1 christos
77 1.1 christos gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp at symlink"
78 1.1 christos
79 1.1 christos # Verify we can still find the dwp if we change directories and we specified
80 1.1 christos # a relative path for the program.
81 1.1 christos
82 1.1 christos set saved_pwd [pwd]
83 1.1 christos
84 1.1 christos # This is clean_restart, but specifying a relative path to the binary.
85 1.1 christos gdb_exit
86 1.1 christos gdb_start
87 1.1 christos gdb_reinitialize_dir $srcdir/$subdir
88 1.1 christos gdb_test "cd [file dirname [standard_output_file ${thelink}]]" \
89 1.1 christos "Working directory .*"
90 1.1 christos gdb_load "./${thelink}"
91 1.1 christos
92 1.1 christos gdb_test "cd .." "Working directory .*"
93 1.1 christos
94 1.1 christos gdb_test "ptype main" {type = int \(int, char \*\*\)} \
95 1.1 christos "relative path, binary symlink, dwp at symlink"
96 1.1 christos
97 1.1 christos cd $saved_pwd
98