* [RFA]: File-I/O patch, testsuite
@ 2002-11-21 1:11 Corinna Vinschen
2003-05-21 22:51 ` Andrew Cagney
0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2002-11-21 1:11 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
Hi,
the following patch adds two files, fileio.c and fileio.exp, which test
the new File-I/O protocol.
However, this tests are currently running always, regardless if the
target implements this functionality or not. I'm not quite sure
about the best way to skip these tests for those targets...
Corinna
2002-11-21 Corinna Vinschen <vinschen@redhat.com>
* gdb.base/fileio.c: New file, testing File-I/O.
* gdb.base/fileio.exp: Ditto.
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com
[-- Attachment #2: fileio-testsuite.patch --]
[-- Type: text/plain, Size: 22641 bytes --]
Index: testsuite/gdb.base/fileio.c
===================================================================
RCS file: testsuite/gdb.base/fileio.c
diff -N testsuite/gdb.base/fileio.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/fileio.c 21 Nov 2002 09:08:05 -0000
@@ -0,0 +1,468 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/errno.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/time.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
+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;
+}
Index: testsuite/gdb.base/fileio.exp
===================================================================
RCS file: testsuite/gdb.base/fileio.exp
diff -N testsuite/gdb.base/fileio.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/fileio.exp 21 Nov 2002 09:08:05 -0000
@@ -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 <vinschen@redhat.com>
+
+
+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
+
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA]: File-I/O patch, testsuite
2002-11-21 1:11 [RFA]: File-I/O patch, testsuite Corinna Vinschen
@ 2003-05-21 22:51 ` Andrew Cagney
2003-05-22 6:52 ` Corinna Vinschen
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2003-05-21 22:51 UTC (permalink / raw)
To: Corinna Vinschen; +Cc: gdb-patches
Someone [me] finally back to looking at this testsuite stuff :-(
> the following patch adds two files, fileio.c and fileio.exp, which test
> the new File-I/O protocol.
>
> However, this tests are currently running always, regardless if the
> target implements this functionality or not. I'm not quite sure
> about the best way to skip these tests for those targets...
I was going to suggest:
> # test only on a remote target board
> if {! [is_remote target]} {
> return
> }
but it doesn't hurt to have this run native (should work?).
What about having the expect script recognize the failure mode and then
just unsupported out? Something like trying a file open / read first?
What about (from interrupt.exp):
> if [target_info exists gdb,noinferiorio] {
> verbose "Skipping interrupt.exp because of noinferiorio."
> return
> }
Doesn't dejagnu's remote config need updating? interrupt.exp, for
instance, should now work so the gdb,noinferiorio option should not be set).
Rather than
gdb_send
gdb_expect
can:
gdb_test
or similar be used?
I don't understand why:
+catch "system \"chmod -f +w dir2.fileio.test\""
+catch "system \"rm -rf *.fileio.test\""
appears twice.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA]: File-I/O patch, testsuite
2003-05-21 22:51 ` Andrew Cagney
@ 2003-05-22 6:52 ` Corinna Vinschen
2003-05-22 17:40 ` Andrew Cagney
0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2003-05-22 6:52 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Wed, May 21, 2003 at 06:51:05PM -0400, Andrew Cagney wrote:
> >However, this tests are currently running always, regardless if the
> >target implements this functionality or not. I'm not quite sure
> >about the best way to skip these tests for those targets...
>
> I was going to suggest:
>
> ># test only on a remote target board
> >if {! [is_remote target]} {
> > return
> >}
Yeah, we could add this. Sounds about right.
> but it doesn't hurt to have this run native (should work?).
It doesn't make any sense, though. :-)
> I don't understand why:
>
> +catch "system \"chmod -f +w dir2.fileio.test\""
> +catch "system \"rm -rf *.fileio.test\""
>
> appears twice.
Paranoid mode. The catches removes all files produced by the fileio tests
of a previous testsuite run and it does so at the end to not let them
hanging around when the test finishes. The test itself needs to have
a clean start, otherwise it produces a couple of annoying FAILs.
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA]: File-I/O patch, testsuite
2003-05-22 6:52 ` Corinna Vinschen
@ 2003-05-22 17:40 ` Andrew Cagney
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2003-05-22 17:40 UTC (permalink / raw)
To: Corinna Vinschen; +Cc: gdb-patches
> On Wed, May 21, 2003 at 06:51:05PM -0400, Andrew Cagney wrote:
>
>> >However, this tests are currently running always, regardless if the
>> >target implements this functionality or not. I'm not quite sure
>> >about the best way to skip these tests for those targets...
>
>>
>> I was going to suggest:
>>
>
>> ># test only on a remote target board
>> >if {! [is_remote target]} {
>> > return
>> >}
>
>
> Yeah, we could add this. Sounds about right.
but I think:
if [target_info exists gdb,noinferiorio] {
verbose "Skipping interrupt.exp because of noinferiorio."
return
}
is more correct. It's the lack of the I/O feature, and not the
remoteness that determines if the test should run.
>> but it doesn't hurt to have this run native (should work?).
>
>
> It doesn't make any sense, though. :-)
It would make maintenance easier. The more mainstream the test, the
more likely it is to be maintained. CF remote.exp which gets little
attention (suffering constant bit rot) because it is only run on remote
targets :-(
>> I don't understand why:
>>
>> +catch "system \"chmod -f +w dir2.fileio.test\""
>> +catch "system \"rm -rf *.fileio.test\""
>>
>> appears twice.
>
>
> Paranoid mode. The catches removes all files produced by the fileio tests
> of a previous testsuite run and it does so at the end to not let them
> hanging around when the test finishes. The test itself needs to have
> a clean start, otherwise it produces a couple of annoying FAILs.
Ah, ok.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-05-22 17:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-21 1:11 [RFA]: File-I/O patch, testsuite Corinna Vinschen
2003-05-21 22:51 ` Andrew Cagney
2003-05-22 6:52 ` Corinna Vinschen
2003-05-22 17:40 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox