From patchwork Tue Apr 21 18:08:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6368 Received: (qmail 97367 invoked by alias); 21 Apr 2015 18:09:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 96332 invoked by uid 89); 21 Apr 2015 18:09:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 21 Apr 2015 18:08:57 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3LI8ueT026477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 21 Apr 2015 14:08:56 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3LI8WLB028722 for ; Tue, 21 Apr 2015 14:08:55 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 22/24] Unbuffer all tests that rely on stdio Date: Tue, 21 Apr 2015 19:08:29 +0100 Message-Id: <1429639711-16459-23-git-send-email-palves@redhat.com> In-Reply-To: <1429639711-16459-1-git-send-email-palves@redhat.com> References: <1429639711-16459-1-git-send-email-palves@redhat.com> 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-04-21 Pedro Alves * 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. --- gdb/testsuite/gdb.base/call-ar-st.c | 4 ++++ gdb/testsuite/gdb.base/call-rt-st.c | 3 +++ gdb/testsuite/gdb.base/call-strs.c | 4 ++++ gdb/testsuite/gdb.base/call-strs.exp | 3 +-- gdb/testsuite/gdb.base/catch-gdb-caused-signals.c | 4 ++++ gdb/testsuite/gdb.base/dprintf.c | 4 ++++ gdb/testsuite/gdb.base/ending-run.c | 4 ++++ gdb/testsuite/gdb.base/run.c | 4 ++++ gdb/testsuite/gdb.base/shlib-call.exp | 2 +- gdb/testsuite/gdb.base/shmain.c | 5 +++++ gdb/testsuite/gdb.base/sizeof.c | 4 ++++ gdb/testsuite/gdb.base/sizeof.exp | 2 +- gdb/testsuite/gdb.base/varargs.c | 13 ++++++++++++- gdb/testsuite/gdb.base/varargs.exp | 2 +- gdb/testsuite/gdb.mi/mi-dprintf.c | 4 ++++ 15 files changed, 56 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.base/call-ar-st.c b/gdb/testsuite/gdb.base/call-ar-st.c index 4b2ffb4..497af84 100644 --- a/gdb/testsuite/gdb.base/call-ar-st.c +++ b/gdb/testsuite/gdb.base/call-ar-st.c @@ -3,6 +3,8 @@ #include #include +#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++) { diff --git a/gdb/testsuite/gdb.base/call-rt-st.c b/gdb/testsuite/gdb.base/call-rt-st.c index 944f1af..072ea86 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.c +++ b/gdb/testsuite/gdb.base/call-rt-st.c @@ -2,6 +2,8 @@ #include #include +#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 */ diff --git a/gdb/testsuite/gdb.base/call-strs.c b/gdb/testsuite/gdb.base/call-strs.c index c0b1823..03a8064 100644 --- a/gdb/testsuite/gdb.base/call-strs.c +++ b/gdb/testsuite/gdb.base/call-strs.c @@ -2,6 +2,8 @@ #include #include +#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"); diff --git a/gdb/testsuite/gdb.base/call-strs.exp b/gdb/testsuite/gdb.base/call-strs.exp index e11296f..96641e5 100644 --- a/gdb/testsuite/gdb.base/call-strs.exp +++ b/gdb/testsuite/gdb.base/call-strs.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c index 769858c..a2cdcb0 100644 --- a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c +++ b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c @@ -20,11 +20,15 @@ #include #include +#include "../lib/unbuffer_output.c" + int main (void) { int i = 0; + gdb_unbuffer_output (); + i++; /* set dprintf here */ return 0; /* set breakpoint here */ } diff --git a/gdb/testsuite/gdb.base/dprintf.c b/gdb/testsuite/gdb.base/dprintf.c index 3fd3b3a..c0c3ce3 100644 --- a/gdb/testsuite/gdb.base/dprintf.c +++ b/gdb/testsuite/gdb.base/dprintf.c @@ -17,6 +17,8 @@ #include +#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); diff --git a/gdb/testsuite/gdb.base/ending-run.c b/gdb/testsuite/gdb.base/ending-run.c index 42f12c0..1e09f16 100644 --- a/gdb/testsuite/gdb.base/ending-run.c +++ b/gdb/testsuite/gdb.base/ending-run.c @@ -4,6 +4,8 @@ #include #include +#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++) diff --git a/gdb/testsuite/gdb.base/run.c b/gdb/testsuite/gdb.base/run.c index 0c62002..614b018 100644 --- a/gdb/testsuite/gdb.base/run.c +++ b/gdb/testsuite/gdb.base/run.c @@ -6,11 +6,15 @@ #include #include +#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 diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 2ccaa39..f48b6fb 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -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 diff --git a/gdb/testsuite/gdb.base/shmain.c b/gdb/testsuite/gdb.base/shmain.c index e36f84f..932b834 100644 --- a/gdb/testsuite/gdb.base/shmain.c +++ b/gdb/testsuite/gdb.base/shmain.c @@ -3,6 +3,8 @@ #include "ss.h" #include +#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); diff --git a/gdb/testsuite/gdb.base/sizeof.c b/gdb/testsuite/gdb.base/sizeof.c index 9c67c03..eb21f22 100644 --- a/gdb/testsuite/gdb.base/sizeof.c +++ b/gdb/testsuite/gdb.base/sizeof.c @@ -1,5 +1,7 @@ #include +#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)); diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp index a237ee3..ce6b7ed 100644 --- a/gdb/testsuite/gdb.base/sizeof.exp +++ b/gdb/testsuite/gdb.base/sizeof.exp @@ -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] diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c index 1ad2ffc..4c0f165 100644 --- a/gdb/testsuite/gdb.base/varargs.c +++ b/gdb/testsuite/gdb.base/varargs.c @@ -8,6 +8,8 @@ #include #include +#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, ...) { diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp index 96933bb..fe54314 100644 --- a/gdb/testsuite/gdb.base/varargs.exp +++ b/gdb/testsuite/gdb.base/varargs.exp @@ -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 } diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.c b/gdb/testsuite/gdb.mi/mi-dprintf.c index 0b8fc82..2571e50 100644 --- a/gdb/testsuite/gdb.mi/mi-dprintf.c +++ b/gdb/testsuite/gdb.mi/mi-dprintf.c @@ -19,6 +19,8 @@ #include #include +#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);