This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
fileio test
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 05 Nov 2009 18:04:18 +0000
- Subject: fileio test
This patch fixes an augments the fileio shell test. By default system calls are
disallowed -- but the test expects them to be enabled. This patch fixes that
test and verifies that enabling system calls, does indeed enable them.
ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2009-11-05 Nathan Sidwell <nathan@codesourcery.com>
* gdb.base/fileio.exp: Add test for shell not available as well as
available.
* gdb.base/fileio.c (test_system): Check for shell twice.
Index: gdb.base/fileio.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 fileio.c
*** gdb.base/fileio.c 1 Oct 2009 15:39:13 -0000 1.11
--- gdb.base/fileio.c 5 Nov 2009 17:51:19 -0000
*************** time(time_t *t);
*** 55,61 ****
Not applicable.
system (const char * string);
! 1) Invalid string/command. - returns 127. */
static const char *strerrno (int err);
#define FILENAME "foo.fileio.test"
--- 55,65 ----
Not applicable.
system (const char * string);
! 1) See if shell available - returns 0
! 2) See if shell available - returns !0
! 3) Execute simple shell command - returns 0
! 4) Invalid string/command. - returns 127. */
!
static const char *strerrno (int err);
#define FILENAME "foo.fileio.test"
*************** test_system ()
*** 373,393 ****
int ret;
char sys[512];
! /* Test for shell */
ret = system (NULL);
! printf ("system 1: ret = %d %s\n", ret, ret != 0 ? "OK" : "");
stop ();
/* This test prepares the directory for test_rename() */
sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2);
ret = system (sys);
if (ret == 127)
! printf ("system 2: ret = %d /bin/sh unavailable???\n", ret);
else
! printf ("system 2: ret = %d %s\n", ret, ret == 0 ? "OK" : "");
stop ();
/* Invalid command (just guessing ;-) ) */
ret = system ("wrtzlpfrmpft");
! printf ("system 3: ret = %d %s\n", ret, WEXITSTATUS (ret) == 127 ? "OK" : "");
stop ();
}
--- 377,402 ----
int ret;
char sys[512];
! /* Test for shell (testsuite should have it disabled). */
! ret = system (NULL);
! printf ("system 1: ret = %d %s\n", ret, ret == 0 ? "OK" : "");
! stop ();
! /* Test for shell again (the testsuite will have enabled it now). */
ret = system (NULL);
! printf ("system 2: ret = %d %s\n", ret, ret != 0 ? "OK" : "");
stop ();
/* This test prepares the directory for test_rename() */
sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2);
ret = system (sys);
if (ret == 127)
! printf ("system 3: ret = %d /bin/sh unavailable???\n", ret);
else
! printf ("system 3: ret = %d %s\n", ret, ret == 0 ? "OK" : "");
stop ();
/* Invalid command (just guessing ;-) ) */
ret = system ("wrtzlpfrmpft");
! printf ("system 4: ret = %d %s\n", ret,
! WEXITSTATUS (ret) == 127 ? "OK" : "");
stop ();
}
Index: gdb.base/fileio.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.exp,v
retrieving revision 1.15
diff -c -3 -p -r1.15 fileio.exp
*** gdb.base/fileio.exp 3 Jan 2009 05:58:03 -0000 1.15
--- gdb.base/fileio.exp 5 Nov 2009 17:51:19 -0000
*************** gdb_test continue \
*** 179,194 ****
gdb_test continue \
"Continuing\\..*system 1:.*OK$stop_msg" \
! "System says shell is available"
send_gdb "set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $"
gdb_test continue \
"Continuing\\..*system 2:.*OK$stop_msg" \
"System(3) call"
# Is this ok? POSIX says system returns a waitpid status?
gdb_test continue \
! "Continuing\\..*system 3:.*OK$stop_msg" \
"System with invalid command returns 127"
gdb_test continue \
--- 179,199 ----
gdb_test continue \
"Continuing\\..*system 1:.*OK$stop_msg" \
! "System says shell is not available"
send_gdb "set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $"
+
gdb_test continue \
"Continuing\\..*system 2:.*OK$stop_msg" \
+ "System says shell is available"
+
+ gdb_test continue \
+ "Continuing\\..*system 3:.*OK$stop_msg" \
"System(3) call"
# Is this ok? POSIX says system returns a waitpid status?
gdb_test continue \
! "Continuing\\..*system 4:.*OK$stop_msg" \
"System with invalid command returns 127"
gdb_test continue \