Add system test before "set remote system-call-allowed 1" to fileio.exp
authorHui Zhu <teawater@gmail.com>
Wed, 4 Jun 2014 06:37:34 +0000 (14:37 +0800)
committerHui Zhu <teawater@gmail.com>
Wed, 4 Jun 2014 06:38:16 +0000 (14:38 +0800)
This patch is update version according to the discussion in
https://www.sourceware.org/ml/gdb-patches/2009-11/msg00090.html.
If test get the target doesn't support fileio system according to the
remote log.   It will set this test as "unsupported".

Before I made this patch, I want add a check before all of tests in this
file.  But I found that the target maybe support one call but not others.
For example: my target support Fwrite, Fopen and so on.  But not Fgettimeofday.
And it doesn't support Fsystem NULL but it support Fsystem not NULL.
So I think if we want to check target support fileio, we need check them
one by one.

2014-06-04  Nathan Sidwell  <nathan@codesourcery.com>
    Hui Zhu  <hui@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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/fileio.c
gdb/testsuite/gdb.base/fileio.exp

index e15237c36679fcc6557eab81d9946da9c54711bb..2720d7049b2ec223ed507a14075fe5585ab075f5 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-04  Nathan Sidwell  <nathan@codesourcery.com>
+           Hui Zhu  <hui@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.
+
 2014-06-04  Yao Qi  <yao@codesourcery.com>
 
        * gdb.base/auto-connect-native-target.exp: Remove redundant
index 4926c05d2b82a1e5b325544e769d47a832cf24fe..b8c269817286841af75fa1aabadef772698437de 100644 (file)
@@ -55,7 +55,11 @@ time(time_t *t);
 Not applicable.
 
 system (const char * string);
-1) Invalid string/command. -  returns 127.  */
+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);
 
 /* Note that OUTDIR is defined by the test suite.  */
@@ -375,21 +379,27 @@ test_system ()
    */
   int ret;
 
-  /* Test for shell */
+  /* Test for shell ('set remote system-call-allowed' is disabled
+     by default).  */
+  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 1: ret = %d %s\n", ret, ret != 0 ? "OK" : "");
+  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 %s/%s", OUTDIR, TESTSUBDIR, OUTDIR, TESTDIR2);
   ret = system (sys);
   if (ret == 127)
-    printf ("system 2: ret = %d /bin/sh unavailable???\n", ret);
+    printf ("system 3: ret = %d /bin/sh unavailable???\n", ret);
   else
-    printf ("system 2: ret = %d %s\n", ret, ret == 0 ? "OK" : "");
+    printf ("system 3: 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" : "");
+  printf ("system 4: ret = %d %s\n", ret,
+         WEXITSTATUS (ret) == 127 ? "OK" : "");
   stop ();
 }
 
index 663a41a73c4fc7d055e38b742eb7eff837d836d4..89f0997c71e0244b5efd7d05fa5fbd32f6e8b252 100644 (file)
@@ -180,19 +180,34 @@ gdb_test continue \
 "Continuing\\..*isatty 5:.*OK$stop_msg" \
 "Isatty (open file)"
 
-gdb_test continue \
-"Continuing\\..*system 1:.*OK$stop_msg" \
-"System says shell is available"
+gdb_test_no_output "set debug remote 1"
+set msg "System says shell is not available"
+gdb_test_multiple "continue" $msg {
+    -re "Continuing\\..*Fsystem.*system 1:.*OK$stop_msg\r\n$gdb_prompt $" {
+       pass $msg
+    }
+    -re ".*Fsystem.*$gdb_prompt $" {
+       fail $msg
+    }
+    -re "$gdb_prompt $" {
+       unsupported $msg
+    }
+}
+gdb_test_no_output "set debug remote 0"
 
 gdb_test_no_output "set remote system-call-allowed 1"
 
 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 3:.*OK$stop_msg" \
+"Continuing\\..*system 4:.*OK$stop_msg" \
 "System with invalid command returns 127"
 
 gdb_test continue \
This page took 0.03007 seconds and 4 git commands to generate.