1 # Copyright
2002, 2003, 2004
2 # Free Software Foundation
, Inc.
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.
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.
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.
18 # Please email
any bugs
, comments
, and
/or additions to this file to
:
19 # bug
-gdb@prep.ai.mit.edu
21 # This file was written by Corinna Vinschen
<vinschen@redhat.com
>
23 if [target_info
exists gdb
,nofileio
] {
24 verbose
"Skipping fileio.exp because of no fileio capabilities."
36 set srcfile $
{testfile
}.c
37 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
39 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
40 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
43 # Create and source the file that provides information about the compiler
44 # used to
compile the test case.
46 if [get_compiler_info $
{binfile
}] {
50 remote_exec build
{sh
-xc test\
-r\ dir2.fileio.test\
&&\ chmod\
-f\
+w\ dir2.fileio.test
}
51 remote_exec build
{sh
-xc rm\
-rf\
*.fileio.test
}
53 set oldtimeout $timeout
54 set timeout
[expr
"$timeout + 60"]
56 # Start with a fresh gdb.
60 gdb_reinitialize_dir $srcdir
/$subdir
62 send_gdb
"set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
63 send_gdb
"set print address off\n" ; gdb_expect -re "$gdb_prompt $"
64 send_gdb
"set width 0\n" ; gdb_expect -re "$gdb_prompt $"
67 if ![runto_main
] then {
68 perror
"couldn't run to breakpoint"
72 send_gdb
"tbreak 81\n" ; gdb_expect -re "$gdb_prompt $"
74 "Continuing\\..*open 1:.*OK.*test_open \\(\\) at.*$srcfile:81.*" \
77 send_gdb
"tbreak 88\n" ; gdb_expect -re "$gdb_prompt $"
79 "Continuing\\..*open 2:.*EEXIST.*test_open \\(\\) at.*$srcfile:88.*" \
80 "Creating already existing file returns EEXIST"
82 send_gdb
"tbreak 95\n" ; gdb_expect -re "$gdb_prompt $"
84 "Continuing\\..*open 3:.*EISDIR.*test_open \\(\\) at.*$srcfile:95.*" \
85 "Open directory for writing returns EISDIR"
87 send_gdb
"tbreak 102\n" ; gdb_expect -re "$gdb_prompt $"
89 "Continuing\\..*open 4:.*ENOENT.*test_open \\(\\) at.*$srcfile:102.*" \
90 "Opening nonexistant file returns ENOENT"
92 send_gdb
"tbreak 109\n" ; gdb_expect -re "$gdb_prompt $"
93 send_gdb
"continue\n" ; gdb_expect -re "$gdb_prompt $"
94 catch
"system \"chmod -f -w nowrt.fileio.test\""
96 send_gdb
"tbreak 119\n" ; gdb_expect -re "$gdb_prompt $"
98 "Continuing\\..*open 5:.*EACCES.*test_open \\(\\) at.*$srcfile:119.*" \
99 "Open for write but no write permission returns EACCES"
101 send_gdb
"tbreak 140\n" ; gdb_expect -re "$gdb_prompt $"
103 "Continuing\\..*write 1:.*OK.*test_write \\(\\) at.*$srcfile:140.*" \
106 send_gdb
"tbreak 145\n" ; gdb_expect -re "$gdb_prompt $"
108 "Continuing\\..*write 2:.*EBADF.*test_write \\(\\) at.*$srcfile:145.*" \
109 "Write using invalid file descriptor returns EBADF"
111 send_gdb
"tbreak 156\n" ; gdb_expect -re "$gdb_prompt $"
113 "Continuing\\..*write 3:.*EBADF.*test_write \\(\\) at.*$srcfile:156.*" \
114 "Writing to a read-only file returns EBADF"
116 send_gdb
"tbreak 182\n" ; gdb_expect -re "$gdb_prompt $"
118 "Continuing\\..*read 1:.*OK.*test_read \\(\\) at.*$srcfile:182.*" \
119 "Reading from a file"
121 send_gdb
"tbreak 186\n" ; gdb_expect -re "$gdb_prompt $"
123 "Continuing\\..*read 2:.*EBADF.*test_read \\(\\) at.*$srcfile:186.*" \
124 "Read using invalid file descriptor returns EBADF"
126 send_gdb
"tbreak 221\n" ; gdb_expect -re "$gdb_prompt $"
128 "Continuing\\..*lseek 1:.*OK.*lseek 2:.*OK.*lseek 3:.*OK.*test_lseek \\(\\) at.*$srcfile:221.*" \
131 send_gdb
"tbreak 241\n" ; gdb_expect -re "$gdb_prompt $"
133 "Continuing\\..*close 1:.*OK.*test_close \\(\\) at.*$srcfile:241.*" \
136 send_gdb
"tbreak 245\n" ; gdb_expect -re "$gdb_prompt $"
138 "Continuing\\..*close 2:.*EBADF.*test_close \\(\\) at.*$srcfile:245.*" \
139 "Closing an invalid file descriptor returns EBADF"
141 send_gdb
"tbreak 262\n" ; gdb_expect -re "$gdb_prompt $"
143 "Continuing\\..*stat 1:.*OK.*test_stat \\(\\) at.*$srcfile:262.*" \
146 send_gdb
"tbreak 267\n" ; gdb_expect -re "$gdb_prompt $"
148 "Continuing\\..*stat 2:.*(ENOENT|EFAULT).*test_stat \\(\\) at.*$srcfile:267.*" \
149 "Stat a NULL pathname returns ENOENT or EFAULT"
151 send_gdb
"tbreak 272\n" ; gdb_expect -re "$gdb_prompt $"
153 "Continuing\\..*stat 3:.*ENOENT.*test_stat \\(\\) at.*$srcfile:272.*" \
154 "Stat an empty pathname returns ENOENT"
156 send_gdb
"tbreak 276\n" ; gdb_expect -re "$gdb_prompt $"
158 "Continuing\\..*stat 4:.*ENOENT.*test_stat \\(\\) at.*$srcfile:276.*" \
159 "Stat a nonexistant file returns ENOENT"
161 send_gdb
"tbreak 301\n" ; gdb_expect -re "$gdb_prompt $"
163 "Continuing\\..*fstat 1:.*OK.*test_fstat \\(\\) at.*$srcfile:301.*" \
166 send_gdb
"tbreak 305\n" ; gdb_expect -re "$gdb_prompt $"
168 "Continuing\\..*fstat 2:.*EBADF.*test_fstat \\(\\) at.*$srcfile:305.*" \
169 "Fstat an invalid file descriptor returns EBADF"
171 send_gdb
"tbreak 314\n" ; gdb_expect -re "$gdb_prompt $"
173 "Continuing\\..*isatty 1:.*OK.*test_isatty \\(\\) at.*$srcfile:314.*" \
176 send_gdb
"tbreak 315\n" ; gdb_expect -re "$gdb_prompt $"
178 "Continuing\\..*isatty 2:.*OK.*test_isatty \\(\\) at.*$srcfile:315.*" \
181 send_gdb
"tbreak 317\n" ; gdb_expect -re "$gdb_prompt $"
183 "Continuing\\..*isatty 3:.*OK.*test_isatty \\(\\) at.*$srcfile:317.*" \
186 send_gdb
"tbreak 319\n" ; gdb_expect -re "$gdb_prompt $"
188 "Continuing\\..*isatty 4:.*OK.*test_isatty \\(\\) at.*$srcfile:319.*" \
189 "Isatty (invalid fd)"
191 send_gdb
"tbreak 327\n" ; gdb_expect -re "$gdb_prompt $"
193 "Continuing\\..*isatty 5:.*OK.*test_isatty \\(\\) at.*$srcfile:327.*" \
196 send_gdb
"set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $"
197 send_gdb
"tbreak 347\n" ; gdb_expect -re "$gdb_prompt $"
199 "Continuing\\..*system 1:.*OK.*test_system \\(\\) at.*$srcfile:347.*" \
202 # Is this ok? POSIX says
system returns a waitpid
status?
203 send_gdb
"tbreak 349\n" ; gdb_expect -re "$gdb_prompt $"
205 "Continuing\\..*system 2:.*OK.*test_system \\(\\) at.*$srcfile:349.*" \
206 "System with invalid command returns 127"
208 send_gdb
"tbreak 378\n" ; gdb_expect -re "$gdb_prompt $"
210 "Continuing\\..*rename 1:.*OK.*test_rename \\(\\) at.*$srcfile:378.*" \
213 send_gdb
"tbreak 383\n" ; gdb_expect -re "$gdb_prompt $"
215 "Continuing\\..*rename 2:.*EISDIR.*test_rename \\(\\) at.*$srcfile:383.*" \
216 "Renaming a file to existing directory returns EISDIR"
218 send_gdb
"tbreak 388\n" ; gdb_expect -re "$gdb_prompt $"
219 set test
"Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST"
220 gdb_test_multiple
continue "${test}" {
221 -re
"Continuing\\..*rename 3:.*(ENOTEMPTY|EEXIST).*test_rename \\(\\) at.*$srcfile:388.*$gdb_prompt $" {
224 -re
"Continuing\\..*rename 3:.*EBUSY.*test_rename \\(\\) at.*$srcfile:388.*$gdb_prompt $" {
225 # At least version
<= 2.6/2004-01-08 of the Linux Kernel gets
226 # this wrong
(reporting EBUSY
) when the file
system is NFS
228 setup_xfail
*-*-*linux
* gdb
/1502
233 send_gdb
"tbreak 393\n" ; gdb_expect -re "$gdb_prompt $"
235 "Continuing\\..*rename 4:.*EINVAL.*test_rename \\(\\) at.*$srcfile:393.*" \
236 "Renaming a directory to a subdir of itself returns EINVAL"
238 send_gdb
"tbreak 397\n" ; gdb_expect -re "$gdb_prompt $"
240 "Continuing\\..*rename 5:.*ENOENT.*test_rename \\(\\) at.*$srcfile:397.*" \
241 "Renaming a nonexistant file returns ENOENT"
243 send_gdb
"tbreak 412\n" ; gdb_expect -re "$gdb_prompt $"
245 "Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:412.*" \
248 send_gdb
"tbreak 432\n" ; gdb_expect -re "$gdb_prompt $"
249 # This test fails
on Cygwin because unlink
() succeeds
on Win32 systems
251 if [ishost
*cygwin
*] {
255 "Continuing\\..*unlink 2:.*EACCES.*test_unlink \\(\\) at.*$srcfile:432.*" \
256 "Unlinking a file in a directory w/o write access returns EACCES"
258 send_gdb
"tbreak 436\n" ; gdb_expect -re "$gdb_prompt $"
260 "Continuing\\..*unlink 3:.*ENOENT.*test_unlink \\(\\) at.*$srcfile:436.*" \
261 "Unlinking a nonexistant file returns ENOENT"
263 send_gdb
"tbreak 446\n" ; gdb_expect -re "$gdb_prompt $"
265 "Continuing\\..*time 1:.*OK.*test_time \\(\\) at.*$srcfile:446.*" \
266 "Time(2) call returns the same value as in parameter"
269 send_gdb
"tbreak 450\n" ; gdb_expect -re "$gdb_prompt $"
271 "Continuing\\..*time 2:.*OK.*test_time \\(\\) at.*$srcfile:450.*" \
272 "Time(2) returns feasible values"
277 remote_exec build
{sh
-xc test\
-r\ dir2.fileio.test\
&&\ chmod\
-f\
+w\ dir2.fileio.test
}
278 remote_exec build
{sh
-xc rm\
-rf\
*.fileio.test
}
280 set timeout $oldtimeout