]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/exe-lock.exp
8221be05595e711620fdf693ca65e2b5e338c4af
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / exe-lock.exp
1 # Copyright 2009-2019 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 # The intent of this testcase is to verify that GDB does not keep
17 # a filesystem lock on the executable file once the executable
18 # is no longer running.
19
20 standard_testfile arrayidx.c
21 # $EXEEXT suffix is needed here, because otherwise, Windows targets
22 # don't find the $binfile for 'file delete $binfile'.
23 append binfile $EXEEXT
24
25 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
26 untested "failed to compile"
27 return -1
28 }
29
30 clean_restart ${binfile}
31
32 # Sanity-check: Verify that the executable exists. This is just to
33 # make sure that, when we verify later that the file does not exist,
34 # it really has been deleted.
35 if { ! [file exists $binfile] } {
36 fail "executable does not exist (${binfile})"
37 return -1
38 }
39
40 if ![runto_main] then {
41 perror "couldn't run to breakpoint"
42 continue
43 }
44
45 gdb_continue_to_end
46
47 # Try deleting the executable file, now that the program has exited,
48 # and make sure that the deletion worked by verifying that the exe
49 # is no longer there (the "file delete" tcl command does not return
50 # any status, apparently).
51 file delete $binfile
52 if { [file exists $binfile] } {
53 fail "executable still exists (${binfile})"
54 }
55
56