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