From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28125 invoked by alias); 20 May 2010 19:23:42 -0000 Received: (qmail 28117 invoked by uid 22791); 20 May 2010 19:23:42 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 May 2010 19:23:37 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7C8D82BAC23 for ; Thu, 20 May 2010 15:23:35 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IhBYZ3t8VOwh for ; Thu, 20 May 2010 15:23:35 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 442662BAC21 for ; Thu, 20 May 2010 15:23:35 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 143D7F58FA; Thu, 20 May 2010 12:23:33 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [commit/testsuite] lib/gdb.exp: New gdb_test_no_output function. Date: Thu, 20 May 2010 19:45:00 -0000 Message-Id: <1274383407-3191-1-git-send-email-brobecker@adacore.com> In-Reply-To: <4BF579B8.1040503@vmware.com> References: <4BF579B8.1040503@vmware.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-05/txt/msg00441.txt.bz2 This implements the suggestion provided by Pedro on how to test a command which is expected to generate no output. I can now see why my own attempts so far have failed: the output being matched by gdb_test_multiple actually contains the command itself. This is something that I managed to never actually notice :-/. 2010-05-20 Pedro Alves Joel Brobecker * lib/gdb.exp (gdb_test_no_output): New function. * lib/gdb.ada/arrayidx.exp: Use gdb_test_no_output instead of gdb_test when testing commands that should produce no output. Tested on x86_64-linux. --- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.ada/arrayidx.exp | 8 ++------ gdb/testsuite/lib/gdb.exp | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b6f9469..93df121 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-05-20 Pedro Alves + Joel Brobecker + + * lib/gdb.exp (gdb_test_no_output): New function. + * lib/gdb.ada/arrayidx.exp: Use gdb_test_no_output instead of gdb_test + when testing commands that should produce no output. + 2010-05-19 Michael Snyder * gdb.base/whatis.exp: Replace send_gdb with gdb_test. diff --git a/gdb/testsuite/gdb.ada/arrayidx.exp b/gdb/testsuite/gdb.ada/arrayidx.exp index 13be845..3d45461 100644 --- a/gdb/testsuite/gdb.ada/arrayidx.exp +++ b/gdb/testsuite/gdb.ada/arrayidx.exp @@ -41,9 +41,7 @@ runto "p.adb:$bp_location" # First, print all the arrays without indexes -gdb_test "set print array-indexes off" \ - "" \ - "set print array-indexes to off" +gdb_test_no_output "set print array-indexes off" gdb_test "print one_two_three" \ "= \\(1, 2, 3\\)" \ @@ -79,9 +77,7 @@ gdb_test "print empty" \ # Next, print all the arrays with the indexes -gdb_test "set print array-indexes on" \ - "" \ - "set print array-indexes to on" +gdb_test_no_output "set print array-indexes on" gdb_test "print one_two_three" \ "= \\(1 => 1, 2 => 2, 3 => 3\\)" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 70df5ea..563ffa7 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -877,6 +877,31 @@ proc gdb_test { args } { } }] } + +# gdb_test_no_output COMMAND MESSAGE +# Send a command to GDB and verify that this command generated no output. +# +# See gdb_test_multiple for a description of the COMMAND and MESSAGE +# parameters. If MESSAGE is ommitted, then COMMAND will be used as +# the message. + +proc gdb_test_no_output { args } { + global gdb_prompt + set command [lindex $args 0] + if [llength $args]>1 then { + set message [lindex $args 1] + } else { + set message $command + } + + set command_regex [string_to_regexp $command] + gdb_test_multiple $command $message { + -re "^$command_regex\r\n$gdb_prompt $" { + pass $message + } + } +} + # Test that a command gives an error. For pass or fail, return # a 1 to indicate that more tests can proceed. However a timeout -- 1.7.1