diff options
author | Andrew Cagney <cagney@redhat.com> | 2003-06-14 16:51:42 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2003-06-14 16:51:42 +0000 |
commit | b257a0d30ab67df224f603c928127f2e653660b9 (patch) | |
tree | c2ebf117c1a18bc257df34b5806d1208ba4e5aec /gdb | |
parent | eb01fc6294e34ebbe1d739bf8771fdd8a38d171a (diff) | |
download | gdb-b257a0d30ab67df224f603c928127f2e653660b9.zip gdb-b257a0d30ab67df224f603c928127f2e653660b9.tar.gz gdb-b257a0d30ab67df224f603c928127f2e653660b9.tar.bz2 |
2003-06-14 Andrew Cagney <cagney@redhat.com>
* gdb.base/fileio.c: Include <errno.h>, and <sys/wait.h>. Gag
-Wformat errors. Add lost line. Use WEXITSTATUS to get system
exit status.
* gdb.base/fileio.exp: Disable target when nointerrupts and
noinferiorio, instead of limiting it to remote. Use remote_exec
instead of system.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/fileio.c | 105 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/fileio.exp | 61 |
3 files changed, 113 insertions, 63 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4392f54..ed7d777 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2003-06-14 Andrew Cagney <cagney@redhat.com> + + * gdb.base/fileio.c: Include <errno.h>, and <sys/wait.h>. Gag + -Wformat errors. Add lost line. Use WEXITSTATUS to get system + exit status. + * gdb.base/fileio.exp: Disable target when nointerrupts and + noinferiorio, instead of limiting it to remote. Use remote_exec + instead of system. + + 2003-06-12 Jeff Johnston <jjohnstn@redhat.com> * gdb.base/float.exp: Add ia64 support. diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c index fd410cd..591b3b6 100644 --- a/gdb/testsuite/gdb.base/fileio.c +++ b/gdb/testsuite/gdb.base/fileio.c @@ -6,8 +6,9 @@ #include <sys/fcntl.h> #include <sys/stat.h> #include <sys/time.h> -/************************************************************************** - * TESTS : +#include <errno.h> +#include <sys/wait.h> +/* 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 @@ -53,15 +54,14 @@ time(time_t *t); Not applicable. system (const char * string); -1) Invalid string/command. - returns 127. +1) Invalid string/command. - returns 127. */ - ***************************************************************************/ +static const char *strerrno (int err); #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" @@ -84,21 +84,21 @@ test_open () 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" : ""); + strerrno (errno)); 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" : ""); + strerrno (errno)); 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" : ""); + strerrno (errno)); if (ret >= 0) close (ret); /* Open for write but no write permission */ @@ -110,7 +110,7 @@ test_open () errno = 0; ret = open (NOWRITE, O_WRONLY); printf ("open 5: ret = %d, errno = %d %s\n", ret, errno, - errno == EACCES ? "OK" : ""); + strerrno (errno)); if (ret >= 0) close (ret); } @@ -140,7 +140,7 @@ test_write () errno = 0; ret = write (999, STRING, strlen (STRING)); printf ("write 2: ret = %d, errno = %d, %s\n", ret, errno, - errno == EBADF ? "OK" : ""); + strerrno (errno)); /* Write to a read-only file */ errno = 0; fd = open (FILENAME, O_RDONLY); @@ -149,7 +149,7 @@ test_write () errno = 0; ret = write (fd, STRING, strlen (STRING)); printf ("write 3: ret = %d, errno = %d %s\n", ret, errno, - errno == EBADF ? "OK" : ""); + strerrno (errno)); } else printf ("write 3: ret = %d, errno = %d\n", ret, errno); @@ -182,14 +182,14 @@ test_read () errno = 0; ret = read (999, buf, 16); printf ("read 2: ret = %d, errno = %d %s\n", ret, errno, - errno == EBADF ? "OK" : ""); + strerrno (errno)); } int test_lseek () { int fd; - off_t ret; + off_t ret = 0; /* Test seeking */ errno = 0; @@ -198,15 +198,15 @@ test_lseek () { errno = 0; ret = lseek (fd, 0, SEEK_CUR); - printf ("lseek 1: ret = %ld, errno = %d, %s\n", ret, errno, + printf ("lseek 1: ret = %ld, errno = %d, %s\n", (long) ret, errno, ret == 0 ? "OK" : ""); errno = 0; ret = lseek (fd, 0, SEEK_END); - printf ("lseek 2: ret = %ld, errno = %d, %s\n", ret, errno, + printf ("lseek 2: ret = %ld, errno = %d, %s\n", (long) ret, errno, ret == 11 ? "OK" : ""); errno = 0; ret = lseek (fd, 3, SEEK_SET); - printf ("lseek 3: ret = %ld, errno = %d, %s\n", ret, errno, + printf ("lseek 3: ret = %ld, errno = %d, %s\n", (long) ret, errno, ret == 3 ? "OK" : ""); close (fd); } @@ -232,7 +232,7 @@ test_close () { errno = 0; ret = close (fd); - printf ("close 1: ret = %ld, errno = %d, %s\n", ret, errno, + printf ("close 1: ret = %d, errno = %d, %s\n", ret, errno, ret == 0 ? "OK" : ""); } else @@ -240,8 +240,8 @@ test_close () /* Close an invalid file descriptor */ errno = 0; ret = close (999); - printf ("close 2: ret = %ld, errno = %d, %s\n", ret, errno, - errno == EBADF ? "OK" : ""); + printf ("close 2: ret = %d, errno = %d, %s\n", ret, errno, + strerrno (errno)); } int @@ -262,17 +262,17 @@ test_stat () errno = 0; ret = stat (NULL, &st); printf ("stat 2: ret = %d, errno = %d %s\n", ret, errno, - errno == ENOENT ? "OK" : ""); + strerrno (errno)); /* Empty pathname */ errno = 0; ret = stat ("", &st); printf ("stat 3: ret = %d, errno = %d %s\n", ret, errno, - errno == ENOENT ? "OK" : ""); + strerrno (errno)); /* Nonexistant file */ errno = 0; ret = stat (NONEXISTANT, &st); printf ("stat 4: ret = %d, errno = %d %s\n", ret, errno, - errno == ENOENT ? "OK" : ""); + strerrno (errno)); } int @@ -301,7 +301,7 @@ test_fstat () errno = 0; ret = fstat (999, &st); printf ("fstat 2: ret = %d, errno = %d %s\n", ret, errno, - errno == EBADF ? "OK" : ""); + strerrno (errno)); } int @@ -326,6 +326,7 @@ test_isatty () printf ("isatty 5: file couldn't open\n"); } + int test_system () { @@ -344,7 +345,7 @@ test_system () 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" : ""); + printf ("system 2: ret = %d %s\n", ret, WEXITSTATUS (ret) == 127 ? "OK" : ""); } int @@ -365,7 +366,7 @@ test_rename () errno = 0; ret = stat (RENAMED, &st); printf ("rename 1: ret = %d, errno = %d %s\n", ret, errno, - errno == 0 ? "OK" : ""); + strerrno (errno)); errno = 0; } else @@ -377,22 +378,22 @@ test_rename () errno = 0; ret = rename (RENAMED, TESTDIR2); printf ("rename 2: ret = %d, errno = %d %s\n", ret, errno, - errno == EISDIR ? "OK" : ""); + strerrno (errno)); /* 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" : ""); + strerrno (errno)); /* 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" : ""); + strerrno (errno)); /* oldpath does not exist */ errno = 0; ret = rename (NONEXISTANT, FILENAME); printf ("rename 5: ret = %d, errno = %d %s\n", ret, errno, - errno == ENOENT ? "OK" : ""); + strerrno (errno)); } int @@ -406,7 +407,7 @@ test_unlink () errno = 0; ret = unlink (RENAMED); printf ("unlink 1: ret = %d, errno = %d %s\n", ret, errno, - errno == 0 ? "OK" : ""); + strerrno (errno)); /* No write access */ sprintf (name, "%s/%s", TESTDIR2, FILENAME); errno = 0; @@ -420,7 +421,7 @@ test_unlink () errno = 0; ret = unlink (name); printf ("unlink 2: ret = %d, errno = %d %s\n", ret, errno, - errno == EACCES ? "OK" : ""); + strerrno (errno)); } else printf ("unlink 2: ret = %d chmod failed\n", ret, errno); @@ -431,7 +432,7 @@ test_unlink () errno = 0; ret = unlink (NONEXISTANT); printf ("unlink 3: ret = %d, errno = %d %s\n", ret, errno, - errno == ENOENT ? "OK" : ""); + strerrno (errno)); } int @@ -441,11 +442,45 @@ test_time () errno = 0; ret = time (&t); - printf ("time 1: ret = %d, errno = %d, t = %d %s\n", ret, errno, t, ret == t ? "OK" : ""); + printf ("time 1: ret = %ld, errno = %d, t = %ld %s\n", (long) ret, errno, (long) 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" : ""); + printf ("time 2: ret = %ld, errno = %d, t = %ld %s\n", + (long) ret, errno, (long) t, ret >= t && ret < t + 10 ? "OK" : ""); +} + +static const char * +strerrno (int err) +{ + switch (err) + { + case 0: return "OK"; +#ifdef EACCES + case EACCES: return "EACCES"; +#endif +#ifdef EBADF + case EBADF: return "EBADF"; +#endif +#ifdef EEXIST + case EEXIST: return "EEXIST"; +#endif +#ifdef EFAULT + case EFAULT: return "EFAULT"; +#endif +#ifdef EINVAL + case EINVAL: return "EINVAL"; +#endif +#ifdef EISDIR + case EISDIR: return "EISDIR"; +#endif +#ifdef ENOENT + case ENOENT: return "ENOENT"; +#endif +#ifdef ENOTEMPTY + case ENOTEMPTY: return "ENOTEMPTY"; +#endif + default: return "E??"; + } } int diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp index 49e8c38..279f1ab 100644 --- a/gdb/testsuite/gdb.base/fileio.exp +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -20,6 +20,15 @@ # This file was written by Corinna Vinschen <vinschen@redhat.com> +if [target_info exists gdb,nointerrupts] { + verbose "Skipping interrupt.exp because of nointerrupts." + continue +} + +if [target_info exists gdb,noinferiorio] { + verbose "Skipping interrupt.exp because of noinferiorio." + return +} if $tracelevel then { strace $tracelevel @@ -32,11 +41,6 @@ set testfile "fileio" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -# test only on a remote target board -if {! [is_remote target]} { - return 0; -} - 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." } @@ -48,8 +52,8 @@ if [get_compiler_info ${binfile}] { return -1; } -catch "system \"chmod -f +w dir2.fileio.test\"" -catch "system \"rm -rf *.fileio.test\"" +remote_exec build "test -r dir2.fileio.test && chmod -f +w dir2.fileio.test" +remote_exec build "rm -rf *.fileio.test" set oldtimeout $timeout set timeout [expr "$timeout + 60"] @@ -77,17 +81,17 @@ gdb_test continue \ send_gdb "tbreak 88\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*open 2:.*OK.*test_open \\(\\) at.*$srcfile:88.*" \ +"Continuing\\..*open 2:.*EEXIST.*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.*" \ +"Continuing\\..*open 3:.*EISDIR.*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.*" \ +"Continuing\\..*open 4:.*ENOENT.*test_open \\(\\) at.*$srcfile:102.*" \ "Opening nonexistant file returns ENOENT" send_gdb "tbreak 109\n" ; gdb_expect -re "$gdb_prompt $" @@ -96,7 +100,7 @@ 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.*" \ +"Continuing\\..*open 5:.*EACCES.*test_open \\(\\) at.*$srcfile:119.*" \ "Open for write but no write permission returns EACCES" send_gdb "tbreak 140\n" ; gdb_expect -re "$gdb_prompt $" @@ -106,12 +110,12 @@ gdb_test continue \ send_gdb "tbreak 145\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*write 2:.*OK.*test_write \\(\\) at.*$srcfile:145.*" \ +"Continuing\\..*write 2:.*EBADF.*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.*" \ +"Continuing\\..*write 3:.*EBADF.*test_write \\(\\) at.*$srcfile:156.*" \ "Writing to a read-only file returns EBADF" send_gdb "tbreak 182\n" ; gdb_expect -re "$gdb_prompt $" @@ -121,7 +125,7 @@ gdb_test continue \ send_gdb "tbreak 186\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*read 2:.*OK.*test_read \\(\\) at.*$srcfile:186.*" \ +"Continuing\\..*read 2:.*EBADF.*test_read \\(\\) at.*$srcfile:186.*" \ "Read using invalid file descriptor returns EBADF" send_gdb "tbreak 221\n" ; gdb_expect -re "$gdb_prompt $" @@ -136,7 +140,7 @@ gdb_test continue \ send_gdb "tbreak 245\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*close 2:.*OK.*test_close \\(\\) at.*$srcfile:245.*" \ +"Continuing\\..*close 2:.*EBADF.*test_close \\(\\) at.*$srcfile:245.*" \ "Closing an invalid file descriptor returns EBADF" send_gdb "tbreak 262\n" ; gdb_expect -re "$gdb_prompt $" @@ -146,17 +150,17 @@ gdb_test continue \ 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" + "Continuing\\..*stat 2:.*(ENOENT|EFAULT).*test_stat \\(\\) at.*$srcfile:267.*" \ +"Stat a NULL pathname returns ENOENT or EFAULT" send_gdb "tbreak 272\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*stat 3:.*OK.*test_stat \\(\\) at.*$srcfile:272.*" \ +"Continuing\\..*stat 3:.*ENOENT.*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.*" \ +"Continuing\\..*stat 4:.*ENOENT.*test_stat \\(\\) at.*$srcfile:276.*" \ "Stat a nonexistant file returns ENOENT" send_gdb "tbreak 301\n" ; gdb_expect -re "$gdb_prompt $" @@ -166,7 +170,7 @@ gdb_test continue \ send_gdb "tbreak 305\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*fstat 2:.*OK.*test_fstat \\(\\) at.*$srcfile:305.*" \ +"Continuing\\..*fstat 2:.*EBADF.*test_fstat \\(\\) at.*$srcfile:305.*" \ "Fstat an invalid file descriptor returns EBADF" send_gdb "tbreak 314\n" ; gdb_expect -re "$gdb_prompt $" @@ -200,6 +204,7 @@ gdb_test continue \ "Continuing\\..*system 1:.*OK.*test_system \\(\\) at.*$srcfile:347.*" \ "System(3) call" +# Is this ok? POSIX says system returns a waitpid status? send_gdb "tbreak 349\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ "Continuing\\..*system 2:.*OK.*test_system \\(\\) at.*$srcfile:349.*" \ @@ -212,22 +217,22 @@ gdb_test continue \ send_gdb "tbreak 383\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*rename 2:.*OK.*test_rename \\(\\) at.*$srcfile:383.*" \ +"Continuing\\..*rename 2:.*EISDIR.*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.*" \ + "Continuing\\..*rename 3:.*(ENOTEMPTY|EEXIST).*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.*" \ +"Continuing\\..*rename 4:.*EINVAL.*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.*" \ +"Continuing\\..*rename 5:.*ENOENT.*test_rename \\(\\) at.*$srcfile:397.*" \ "Renaming a nonexistant file returns ENOENT" send_gdb "tbreak 412\n" ; gdb_expect -re "$gdb_prompt $" @@ -242,12 +247,12 @@ if [ishost *cygwin*] { setup_xfail "*-*-*" } gdb_test continue \ -"Continuing\\..*unlink 2:.*OK.*test_unlink \\(\\) at.*$srcfile:432.*" \ +"Continuing\\..*unlink 2:.*EACCES.*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.*" \ +"Continuing\\..*unlink 3:.*ENOENT.*test_unlink \\(\\) at.*$srcfile:436.*" \ "Unlinking a nonexistant file returns ENOENT" send_gdb "tbreak 446\n" ; gdb_expect -re "$gdb_prompt $" @@ -264,8 +269,8 @@ gdb_test continue \ send_gdb "quit\n" send_gdb "y\n" -catch "system \"chmod -f +w dir2.fileio.test\"" -catch "system \"rm -rf *.fileio.test\"" +remote_exec build "test -r dir2.fileio.test && chmod -f +w dir2.fileio.test" +remote_exec build "rm -rf *.fileio.test" set timeout $oldtimeout return 0 |