From patchwork Wed Mar 19 15:57:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 164 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (caibbdcaaahb.dreamhost.com [208.113.200.71]) by wilcox.dreamhost.com (Postfix) with ESMTP id BFA2D3600D6 for ; Wed, 19 Mar 2014 08:58:41 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 4BE2CCA61AD; Wed, 19 Mar 2014 08:58:41 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id 1D2CECA6139 for ; Wed, 19 Mar 2014 08:58:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Ks5EYxSIlPYQy95FsaOnsJAq7fek2jE FUff9XmBjjc4pn0xgaWHmmiUnZyJfDA92ng+y0DNJrsrMis0QWdlzzkv+lrDGLFo AUnYWvC+lD+4z3sVp42wO1yVxNQ4HQCU7E862KFIPkrmqGhfCfQZ3yVr1RK8v4Z4 WzYHuLevvxaQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=bcZBLhp7w8+ErWeqiq4iNkCw8Bs=; b=nrj6u xGh1NZDnJ47ErsB/l/MM+sMlnjgBWzFL3b/Hu1wQeV7GcI+EG5z2oMcMYOx+RD0f tuLykw0B+SNGmc9qTket1dJnREmyTbzW57rFnqQMdALaavH8wsWSON2/SjY7V63o /8QCSBVJ3y9EmaBVP+g5TlDUOi81njeNjyuMos= Received: (qmail 20240 invoked by alias); 19 Mar 2014 15:58:12 -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 20191 invoked by uid 89); 19 Mar 2014 15:58:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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 ESMTP; Wed, 19 Mar 2014 15:58:10 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2JFw8oY031718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 Mar 2014 11:58:09 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2JFw1MG008699 for ; Wed, 19 Mar 2014 11:58:07 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PUSHED 5/8] gdb.base/async.exp: Factor out test pattern to a procedure. Date: Wed, 19 Mar 2014 15:57:58 +0000 Message-Id: <1395244681-24272-6-git-send-email-palves@redhat.com> In-Reply-To: <1395244681-24272-1-git-send-email-palves@redhat.com> References: <1395244681-24272-1-git-send-email-palves@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in All the tests here follow the same pattern (and they all have the same problem, not fixed here yet). Add a new procedure, factoring out the pattern to a simple place. gdb/testsuite/ 2014-03-19 Pedro Alves * gdb.base/async.exp (test_background): New procedure. Use it for all background execution command tests. --- gdb/testsuite/ChangeLog | 5 +++ gdb/testsuite/gdb.base/async.exp | 96 ++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 54 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index bb3d559..509472d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2014-03-19 Pedro Alves + * gdb.base/async.exp (test_background): New procedure. + Use it for all background execution command tests. + +2014-03-19 Pedro Alves + * gdb.base/async.exp: Use prepare_for_testing. 2014-03-19 Pedro Alves diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp index 02ca4d1..65bec4d 100644 --- a/gdb/testsuite/gdb.base/async.exp +++ b/gdb/testsuite/gdb.base/async.exp @@ -49,69 +49,57 @@ gdb_test "break baz" ".*" "" # gdb_test_no_output "set exec-done-display on" - -send_gdb "next&\n" -gdb_expect { - -re "^next&\r\n$gdb_prompt.*z = 9.*completed\.\r\n" { pass "next &" } - -re "$gdb_prompt.*completed\.$" { fail "next &" } - timeout { fail "(timeout) next &" } +# Test a background execution command. COMMAND is the command to +# send. BEFORE_PROMPT is the pattern expected before the GDB prompt +# is output. AFTER_PROMPT is the pattern expected after the prompt +# and before "completed". MESSAGE is optional, and is the pass/fail +# message to br printed. If omitted, then the command string is used +# as message. +proc test_background {command before_prompt after_prompt {message ""}} { + global gdb_prompt + + if {$message eq ""} { + set message $command + } + + send_gdb "$command\n" + gdb_expect { + -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" { + pass "$message" + } + -re "$gdb_prompt.*completed\.$" { + fail "$message" + } + timeout { + fail "$message (timeout)" + } + } } -send_gdb "step&\n" -gdb_expect { - -re "^step&\r\n$gdb_prompt.*y = foo \\(\\).*completed\.\r\n" { pass "step &" } - -re "$gdb_prompt.*completed\.$" { fail "step &" } - timeout { fail "(timeout) step &" } -} +test_background "next&" "" ".*z = 9.*" -send_gdb "step&\n" -gdb_expect { - -re "^step&\r\n$gdb_prompt foo \\(\\) at .*async.c.*x = 5.*completed\.\r\n" \ - { pass "step &" } - -re "$gdb_prompt.*completed\.$" { fail "step &" } - timeout { fail "(timeout) step &" } -} +test_background "step&" "" ".*y = foo \\(\\).*" -send_gdb "stepi&\n" -gdb_expect { - -re "^stepi&\r\n$gdb_prompt.*$hex.*x = 5.*completed\.\r\n" { pass "stepi &" } - -re "$gdb_prompt.*completed\.$" { fail "stepi &" } - timeout { fail "(timeout) stepi &" } -} +test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" -send_gdb "nexti&\n" -gdb_expect { - -re "^nexti&\r\n$gdb_prompt.*y = 3.*completed\.\r\n" { pass "nexti &" } - -re "$gdb_prompt.*completed\.$" { fail "nexti &" } - timeout { fail "(timeout) nexti &" } -} +test_background "stepi&" "" ".*$hex.*x = 5.*" -send_gdb "finish&\n" -gdb_expect { - -re "^finish&\r\nRun till exit from #0 foo \\(\\) at.*async.c.*\r\n$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*completed\.\r\n" \ - { pass "finish &" } - -re "$gdb_prompt.*completed\.$" { fail "finish &" } - timeout { fail "(timeout) finish &" } -} +test_background "nexti&" "" ".*y = 3.*" -set jump_here [gdb_get_line_number "jump here"] +test_background "finish&" \ + "Run till exit from #0 foo \\(\\) at.*async.c.*\r\n" \ + ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*" -send_gdb "jump $jump_here&\n" -gdb_expect { - -re "^jump $jump_here&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \ - { pass "jump &" } - -re ".*$gdb_prompt.*completed\.$" { fail "jump &" } - timeout { fail "(timeout) jump &" } -} +set jump_here [gdb_get_line_number "jump here"] +test_background "jump $jump_here&" \ + ".*Continuing at $hex.*" \ + ".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \ + "jump&" set until_here [gdb_get_line_number "until here"] - -send_gdb "until $until_here&\n" -gdb_expect { - -re "^until $until_here&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \ - { pass "until &" } - -re "$gdb_prompt.*completed\.$" { fail "until &" } - timeout { fail "(timeout) until &" } -} +test_background "until $until_here&" \ + ".*" \ + ".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \ + "until&" gdb_test_no_output "set exec-done-display off"