Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* fileio test
@ 2009-11-05 18:04 Nathan Sidwell
  2009-11-09 20:14 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Sidwell @ 2009-11-05 18:04 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 327 bytes --]

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


[-- Attachment #2: fileio-test.patch --]
[-- Type: text/x-patch, Size: 4140 bytes --]

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 \

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-10 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05 18:04 fileio test Nathan Sidwell
2009-11-09 20:14 ` Daniel Jacobowitz
2009-11-10 10:55   ` Nathan Sidwell
2009-11-10 19:12     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox