From 6aeb981f43b9a523832fa3c5c86bbc2f71e881ea Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 10 Jun 2003 14:38:04 +0000 Subject: [PATCH] * gdb.base/fileio.c: New file, testing File-I/O. * gdb.base/fileio.exp: Ditto. --- gdb/testsuite/ChangeLog | 5 + gdb/testsuite/gdb.base/fileio.c | 468 ++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/fileio.exp | 267 +++++++++++++++++ 3 files changed, 740 insertions(+) create mode 100644 gdb/testsuite/gdb.base/fileio.c create mode 100644 gdb/testsuite/gdb.base/fileio.exp diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 61e95370415..50b969ce599 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-06-10 Corinna Vinschen + + * gdb.base/fileio.c: New file, testing File-I/O. + * gdb.base/fileio.exp: Ditto. + 2003-06-09 Raoul Gough * gdb.base/shreloc.exp: New file, check symbol values obtained from diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c new file mode 100644 index 00000000000..fd410cd24fc --- /dev/null +++ b/gdb/testsuite/gdb.base/fileio.c @@ -0,0 +1,468 @@ +#include +#include +#include +#include +#include +#include +#include +#include +/************************************************************************** + * TESTS : + * - open(const char *pathname, int flags, mode_t mode); +1) Attempt to create file that already exists - EEXIST +2) Attempt to open a directory for writing - EISDIR +3) Pathname does not exist - ENOENT +4) Open for write but no write permission - EACCES + +read(int fd, void *buf, size_t count); +1) Read using invalid file descriptor - EBADF + +write(int fd, const void *buf, size_t count); +1) Write using invalid file descriptor - EBADF +2) Attempt to write to read-only file - EBADF + +lseek(int fildes, off_t offset, int whence); +1) Seeking on an invalid file descriptor - EBADF +2) Invalid "whence" (3rd param) value - EINVAL + +close(int fd); +1) Attempt to close an invalid file descriptor - EBADF + +stat(const char *file_name, struct stat *buf); +1) Pathname is a null string - ENOENT +2) Pathname does not exist - ENOENT + +fstat(int filedes, struct stat *buf); +1) Attempt to stat using an invalid file descriptor - EBADF + +isatty (int desc); +Not applicable. We will test that it returns 1 when expected and a case +where it should return 0. + +rename(const char *oldpath, const char *newpath); +1) newpath is an existing directory, but oldpath is not a directory. - EISDIR +2) newpath is a non-empty directory. - ENOTEMPTY or EEXIST +3) newpath is a subdirectory of old path. - EINVAL +4) oldpath does not exist. - ENOENT + +unlink(const char *pathname); +1) pathname does not have write access. - EACCES +2) pathname does not exist. - ENOENT + +time(time_t *t); +Not applicable. + +system (const char * string); +1) Invalid string/command. - returns 127. + + ***************************************************************************/ + +#define FILENAME "foo.fileio.test" +#define RENAMED "bar.fileio.test" +#define NONEXISTANT "nofoo.fileio.test" +#define NOWRITE "nowrt.fileio.test" + +#define TESTDIR1 "dir1.fileio.test" +#define TESTDIR2 "dir2.fileio.test" +#define TESTSUBDIR "dir1.fileio.test/subdir.fileio.test" + +#define STRING "Hello World" + +int +test_open () +{ + int ret; + + /* Test opening */ + errno = 0; + ret = open (FILENAME, O_CREAT | O_TRUNC | O_RDONLY, S_IWUSR | S_IRUSR); + printf ("open 1: ret = %d, errno = %d %s\n", ret, errno, + ret >= 0 ? "OK" : ""); + if (ret >= 0) + close (ret); + /* Creating an already existing file (created by fileio.exp) */ + errno = 0; + ret = open (FILENAME, O_CREAT | O_EXCL | O_WRONLY, S_IWUSR | S_IRUSR); + printf ("open 2: ret = %d, errno = %d %s\n", ret, errno, + errno == EEXIST ? "OK" : ""); + if (ret >= 0) + close (ret); + /* Open directory (for writing) */ + errno = 0; + ret = open (".", O_WRONLY); + printf ("open 3: ret = %d, errno = %d %s\n", ret, errno, + errno == EISDIR ? "OK" : ""); + if (ret >= 0) + close (ret); + /* Opening nonexistant file */ + errno = 0; + ret = open (NONEXISTANT, O_RDONLY); + printf ("open 4: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOENT ? "OK" : ""); + if (ret >= 0) + close (ret); + /* Open for write but no write permission */ + errno = 0; + ret = open (NOWRITE, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); + if (ret >= 0) + { + close (ret); + errno = 0; + ret = open (NOWRITE, O_WRONLY); + printf ("open 5: ret = %d, errno = %d %s\n", ret, errno, + errno == EACCES ? "OK" : ""); + if (ret >= 0) + close (ret); + } + else + printf ("open 5: ret = %d, errno = %d\n", ret, errno); +} + +int +test_write () +{ + int fd, ret; + + /* Test writing */ + errno = 0; + fd = open (FILENAME, O_WRONLY); + if (fd >= 0) + { + errno = 0; + ret = write (fd, STRING, strlen (STRING)); + printf ("write 1: ret = %d, errno = %d %s\n", ret, errno, + ret == strlen (STRING) ? "OK" : ""); + close (fd); + } + else + printf ("write 1: ret = %d, errno = %d\n", ret, errno); + /* Write using invalid file descriptor */ + errno = 0; + ret = write (999, STRING, strlen (STRING)); + printf ("write 2: ret = %d, errno = %d, %s\n", ret, errno, + errno == EBADF ? "OK" : ""); + /* Write to a read-only file */ + errno = 0; + fd = open (FILENAME, O_RDONLY); + if (fd >= 0) + { + errno = 0; + ret = write (fd, STRING, strlen (STRING)); + printf ("write 3: ret = %d, errno = %d %s\n", ret, errno, + errno == EBADF ? "OK" : ""); + } + else + printf ("write 3: ret = %d, errno = %d\n", ret, errno); +} + +int +test_read () +{ + int fd, ret; + char buf[16]; + + /* Test reading */ + errno = 0; + fd = open (FILENAME, O_RDONLY); + if (fd >= 0) + { + memset (buf, 0, 16); + errno = 0; + ret = read (fd, buf, 16); + buf[15] = '\0'; /* Don't trust anybody... */ + if (ret == strlen (STRING)) + printf ("read 1: %s %s\n", buf, !strcmp (buf, STRING) ? "OK" : ""); + else + printf ("read 1: ret = %d, errno = %d\n", ret, errno); + close (fd); + } + else + printf ("read 1: ret = %d, errno = %d\n", ret, errno); + /* Read using invalid file descriptor */ + errno = 0; + ret = read (999, buf, 16); + printf ("read 2: ret = %d, errno = %d %s\n", ret, errno, + errno == EBADF ? "OK" : ""); +} + +int +test_lseek () +{ + int fd; + off_t ret; + + /* Test seeking */ + errno = 0; + fd = open (FILENAME, O_RDONLY); + if (fd >= 0) + { + errno = 0; + ret = lseek (fd, 0, SEEK_CUR); + printf ("lseek 1: ret = %ld, errno = %d, %s\n", ret, errno, + ret == 0 ? "OK" : ""); + errno = 0; + ret = lseek (fd, 0, SEEK_END); + printf ("lseek 2: ret = %ld, errno = %d, %s\n", ret, errno, + ret == 11 ? "OK" : ""); + errno = 0; + ret = lseek (fd, 3, SEEK_SET); + printf ("lseek 3: ret = %ld, errno = %d, %s\n", ret, errno, + ret == 3 ? "OK" : ""); + close (fd); + } + else + { + printf ("lseek 1: ret = %d, errno = %d\n", ret, errno); + printf ("lseek 2: ret = %d, errno = %d\n", ret, errno); + printf ("lseek 3: ret = %d, errno = %d\n", ret, errno); + } + /* Seeking on an invalid file descriptor */ + +} + +int +test_close () +{ + int fd, ret; + + /* Test close */ + errno = 0; + fd = open (FILENAME, O_RDONLY); + if (fd >= 0) + { + errno = 0; + ret = close (fd); + printf ("close 1: ret = %ld, errno = %d, %s\n", ret, errno, + ret == 0 ? "OK" : ""); + } + else + printf ("close 1: ret = %d, errno = %d\n", ret, errno); + /* Close an invalid file descriptor */ + errno = 0; + ret = close (999); + printf ("close 2: ret = %ld, errno = %d, %s\n", ret, errno, + errno == EBADF ? "OK" : ""); +} + +int +test_stat () +{ + int ret; + struct stat st; + + /* Test stat */ + errno = 0; + ret = stat (FILENAME, &st); + if (!ret) + printf ("stat 1: ret = %d, errno = %d %s\n", ret, errno, + st.st_size == 11 ? "OK" : ""); + else + printf ("stat 1: ret = %d, errno = %d\n", ret, errno); + /* NULL pathname */ + errno = 0; + ret = stat (NULL, &st); + printf ("stat 2: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOENT ? "OK" : ""); + /* Empty pathname */ + errno = 0; + ret = stat ("", &st); + printf ("stat 3: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOENT ? "OK" : ""); + /* Nonexistant file */ + errno = 0; + ret = stat (NONEXISTANT, &st); + printf ("stat 4: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOENT ? "OK" : ""); +} + +int +test_fstat () +{ + int fd, ret; + struct stat st; + + /* Test fstat */ + errno = 0; + fd = open (FILENAME, O_RDONLY); + if (fd >= 0) + { + errno = 0; + ret = fstat (fd, &st); + if (!ret) + printf ("fstat 1: ret = %d, errno = %d %s\n", ret, errno, + st.st_size == 11 ? "OK" : ""); + else + printf ("fstat 1: ret = %d, errno = %d\n", ret, errno); + close (fd); + } + else + printf ("fstat 1: ret = %d, errno = %d\n", ret, errno); + /* Fstat using invalid file descriptor */ + errno = 0; + ret = fstat (999, &st); + printf ("fstat 2: ret = %d, errno = %d %s\n", ret, errno, + errno == EBADF ? "OK" : ""); +} + +int +test_isatty () +{ + int fd; + + /* Check std I/O */ + printf ("isatty 1: stdin %s\n", isatty (0) ? "yes OK" : "no"); + printf ("isatty 2: stdout %s\n", isatty (1) ? "yes OK" : "no"); + printf ("isatty 3: stderr %s\n", isatty (2) ? "yes OK" : "no"); + /* Check invalid fd */ + printf ("isatty 4: invalid %s\n", isatty (999) ? "yes" : "no OK"); + /* Check open file */ + fd = open (FILENAME, O_RDONLY); + if (fd >= 0) + { + printf ("isatty 5: file %s\n", isatty (fd) ? "yes" : "no OK"); + close (fd); + } + else + printf ("isatty 5: file couldn't open\n"); +} + +int +test_system () +{ + /* + * Requires test framework to switch on "set remote system-call-allowed 1" + */ + int ret; + char sys[512]; + + /* This test prepares the directory for test_rename() */ + sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2); + ret = system (sys); + if (ret == 127) + printf ("system 1: ret = %d /bin/sh unavailable???\n", ret); + else + printf ("system 1: ret = %d %s\n", ret, ret == 0 ? "OK" : ""); + /* Invalid command (just guessing ;-) ) */ + ret = system ("wrtzlpfrmpft"); + printf ("system 2: ret = %d %s\n", ret, ret == 127 ? "OK" : ""); +} + +int +test_rename () +{ + int ret; + struct stat st; + + /* Test rename */ + errno = 0; + ret = rename (FILENAME, RENAMED); + if (!ret) + { + errno = 0; + ret = stat (FILENAME, &st); + if (ret && errno == ENOENT) + { + errno = 0; + ret = stat (RENAMED, &st); + printf ("rename 1: ret = %d, errno = %d %s\n", ret, errno, + errno == 0 ? "OK" : ""); + errno = 0; + } + else + printf ("rename 1: ret = %d, errno = %d\n", ret, errno); + } + else + printf ("rename 1: ret = %d, errno = %d\n", ret, errno); + /* newpath is existing directory, oldpath is not a directory */ + errno = 0; + ret = rename (RENAMED, TESTDIR2); + printf ("rename 2: ret = %d, errno = %d %s\n", ret, errno, + errno == EISDIR ? "OK" : ""); + /* newpath is a non-empty directory */ + errno = 0; + ret = rename (TESTDIR2, TESTDIR1); + printf ("rename 3: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOTEMPTY || errno == EEXIST ? "OK" : ""); + /* newpath is a subdirectory of old path */ + errno = 0; + ret = rename (TESTDIR1, TESTSUBDIR); + printf ("rename 4: ret = %d, errno = %d %s\n", ret, errno, + errno == EINVAL ? "OK" : ""); + /* oldpath does not exist */ + errno = 0; + ret = rename (NONEXISTANT, FILENAME); + printf ("rename 5: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOENT ? "OK" : ""); +} + +int +test_unlink () +{ + int ret; + char name[256]; + char sys[512]; + + /* Test unlink */ + errno = 0; + ret = unlink (RENAMED); + printf ("unlink 1: ret = %d, errno = %d %s\n", ret, errno, + errno == 0 ? "OK" : ""); + /* No write access */ + sprintf (name, "%s/%s", TESTDIR2, FILENAME); + errno = 0; + ret = open (name, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); + if (ret >= 0) + { + sprintf (sys, "chmod -w %s", TESTDIR2); + ret = system (sys); + if (!ret) + { + errno = 0; + ret = unlink (name); + printf ("unlink 2: ret = %d, errno = %d %s\n", ret, errno, + errno == EACCES ? "OK" : ""); + } + else + printf ("unlink 2: ret = %d chmod failed\n", ret, errno); + } + else + printf ("unlink 2: ret = %d, errno = %d\n", ret, errno); + /* pathname doesn't exist */ + errno = 0; + ret = unlink (NONEXISTANT); + printf ("unlink 3: ret = %d, errno = %d %s\n", ret, errno, + errno == ENOENT ? "OK" : ""); +} + +int +test_time () +{ + time_t ret, t; + + errno = 0; + ret = time (&t); + printf ("time 1: ret = %d, errno = %d, t = %d %s\n", ret, errno, t, ret == t ? "OK" : ""); + errno = 0; + ret = time (NULL); + printf ("time 2: ret = %d, errno = %d, t = %d %s\n", ret, errno, t, + ret >= t && ret < t + 10 ? "OK" : ""); +} + +int +main () +{ + /* Don't change the order of the calls. They partly depend on each other */ + test_open (); + test_write (); + test_read (); + test_lseek (); + test_close (); + test_stat (); + test_fstat (); + test_isatty (); + test_system (); + test_rename (); + test_unlink (); + test_time (); + return 0; +} diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp new file mode 100644 index 00000000000..e7e61d53f19 --- /dev/null +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -0,0 +1,267 @@ +# Copyright 2002 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Corinna Vinschen + + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile "fileio" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# Create and source the file that provides information about the compiler +# used to compile the test case. + +if [get_compiler_info ${binfile}] { + return -1; +} + +catch "system \"chmod -f +w dir2.fileio.test\"" +catch "system \"rm -rf *.fileio.test\"" + +set oldtimeout $timeout +set timeout [expr "$timeout + 60"] + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" +send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $" +send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "tbreak 81\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*open 1:.*OK.*test_open \\(\\) at.*$srcfile:81.*" \ +"Open a file" + +send_gdb "tbreak 88\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*open 2:.*OK.*test_open \\(\\) at.*$srcfile:88.*" \ +"Creating already existing file returns EEXIST" + +send_gdb "tbreak 95\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*open 3:.*OK.*test_open \\(\\) at.*$srcfile:95.*" \ +"Open directory for writing returns EISDIR" + +send_gdb "tbreak 102\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*open 4:.*OK.*test_open \\(\\) at.*$srcfile:102.*" \ +"Opening nonexistant file returns ENOENT" + +send_gdb "tbreak 109\n" ; gdb_expect -re "$gdb_prompt $" +send_gdb "continue\n" ; gdb_expect -re "$gdb_prompt $" +catch "system \"chmod -f -w nowrt.fileio.test\"" + +send_gdb "tbreak 119\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*open 5:.*OK.*test_open \\(\\) at.*$srcfile:119.*" \ +"Open for write but no write permission returns EACCES" + +send_gdb "tbreak 140\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*write 1:.*OK.*test_write \\(\\) at.*$srcfile:140.*" \ +"Writing to a file" + +send_gdb "tbreak 145\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*write 2:.*OK.*test_write \\(\\) at.*$srcfile:145.*" \ +"Write using invalid file descriptor returns EBADF" + +send_gdb "tbreak 156\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*write 3:.*OK.*test_write \\(\\) at.*$srcfile:156.*" \ +"Writing to a read-only file returns EBADF" + +send_gdb "tbreak 182\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*read 1:.*OK.*test_read \\(\\) at.*$srcfile:182.*" \ +"Reading from a file" + +send_gdb "tbreak 186\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*read 2:.*OK.*test_read \\(\\) at.*$srcfile:186.*" \ +"Read using invalid file descriptor returns EBADF" + +send_gdb "tbreak 221\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*lseek 1:.*OK.*lseek 2:.*OK.*lseek 3:.*OK.*test_lseek \\(\\) at.*$srcfile:221.*" \ +"Lseeking a file" + +send_gdb "tbreak 241\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*close 1:.*OK.*test_close \\(\\) at.*$srcfile:241.*" \ +"Closing a file" + +send_gdb "tbreak 245\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*close 2:.*OK.*test_close \\(\\) at.*$srcfile:245.*" \ +"Closing an invalid file descriptor returns EBADF" + +send_gdb "tbreak 262\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*stat 1:.*OK.*test_stat \\(\\) at.*$srcfile:262.*" \ +"Stat a file" + +send_gdb "tbreak 267\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*stat 2:.*OK.*test_stat \\(\\) at.*$srcfile:267.*" \ +"Stat a NULL pathname returns ENOENT" + +send_gdb "tbreak 272\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*stat 3:.*OK.*test_stat \\(\\) at.*$srcfile:272.*" \ +"Stat an empty pathname returns ENOENT" + +send_gdb "tbreak 276\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*stat 4:.*OK.*test_stat \\(\\) at.*$srcfile:276.*" \ +"Stat a nonexistant file returns ENOENT" + +send_gdb "tbreak 301\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*fstat 1:.*OK.*test_fstat \\(\\) at.*$srcfile:301.*" \ +"Fstat an open file" + +send_gdb "tbreak 305\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*fstat 2:.*OK.*test_fstat \\(\\) at.*$srcfile:305.*" \ +"Fstat an invalid file descriptor returns EBADF" + +send_gdb "tbreak 314\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*isatty 1:.*OK.*test_isatty \\(\\) at.*$srcfile:314.*" \ +"Isatty (stdin)" + +send_gdb "tbreak 315\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*isatty 2:.*OK.*test_isatty \\(\\) at.*$srcfile:315.*" \ +"Isatty (stdout)" + +send_gdb "tbreak 317\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*isatty 3:.*OK.*test_isatty \\(\\) at.*$srcfile:317.*" \ +"Isatty (stderr)" + +send_gdb "tbreak 319\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*isatty 4:.*OK.*test_isatty \\(\\) at.*$srcfile:319.*" \ +"Isatty (invalid fd)" + +send_gdb "tbreak 327\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*isatty 5:.*OK.*test_isatty \\(\\) at.*$srcfile:327.*" \ +"Isatty (open file)" + +send_gdb "set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $" +send_gdb "tbreak 347\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*system 1:.*OK.*test_system \\(\\) at.*$srcfile:347.*" \ +"System(3) call" + +send_gdb "tbreak 349\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*system 2:.*OK.*test_system \\(\\) at.*$srcfile:349.*" \ +"System with invalid command returns 127" + +send_gdb "tbreak 378\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*rename 1:.*OK.*test_rename \\(\\) at.*$srcfile:378.*" \ +"Rename a file" + +send_gdb "tbreak 383\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*rename 2:.*OK.*test_rename \\(\\) at.*$srcfile:383.*" \ +"Renaming a file to existing directory returns EISDIR" + +send_gdb "tbreak 388\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*rename 3:.*OK.*test_rename \\(\\) at.*$srcfile:388.*" \ +"Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST" + +send_gdb "tbreak 393\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*rename 4:.*OK.*test_rename \\(\\) at.*$srcfile:393.*" \ +"Renaming a directory to a subdir of itself returns EINVAL" + +send_gdb "tbreak 397\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*rename 5:.*OK.*test_rename \\(\\) at.*$srcfile:397.*" \ +"Renaming a nonexistant file returns ENOENT" + +send_gdb "tbreak 412\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:412.*" \ +"Unlink a file" + +send_gdb "tbreak 432\n" ; gdb_expect -re "$gdb_prompt $" +# This test fails on Cygwin because unlink() succeeds on Win32 systems +# in that situation. +if [ishost *cygwin*] { + setup_xfail "*-*-*" +} +gdb_test continue \ +"Continuing\\..*unlink 2:.*OK.*test_unlink \\(\\) at.*$srcfile:432.*" \ +"Unlinking a file in a directory w/o write access returns EACCES" + +send_gdb "tbreak 436\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*unlink 3:.*OK.*test_unlink \\(\\) at.*$srcfile:436.*" \ +"Unlinking a nonexistant file returns ENOENT" + +send_gdb "tbreak 446\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*time 1:.*OK.*test_time \\(\\) at.*$srcfile:446.*" \ +"Time(2) call returns the same value as in parameter" + +sleep 2 +send_gdb "tbreak 450\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test continue \ +"Continuing\\..*time 2:.*OK.*test_time \\(\\) at.*$srcfile:450.*" \ +"Time(2) returns feasible values" + +send_gdb "quit\n" +send_gdb "y\n" + +catch "system \"chmod -f +w dir2.fileio.test\"" +catch "system \"rm -rf *.fileio.test\"" + +set timeout $oldtimeout +return 0 + -- 2.30.2