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