]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/fileio.exp
* gdb.arch/altivec-abi.exp: Replace gdb_suppress_entire_file with
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / fileio.exp
CommitLineData
a9415475 1# Copyright 2002, 2003, 2004
6aeb981f
CV
2# Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18# Please email any bugs, comments, and/or additions to this file to:
19# bug-gdb@prep.ai.mit.edu
20
21# This file was written by Corinna Vinschen <vinschen@redhat.com>
22
db488fc1
CV
23if [target_info exists gdb,nofileio] {
24 verbose "Skipping fileio.exp because of no fileio capabilities."
b257a0d3
AC
25 continue
26}
27
6aeb981f
CV
28if $tracelevel then {
29 strace $tracelevel
30}
31
32set prms_id 0
33set bug_id 0
34
35set testfile "fileio"
36set srcfile ${testfile}.c
37set binfile ${objdir}/${subdir}/${testfile}
38
39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
40 untested fileio.exp
41 return -1
6aeb981f
CV
42}
43
44# Create and source the file that provides information about the compiler
45# used to compile the test case.
46
47if [get_compiler_info ${binfile}] {
48 return -1;
49}
50
225f2bf6
AC
51remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
52remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
6aeb981f
CV
53
54set oldtimeout $timeout
55set timeout [expr "$timeout + 60"]
56
57# Start with a fresh gdb.
58
59gdb_exit
60gdb_start
61gdb_reinitialize_dir $srcdir/$subdir
62gdb_load ${binfile}
63send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
64send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
65send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
66
67
68if ![runto_main] then {
69 perror "couldn't run to breakpoint"
70 continue
71}
72
e1c2defa
NS
73send_gdb "break stop\n" ; gdb_expect -re "Breakpoint .*$srcfile.*$gdb_prompt $"
74set stop_msg ".*Breakpoint .* stop \\(\\) at.*$srcfile:.*static void stop \\(\\) {}.*"
75
6aeb981f 76gdb_test continue \
e1c2defa 77"Continuing\\..*open 1:.*OK$stop_msg" \
6aeb981f
CV
78"Open a file"
79
6aeb981f 80gdb_test continue \
e1c2defa 81"Continuing\\..*open 2:.*EEXIST$stop_msg" \
6aeb981f
CV
82"Creating already existing file returns EEXIST"
83
6aeb981f 84gdb_test continue \
e1c2defa 85"Continuing\\..*open 3:.*EISDIR$stop_msg" \
6aeb981f
CV
86"Open directory for writing returns EISDIR"
87
6aeb981f 88gdb_test continue \
e1c2defa 89"Continuing\\..*open 4:.*ENOENT$stop_msg" \
6aeb981f
CV
90"Opening nonexistant file returns ENOENT"
91
6aeb981f
CV
92send_gdb "continue\n" ; gdb_expect -re "$gdb_prompt $"
93catch "system \"chmod -f -w nowrt.fileio.test\""
94
6aeb981f 95gdb_test continue \
e1c2defa 96"Continuing\\..*open 5:.*EACCES$stop_msg" \
6aeb981f
CV
97"Open for write but no write permission returns EACCES"
98
6aeb981f 99gdb_test continue \
e1c2defa 100"Continuing\\..*write 1:.*OK$stop_msg" \
6aeb981f
CV
101"Writing to a file"
102
6aeb981f 103gdb_test continue \
e1c2defa 104"Continuing\\..*write 2:.*EBADF$stop_msg" \
6aeb981f
CV
105"Write using invalid file descriptor returns EBADF"
106
6aeb981f 107gdb_test continue \
e1c2defa 108"Continuing\\..*write 3:.*EBADF$stop_msg" \
6aeb981f
CV
109"Writing to a read-only file returns EBADF"
110
6aeb981f 111gdb_test continue \
e1c2defa 112"Continuing\\..*read 1:.*OK$stop_msg" \
6aeb981f
CV
113"Reading from a file"
114
6aeb981f 115gdb_test continue \
e1c2defa 116"Continuing\\..*read 2:.*EBADF$stop_msg" \
6aeb981f
CV
117"Read using invalid file descriptor returns EBADF"
118
6aeb981f 119gdb_test continue \
e1c2defa
NS
120"Continuing\\..*lseek 1:.*OK$stop_msg" \
121"Lseeking CUR a file"
122
123gdb_test continue \
124"Continuing\\..*lseek 2:.*OK$stop_msg" \
125"Lseeking END a file"
126
127gdb_test continue \
128"Continuing\\..*lseek 3:.*OK$stop_msg" \
129"Lseeking SET a file"
130
6aeb981f 131
6aeb981f 132gdb_test continue \
e1c2defa 133"Continuing\\..*close 1:.*OK$stop_msg" \
6aeb981f
CV
134"Closing a file"
135
6aeb981f 136gdb_test continue \
e1c2defa 137"Continuing\\..*close 2:.*EBADF$stop_msg" \
6aeb981f
CV
138"Closing an invalid file descriptor returns EBADF"
139
6aeb981f 140gdb_test continue \
e1c2defa 141"Continuing\\..*stat 1:.*OK$stop_msg" \
6aeb981f
CV
142"Stat a file"
143
6aeb981f 144gdb_test continue \
e1c2defa 145 "Continuing\\..*stat 2:.*(ENOENT|EFAULT)$stop_msg" \
b257a0d3 146"Stat a NULL pathname returns ENOENT or EFAULT"
6aeb981f 147
6aeb981f 148gdb_test continue \
e1c2defa 149"Continuing\\..*stat 3:.*ENOENT$stop_msg" \
6aeb981f
CV
150"Stat an empty pathname returns ENOENT"
151
6aeb981f 152gdb_test continue \
e1c2defa 153"Continuing\\..*stat 4:.*ENOENT$stop_msg" \
6aeb981f
CV
154"Stat a nonexistant file returns ENOENT"
155
6aeb981f 156gdb_test continue \
e1c2defa 157"Continuing\\..*fstat 1:.*OK$stop_msg" \
6aeb981f
CV
158"Fstat an open file"
159
6aeb981f 160gdb_test continue \
e1c2defa 161"Continuing\\..*fstat 2:.*EBADF$stop_msg" \
6aeb981f
CV
162"Fstat an invalid file descriptor returns EBADF"
163
6aeb981f 164gdb_test continue \
e1c2defa 165"Continuing\\..*isatty 1:.*OK$stop_msg" \
6aeb981f
CV
166"Isatty (stdin)"
167
6aeb981f 168gdb_test continue \
e1c2defa 169"Continuing\\..*isatty 2:.*OK$stop_msg" \
6aeb981f
CV
170"Isatty (stdout)"
171
6aeb981f 172gdb_test continue \
e1c2defa 173"Continuing\\..*isatty 3:.*OK$stop_msg" \
6aeb981f
CV
174"Isatty (stderr)"
175
6aeb981f 176gdb_test continue \
e1c2defa 177"Continuing\\..*isatty 4:.*OK$stop_msg" \
6aeb981f
CV
178"Isatty (invalid fd)"
179
6aeb981f 180gdb_test continue \
e1c2defa 181"Continuing\\..*isatty 5:.*OK$stop_msg" \
6aeb981f
CV
182"Isatty (open file)"
183
6aeb981f 184gdb_test continue \
e1c2defa 185"Continuing\\..*system 1:.*OK$stop_msg" \
5600ea19
NS
186"System says shell is available"
187
188send_gdb "set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $"
189gdb_test continue \
190"Continuing\\..*system 2:.*OK$stop_msg" \
6aeb981f
CV
191"System(3) call"
192
b257a0d3 193# Is this ok? POSIX says system returns a waitpid status?
6aeb981f 194gdb_test continue \
5600ea19 195"Continuing\\..*system 3:.*OK$stop_msg" \
6aeb981f
CV
196"System with invalid command returns 127"
197
6aeb981f 198gdb_test continue \
e1c2defa 199"Continuing\\..*rename 1:.*OK$stop_msg" \
6aeb981f
CV
200"Rename a file"
201
6aeb981f 202gdb_test continue \
e1c2defa 203"Continuing\\..*rename 2:.*EISDIR$stop_msg" \
6aeb981f
CV
204"Renaming a file to existing directory returns EISDIR"
205
a9415475
AC
206set test "Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST"
207gdb_test_multiple continue "${test}" {
e1c2defa 208 -re "Continuing\\..*rename 3:.*(ENOTEMPTY|EEXIST)$stop_msg$gdb_prompt $" {
a9415475
AC
209 pass "${test}"
210 }
e1c2defa 211 -re "Continuing\\..*rename 3:.*EBUSY$stop_msg$gdb_prompt $" {
a9415475
AC
212 # At least version <= 2.6/2004-01-08 of the Linux Kernel gets
213 # this wrong (reporting EBUSY) when the file system is NFS
214 # mounted.
215 setup_xfail *-*-*linux* gdb/1502
216 fail "${test}"
217 }
218}
6aeb981f 219
6aeb981f 220gdb_test continue \
e1c2defa 221"Continuing\\..*rename 4:.*EINVAL$stop_msg" \
6aeb981f
CV
222"Renaming a directory to a subdir of itself returns EINVAL"
223
6aeb981f 224gdb_test continue \
e1c2defa 225"Continuing\\..*rename 5:.*ENOENT$stop_msg" \
6aeb981f
CV
226"Renaming a nonexistant file returns ENOENT"
227
6aeb981f 228gdb_test continue \
e1c2defa 229"Continuing\\..*unlink 1:.*OK$stop_msg" \
6aeb981f
CV
230"Unlink a file"
231
6aeb981f
CV
232# This test fails on Cygwin because unlink() succeeds on Win32 systems
233# in that situation.
234if [ishost *cygwin*] {
235 setup_xfail "*-*-*"
236}
237gdb_test continue \
e1c2defa 238"Continuing\\..*unlink 2:.*EACCES$stop_msg" \
6aeb981f
CV
239"Unlinking a file in a directory w/o write access returns EACCES"
240
6aeb981f 241gdb_test continue \
e1c2defa 242"Continuing\\..*unlink 3:.*ENOENT$stop_msg" \
6aeb981f
CV
243"Unlinking a nonexistant file returns ENOENT"
244
6aeb981f 245gdb_test continue \
e1c2defa 246"Continuing\\..*time 1:.*OK$stop_msg" \
6aeb981f
CV
247"Time(2) call returns the same value as in parameter"
248
249sleep 2
6aeb981f 250gdb_test continue \
e1c2defa 251"Continuing\\..*time 2:.*OK$stop_msg" \
6aeb981f
CV
252"Time(2) returns feasible values"
253
254send_gdb "quit\n"
255send_gdb "y\n"
256
225f2bf6
AC
257remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
258remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
6aeb981f
CV
259
260set timeout $oldtimeout
261return 0