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,nointerrupts] {
24 verbose "Skipping interrupt.exp because of nointerrupts."
28 if [target_info exists gdb,noinferiorio] {
29 verbose "Skipping interrupt.exp because of noinferiorio."
41 set srcfile ${testfile}.c
42 set binfile ${objdir}/${subdir}/${testfile}
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
45 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48 # Create and source the file that provides information about the compiler
49 # used to compile the test case.
51 if [get_compiler_info ${binfile}] {
55 remote_exec build "test -r dir2.fileio.test && chmod -f +w dir2.fileio.test"
56 remote_exec build "rm -rf *.fileio.test"
58 set oldtimeout $timeout
59 set timeout [expr "$timeout + 60"]
61 # Start with a fresh gdb.
65 gdb_reinitialize_dir $srcdir/$subdir
67 send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
68 send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
69 send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
72 if ![runto_main] then {
73 perror "couldn't run to breakpoint"
77 send_gdb "tbreak 81\n" ; gdb_expect -re "$gdb_prompt $"
79 "Continuing\\..*open 1:.*OK.*test_open \\(\\) at.*$srcfile:81.*" \
82 send_gdb "tbreak 88\n" ; gdb_expect -re "$gdb_prompt $"
84 "Continuing\\..*open 2:.*EEXIST.*test_open \\(\\) at.*$srcfile:88.*" \
85 "Creating already existing file returns EEXIST"
87 send_gdb "tbreak 95\n" ; gdb_expect -re "$gdb_prompt $"
89 "Continuing\\..*open 3:.*EISDIR.*test_open \\(\\) at.*$srcfile:95.*" \
90 "Open directory for writing returns EISDIR"
92 send_gdb "tbreak 102\n" ; gdb_expect -re "$gdb_prompt $"
94 "Continuing\\..*open 4:.*ENOENT.*test_open \\(\\) at.*$srcfile:102.*" \
95 "Opening nonexistant file returns ENOENT"
97 send_gdb "tbreak 109\n" ; gdb_expect -re "$gdb_prompt $"
98 send_gdb "continue\n" ; gdb_expect -re "$gdb_prompt $"
99 catch "system \"chmod -f -w nowrt.fileio.test\""
101 send_gdb "tbreak 119\n" ; gdb_expect -re "$gdb_prompt $"
103 "Continuing\\..*open 5:.*EACCES.*test_open \\(\\) at.*$srcfile:119.*" \
104 "Open for write but no write permission returns EACCES"
106 send_gdb "tbreak 140\n" ; gdb_expect -re "$gdb_prompt $"
108 "Continuing\\..*write 1:.*OK.*test_write \\(\\) at.*$srcfile:140.*" \
111 send_gdb "tbreak 145\n" ; gdb_expect -re "$gdb_prompt $"
113 "Continuing\\..*write 2:.*EBADF.*test_write \\(\\) at.*$srcfile:145.*" \
114 "Write using invalid file descriptor returns EBADF"
116 send_gdb "tbreak 156\n" ; gdb_expect -re "$gdb_prompt $"
118 "Continuing\\..*write 3:.*EBADF.*test_write \\(\\) at.*$srcfile:156.*" \
119 "Writing to a read-only file returns EBADF"
121 send_gdb "tbreak 182\n" ; gdb_expect -re "$gdb_prompt $"
123 "Continuing\\..*read 1:.*OK.*test_read \\(\\) at.*$srcfile:182.*" \
124 "Reading from a file"
126 send_gdb "tbreak 186\n" ; gdb_expect -re "$gdb_prompt $"
128 "Continuing\\..*read 2:.*EBADF.*test_read \\(\\) at.*$srcfile:186.*" \
129 "Read using invalid file descriptor returns EBADF"
131 send_gdb "tbreak 221\n" ; gdb_expect -re "$gdb_prompt $"
133 "Continuing\\..*lseek 1:.*OK.*lseek 2:.*OK.*lseek 3:.*OK.*test_lseek \\(\\) at.*$srcfile:221.*" \
136 send_gdb "tbreak 241\n" ; gdb_expect -re "$gdb_prompt $"
138 "Continuing\\..*close 1:.*OK.*test_close \\(\\) at.*$srcfile:241.*" \
141 send_gdb "tbreak 245\n" ; gdb_expect -re "$gdb_prompt $"
143 "Continuing\\..*close 2:.*EBADF.*test_close \\(\\) at.*$srcfile:245.*" \
144 "Closing an invalid file descriptor returns EBADF"
146 send_gdb "tbreak 262\n" ; gdb_expect -re "$gdb_prompt $"
148 "Continuing\\..*stat 1:.*OK.*test_stat \\(\\) at.*$srcfile:262.*" \
151 send_gdb "tbreak 267\n" ; gdb_expect -re "$gdb_prompt $"
153 "Continuing\\..*stat 2:.*(ENOENT|EFAULT).*test_stat \\(\\) at.*$srcfile:267.*" \
154 "Stat a NULL pathname returns ENOENT or EFAULT"
156 send_gdb "tbreak 272\n" ; gdb_expect -re "$gdb_prompt $"
158 "Continuing\\..*stat 3:.*ENOENT.*test_stat \\(\\) at.*$srcfile:272.*" \
159 "Stat an empty pathname returns ENOENT"
161 send_gdb "tbreak 276\n" ; gdb_expect -re "$gdb_prompt $"
163 "Continuing\\..*stat 4:.*ENOENT.*test_stat \\(\\) at.*$srcfile:276.*" \
164 "Stat a nonexistant file returns ENOENT"
166 send_gdb "tbreak 301\n" ; gdb_expect -re "$gdb_prompt $"
168 "Continuing\\..*fstat 1:.*OK.*test_fstat \\(\\) at.*$srcfile:301.*" \
171 send_gdb "tbreak 305\n" ; gdb_expect -re "$gdb_prompt $"
173 "Continuing\\..*fstat 2:.*EBADF.*test_fstat \\(\\) at.*$srcfile:305.*" \
174 "Fstat an invalid file descriptor returns EBADF"
176 send_gdb "tbreak 314\n" ; gdb_expect -re "$gdb_prompt $"
178 "Continuing\\..*isatty 1:.*OK.*test_isatty \\(\\) at.*$srcfile:314.*" \
181 send_gdb "tbreak 315\n" ; gdb_expect -re "$gdb_prompt $"
183 "Continuing\\..*isatty 2:.*OK.*test_isatty \\(\\) at.*$srcfile:315.*" \
186 send_gdb "tbreak 317\n" ; gdb_expect -re "$gdb_prompt $"
188 "Continuing\\..*isatty 3:.*OK.*test_isatty \\(\\) at.*$srcfile:317.*" \
191 send_gdb "tbreak 319\n" ; gdb_expect -re "$gdb_prompt $"
193 "Continuing\\..*isatty 4:.*OK.*test_isatty \\(\\) at.*$srcfile:319.*" \
194 "Isatty (invalid fd)"
196 send_gdb "tbreak 327\n" ; gdb_expect -re "$gdb_prompt $"
198 "Continuing\\..*isatty 5:.*OK.*test_isatty \\(\\) at.*$srcfile:327.*" \
201 send_gdb "set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $"
202 send_gdb "tbreak 347\n" ; gdb_expect -re "$gdb_prompt $"
204 "Continuing\\..*system 1:.*OK.*test_system \\(\\) at.*$srcfile:347.*" \
207 # Is this ok? POSIX says system returns a waitpid status?
208 send_gdb "tbreak 349\n" ; gdb_expect -re "$gdb_prompt $"
210 "Continuing\\..*system 2:.*OK.*test_system \\(\\) at.*$srcfile:349.*" \
211 "System with invalid command returns 127"
213 send_gdb "tbreak 378\n" ; gdb_expect -re "$gdb_prompt $"
215 "Continuing\\..*rename 1:.*OK.*test_rename \\(\\) at.*$srcfile:378.*" \
218 send_gdb "tbreak 383\n" ; gdb_expect -re "$gdb_prompt $"
220 "Continuing\\..*rename 2:.*EISDIR.*test_rename \\(\\) at.*$srcfile:383.*" \
221 "Renaming a file to existing directory returns EISDIR"
223 send_gdb "tbreak 388\n" ; gdb_expect -re "$gdb_prompt $"
225 "Continuing\\..*rename 3:.*(ENOTEMPTY|EEXIST).*test_rename \\(\\) at.*$srcfile:388.*" \
226 "Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST"
228 send_gdb "tbreak 393\n" ; gdb_expect -re "$gdb_prompt $"
230 "Continuing\\..*rename 4:.*EINVAL.*test_rename \\(\\) at.*$srcfile:393.*" \
231 "Renaming a directory to a subdir of itself returns EINVAL"
233 send_gdb "tbreak 397\n" ; gdb_expect -re "$gdb_prompt $"
235 "Continuing\\..*rename 5:.*ENOENT.*test_rename \\(\\) at.*$srcfile:397.*" \
236 "Renaming a nonexistant file returns ENOENT"
238 send_gdb "tbreak 412\n" ; gdb_expect -re "$gdb_prompt $"
240 "Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:412.*" \
243 send_gdb "tbreak 432\n" ; gdb_expect -re "$gdb_prompt $"
244 # This test fails on Cygwin because unlink() succeeds on Win32 systems
246 if [ishost *cygwin*] {
250 "Continuing\\..*unlink 2:.*EACCES.*test_unlink \\(\\) at.*$srcfile:432.*" \
251 "Unlinking a file in a directory w/o write access returns EACCES"
253 send_gdb "tbreak 436\n" ; gdb_expect -re "$gdb_prompt $"
255 "Continuing\\..*unlink 3:.*ENOENT.*test_unlink \\(\\) at.*$srcfile:436.*" \
256 "Unlinking a nonexistant file returns ENOENT"
258 send_gdb "tbreak 446\n" ; gdb_expect -re "$gdb_prompt $"
260 "Continuing\\..*time 1:.*OK.*test_time \\(\\) at.*$srcfile:446.*" \
261 "Time(2) call returns the same value as in parameter"
264 send_gdb "tbreak 450\n" ; gdb_expect -re "$gdb_prompt $"
266 "Continuing\\..*time 2:.*OK.*test_time \\(\\) at.*$srcfile:450.*" \
267 "Time(2) returns feasible values"
272 remote_exec build "test -r dir2.fileio.test && chmod -f +w dir2.fileio.test"
273 remote_exec build "rm -rf *.fileio.test"
275 set timeout $oldtimeout