From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97917 invoked by alias); 27 Apr 2017 14:53:05 -0000 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 Received: (qmail 97092 invoked by uid 89); 27 Apr 2017 14:53:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=nonetheless 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; Thu, 27 Apr 2017 14:53:03 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B7F324850C; Thu, 27 Apr 2017 14:53:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0B7F324850C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0B7F324850C Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14F0B9391F; Thu, 27 Apr 2017 14:52:59 +0000 (UTC) Subject: Re: [PATCH v3] Make environ.exp run on all platforms (and create info-program.exp) To: Sergio Durigan Junior , GDB Patches References: <20170331172901.23402-1-sergiodj@redhat.com> <20170426222833.9679-1-sergiodj@redhat.com> Cc: Luis Machado From: Pedro Alves Message-ID: <03a5e3b7-054a-4c2b-a41b-b496333f349a@redhat.com> Date: Thu, 27 Apr 2017 14:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170426222833.9679-1-sergiodj@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-04/txt/msg00740.txt.bz2 On 04/26/2017 11:28 PM, Sergio Durigan Junior wrote: > Changes since v2: > > - Removed \t when matching the output of 'info program'. > > This has been on my TODO list for a while. There's a really old bug > about this (PR testsuite/8595), and there was no reason for > environ.exp to be specific for hppa* targets. So this patch removes > this constraint, modernizes the testcase, and cleans up some things. > Most of the tests remained, and some were rewritten (especially the > one that checks if "show environment" works, which is something kind > of hard to do). It'd be good to cross check for overlap with gdb.base/testenv.exp. > # Verify that we can show all currently-set environment variables. > -# (It's a bit hacky, but nonetheless probably safe to check for at > -# least the SHELL variable.) > -# > -# need to increase timeout because of very long output > -set oldtimeout $timeout > -set timeout [expr "$timeout + 300"] > - > -send_gdb "show environment\n" > -gdb_expect { > - -re ".*SHELL=(\[a-zA-Z0-9\]*).*$gdb_prompt $"\ > - {pass "show environment"} > - -re "$gdb_prompt $"\ > - {fail "show environment"} > - timeout {fail "(timeout) show environment"} > -} > -set timeout $oldtimeout > +# It's hard to do this verification since we can't really compare each > +# entry with the current environment. So we just check to see if > +# there is anything that looks like an environment variable being > +# printed. > +gdb_test "show environment" "(\[A-Za-z_\]+=.*)+" \ > + "show environment works" We can easily set a variable in the environment before spawning GDB. We'd just have to limit that specific test to when not testing with a remote host, I think? See gdb.base/gdbhistsize-history.exp for example. > +gdb_test_multiple "unset environment" $msg { > + -re "Delete all environment variables.*y or n.*$" { > + gdb_test_no_output "y" $msg > + } > + -re "$gdb_prompt $" { > + fail $msg > + } > } The '-re "$gdb_prompt $"' part is not necessary because gdb_test_multiple already does that by default. And then you can use gdb_test for this: gdb_test "unset environment" "" $msg \ "Delete all environment variables. .y or n. $" \ "y" > -# Verify that GDB can manipulate the distinguished PATH variable. > -# > -send_gdb "path /tmp/FOOBARBAZGRUNGESPAZBALL\n" > -gdb_expect { > - -re ".*Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\ > - {pass "issue path"} > - -re "$gdb_prompt $"\ > - {fail "issue path"} > - timeout {fail "(timeout) issue path"} > -} > -send_gdb "show paths\n" > -gdb_expect { > - -re "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\ > - {pass "show paths"} > - -re "$gdb_prompt $"\ > - {fail "show paths"} > - timeout {fail "(timeout) show paths"} Any reason these "path" command tests are dropped? (AFAICS, the MI equivalent is tested by gdb.mi/mi-basics.exp). > -} > +gdb_test_no_output "set environment FOOBARBAZGRUNGESPAZBALL = foo" \ > + "set environment variable with trailing whitespace" > +gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \ > + "FOOBARBAZGRUNGESPAZBALL = foo" \ > + "confirm set environment variable with trailing whitespace" > > gdb_exit > return 0 > diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp > new file mode 100644 > index 0000000..e5e5fb9 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/info-program.exp > @@ -0,0 +1,45 @@ > +# Copyright 2017 Free Software Foundation, Inc. If the moved code is based on older code, the original copyright year must be preserved. Thanks, Pedro Alves