Unbuffer all tests that rely on stdio
authorPedro Alves <palves@redhat.com>
Wed, 29 Jul 2015 10:09:45 +0000 (11:09 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 29 Jul 2015 10:09:45 +0000 (11:09 +0100)
This forces all tests that rely on stdio to be unbuffered, like
interrupt.exp was adjusted in 6f98576f.

To recap, in some scenarios, GDB or GDBserver can be spawned with
input _not_ connected to a tty, and then tests that rely on stdio fail
with timeouts, because the inferior's stdout and stderr streams end up
fully buffered.  Calling gdb_unbuffer_output forces output to be
unbuffered.

See https://sourceware.org/ml/gdb-patches/2015-02/msg00809.html and
https://sourceware.org/ml/gdb-patches/2015-02/msg00819.html.

Tested on x86_64 Fedora 20, native, and against a remote gdbserver
board file that connects to the target with ssh, with and without -t
(create pty).

gdb/testsuite/ChangeLog:
2015-07-29  Pedro Alves  <palves@redhat.com>

* gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-strs.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-strs.exp: Adjust to step over the
gdb_unbuffer_output call.
* gdb.base/catch-gdb-caused-signals.c: Include
"../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/ending-run.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/run.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/shlib-call.exp: Adjust to step over the
gdb_unbuffer_output call.
* gdb.base/shmain.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/sizeof.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/varargs.c: Include "../lib/unbuffer_output.c".
(main): Rename to ...
(test): ... this.
(main): Reimplement.
* gdb.base/varargs.exp: Run to test instead of to main.
* gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.

16 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/call-ar-st.c
gdb/testsuite/gdb.base/call-rt-st.c
gdb/testsuite/gdb.base/call-strs.c
gdb/testsuite/gdb.base/call-strs.exp
gdb/testsuite/gdb.base/catch-gdb-caused-signals.c
gdb/testsuite/gdb.base/dprintf.c
gdb/testsuite/gdb.base/ending-run.c
gdb/testsuite/gdb.base/run.c
gdb/testsuite/gdb.base/shlib-call.exp
gdb/testsuite/gdb.base/shmain.c
gdb/testsuite/gdb.base/sizeof.c
gdb/testsuite/gdb.base/sizeof.exp
gdb/testsuite/gdb.base/varargs.c
gdb/testsuite/gdb.base/varargs.exp
gdb/testsuite/gdb.mi/mi-dprintf.c

index 9b4bf6bc6c0b06ffe02136d9ab3f2cbae23cb29a..072a1083c907a584e0c0a1ece5dbbb466931ca89 100644 (file)
@@ -1,3 +1,36 @@
+2015-07-29  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/call-strs.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/call-strs.exp: Adjust to step over the
+       gdb_unbuffer_output call.
+       * gdb.base/catch-gdb-caused-signals.c: Include
+       "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/dprintf.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/ending-run.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/run.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/shlib-call.exp: Adjust to step over the
+       gdb_unbuffer_output call.
+       * gdb.base/shmain.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/sizeof.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+       * gdb.base/varargs.c: Include "../lib/unbuffer_output.c".
+       (main): Rename to ...
+       (test): ... this.
+       (main): Reimplement.
+       * gdb.base/varargs.exp: Run to test instead of to main.
+       * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
+       (main): Call gdb_unbuffer_output.
+
 2015-07-29  Pedro Alves  <palves@redhat.com>
 
        * gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure,
index 4b2ffb44625d045ad6144b5456fc189b3a47d301..497af840854392e032081c5a6f7a239a29c39ec7 100644 (file)
@@ -3,6 +3,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../lib/unbuffer_output.c"
+
 /**************************************************************************
  * TESTS :
  *   -- function arguments that are enumerated types
@@ -912,6 +914,8 @@ int main ()  {
    static struct two_floats_t      *f2;
    static struct two_floats_t      *f3;
 
+  gdb_unbuffer_output ();
+
   /* Initialize arrays
    */
   for (index = 0; index < 120; index++) {
index 944f1afff64d721c5103e553520958d560fccff1..072ea8601927f29975ec953478e5cdfe214eda45 100644 (file)
@@ -2,6 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../lib/unbuffer_output.c"
+
 /**************************************************************************
  * TESTS :
  * function returning large structures, which go on the stack
@@ -562,6 +564,7 @@ int main ()  {
    struct one_double_t      *d1;
    struct two_floats_t      *f3;
 
+  gdb_unbuffer_output ();
 
   /* Allocate space for large structures 
    */
index c0b18232c056ecf0442d6a0a7a892161bb9c6d7f..03a80647d7eaa130c8d4a6c2e19e38954b7c3db9 100644 (file)
@@ -2,6 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../lib/unbuffer_output.c"
+
 char buf[100];
 char bigbuf[1000];
 char * s;
@@ -47,6 +49,8 @@ link_malloc ()
 
 int main()
 {
+  gdb_unbuffer_output ();
+
   s = &buf[0];
   strcpy(buf, "test string");
   str_func("abcd", "efgh", "ijkl", "mnop", "qrst", "uvwx", "yz12");
index e11296f663962d72feb60488fd7efe285c0e86e1..96641e5328364f1e614e0f9acf003701a17f47a5 100644 (file)
@@ -57,8 +57,7 @@ if ![runto_main] then {
 set prev_timeout $timeout
 set timeout 120
 
-#step
-gdb_test "step" \
+gdb_test "next 2" \
     "strcpy\\(buf, \"test string\"\\);" \
     "step after assignment to s"
 
index 769858c81a053400c06533ebb9102d2be477b9a5..a2cdcb079b13e5da8672917179a9d7096577bc55 100644 (file)
 #include <unistd.h>
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 int
 main (void)
 {
   int i = 0;
 
+  gdb_unbuffer_output ();
+
   i++; /* set dprintf here */
   return 0; /* set breakpoint here */
 }
index 3fd3b3a23976caa45bb0646d2e91ef2de61e05a4..c0c3ce3f9069287ee5daafdcc59bed1635bb53e5 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 static int g;
 
 void
@@ -32,6 +34,8 @@ main (int argc, char *argv[])
 {
   int loc = 1234;
 
+  gdb_unbuffer_output ();
+
   /* Ensure these functions are available.  */
   printf ("kickoff %d\n", loc);
   fprintf (stderr, "also to stderr %d\n", loc);
index 42f12c0ae9bfce5808b85b33d92e2b14d0ff611d..1e09f1648775931bce225ac5b87d64f948f9ecb9 100644 (file)
@@ -4,6 +4,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../lib/unbuffer_output.c"
+
 int callee (int x)
 {
     int y = x * x;             /* -break1- */
@@ -16,6 +18,8 @@ int main()
     int *p;
     int i;
 
+    gdb_unbuffer_output ();
+
     p = (int *) malloc( 4 );
 
     for (i = 1; i < 10; i++)
index 0c6200258034d3a240c617efcc9a3a84f05db347..614b018260d7a213f016ec72acded19c0343bac1 100644 (file)
@@ -6,11 +6,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../lib/unbuffer_output.c"
+
 int factorial (int);
 
 int
 main (int argc, char **argv, char **envp)
 {
+  gdb_unbuffer_output ();
+
 #ifdef FAKEARGV
     printf ("%d\n", factorial (1)); /* commands.exp: hw local_var out of scope */
 #else    
index 2ccaa39ded9646ceae6e45e04f4b15f805b95acb..f48b6fbb578c4f199da84be33000da23bba863b9 100644 (file)
@@ -71,7 +71,7 @@ if ![runto_main] then {
 
 #step -over
 
-gdb_test "next" "g = shr1\\(g\\);" "next to shr1"
+gdb_test "next 2" "g = shr1\\(g\\);" "next to shr1"
 
 #print g
 
index e36f84f6daa33d45f197a0ea2169a89e10fde2a8..932b83477e2a948853ebd23523be2af6d553fab3 100644 (file)
@@ -3,6 +3,8 @@
 #include "ss.h"
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 extern int structarg(struct s);
 extern int pstructarg(struct s*);
 extern int shr1(int);
@@ -31,6 +33,9 @@ int mainshr1(int g)
 int main()
 {
   struct s y;
+
+  gdb_unbuffer_output ();
+
   g = 1;
   g = shr1(g);
   g = shr2(g);
index 9c67c035cd6e1024e87d0c3db6461812643868a5..eb21f22cc2e2d3e18d26e426a71be96f5bf32551 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 typedef char padding[16];
 
 struct {
@@ -98,6 +100,8 @@ fill_structs (void)
 int
 main ()
 {
+  gdb_unbuffer_output ();
+
   fill_structs ();
 
   printf ("sizeof (char) == %d\n", (int) sizeof (char));
index a237ee35ae4454dada175d533065253192d811d2..ce6b7edd9ebada98ca7ea76817a5fea473861597 100644 (file)
@@ -48,7 +48,7 @@ if ![runto_main] then {
 # Query GDB for the size of various types
 #
 
-gdb_test "next"
+gdb_test "next 2"
 
 set sizeof_char [get_sizeof "char" 1]
 set sizeof_short [get_sizeof "short" 2]
index 1ad2ffcfa7245fba2d37e7e2fae42e41a26ba74d..4c0f16547f4b7b4b3900a4a1a1377fb8c5baf0dd 100644 (file)
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#include "../lib/unbuffer_output.c"
+
 int find_max1(int, ...);
 int find_max2(int, int, ...);
 double find_max_double(int, double, ...);
@@ -45,7 +47,9 @@ long double _Complex ldc4 = 4.0L + 4.0Li;
 
 #endif
 
-int main() {
+int
+test (void)
+{
   c = -1;
   uc = 1;
   s = -2;
@@ -70,6 +74,13 @@ int main() {
   return 0;
 }
 
+int
+main (void)
+{
+  gdb_unbuffer_output ();
+  test ();
+}
+
 /* Integer varargs, 1 declared arg */
 
 int find_max1(int num_vals, ...) {
index 96933bbd2aa87faeab87a70bafa511ffefa4ca56..fe543143438014cde7baa15fe33c439bf0607b8c 100644 (file)
@@ -66,7 +66,7 @@ if [gdb_skip_stdio_test "varargs.exp"] {
     return
 }
 
-if ![runto_main] then {
+if ![runto test] then {
     perror "couldn't run to breakpoint"
     continue
 }
index 0b8fc82585467870d177e4ce06b6fa0ca3926123..2571e5012f89630718fa9a2b6ba58d75c750576b 100644 (file)
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../lib/unbuffer_output.c"
+
 static int g;
 
 void
@@ -34,6 +36,8 @@ main (int argc, char *argv[])
 {
   int loc = 1234;
 
+  gdb_unbuffer_output ();
+
   /* Ensure these functions are available.  */
   printf ("kickoff %d\n", loc);
   fprintf (stderr, "also to stderr %d\n", loc);
This page took 0.042339 seconds and 4 git commands to generate.