From patchwork Tue Nov 26 23:34:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 36288 Received: (qmail 31909 invoked by alias); 26 Nov 2019 23:34:40 -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 31856 invoked by uid 89); 26 Nov 2019 23:34:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=20191127, 2019-11-27 X-HELO: mailsec117.isp.belgacom.be Received: from mailsec117.isp.belgacom.be (HELO mailsec117.isp.belgacom.be) (195.238.20.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 23:34:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1574811277; x=1606347277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AJ2YSPiWZ4AcgJ824mZmWNz/K3EOP2DvvhiY6zKh6xc=; b=BWr8xzd10pLt4lW/1rYoLXg3SfmxJVntUcoWqO/KNM2wTMaE7QQPvMFW qbcnF15FynyiSbGpQ5d9TKaadKuDYg==; IronPort-SDR: FC96bKo64IAozTD7pvIH7DUMci4rW1siYkUIQA6k/fIQQsf1EaYn/VLzwWVwYtSK79LBkvcGZK aqMmN1/YUn8efEP+yMUzNOrKPZDrr1/HytCblzLUC8yh6cjA8oonK/8gxGTSGssElJMmdBj39j Hf4zXPbsPEu4JHOEir5dKBCayVeJLHCj8p3TEKpYJLc3MCGPF5ftthV9jPkUUVPFVJJ+nuvqIk /TJxefKOY2GYJR+QK1fIL99EAWuc9KMPYTzOfaIPRQxDajAb3lOKh53maHLrGSz6yVRpGXW9/O P4A= Received: from 136.173-134-109.adsl-dyn.isp.belgacom.be (HELO md.home) ([109.134.173.136]) by relay.skynet.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Nov 2019 00:34:29 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFAv2 2/4] Test define-prefix. Date: Wed, 27 Nov 2019 00:34:21 +0100 Message-Id: <20191126233423.14801-3-philippe.waroquiers@skynet.be> In-Reply-To: <20191126233423.14801-1-philippe.waroquiers@skynet.be> References: <20191126233423.14801-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes Adds a test testing the new define-prefix command. 2019-11-27 Philippe Waroquiers * gdb.base/define-prefix.exp: New file. --- gdb/testsuite/gdb.base/define-prefix.exp | 146 +++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 gdb/testsuite/gdb.base/define-prefix.exp diff --git a/gdb/testsuite/gdb.base/define-prefix.exp b/gdb/testsuite/gdb.base/define-prefix.exp new file mode 100644 index 0000000000..e8f4c3c4e4 --- /dev/null +++ b/gdb/testsuite/gdb.base/define-prefix.exp @@ -0,0 +1,146 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2019 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# This test verifies the "define-prefix" command. + +gdb_start + +#################### +# Verify the definition of user defined prefix commands. +# Test the definition of a command using these prefixes. + +# Define an empty prefix command. +gdb_test_no_output "define-prefix abc-prefix" + +# Verify an empty prefix command cannot be used as a command. +gdb_test "abc-prefix" \ + "\"abc-prefix\" must be followed by the name of a subcommand.*" \ + "execute prefix command not followed by subcommand" + +# Define a sub-prefix command. +gdb_test_no_output "define-prefix abc-prefix def-prefix" + +# Define ghi-cmd using the prefixes. +gdb_test_multiple "define abc-prefix def-prefix ghi-cmd" \ + "define user command: abc-prefix def-prefix ghi-cmd" { + -re "Type commands for definition of \"abc-prefix def-prefix ghi-cmd\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "echo command ghi-cmd\\n\nend" "" \ + "define user command: ghi-cmd" + } + } +# Verify ghi-cmd works. +gdb_test "abc-prefix def-prefix ghi-cmd" \ + "command ghi-cmd" \ + "use user command: ghi-cmd" + + +#################### +# Verify an existing (empty) command can be marked as a prefix command. +# Then verify an empty prefix command can be transformed into an executable command. + +# Define ghi-prefix-cmd as an empty command. +gdb_test_multiple "define abc-prefix def-prefix ghi-prefix-cmd" \ + "define user command: abc-prefix def-prefix ghi-prefix-cmd" { + -re "Type commands for definition of \"abc-prefix def-prefix ghi-prefix-cmd\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "end" "" \ + "define user command: ghi-prefix-cmd" + } + } +gdb_test_no_output "define-prefix abc-prefix def-prefix ghi-prefix-cmd" + +# Verify a sequence ending with an empty prefix command cannot be used as +# a command. +gdb_test "abc-prefix def-prefix ghi-prefix-cmd" \ + "\"abc-prefix def-prefix ghi-prefix-cmd\" must be followed by the name of a subcommand.*" \ + "execute sequence of prefix commands not followed by a subcommand" + +# Define jkl-cmd command. +gdb_test_multiple "define abc-prefix def-prefix ghi-prefix-cmd jkl-cmd" \ + "define user command: abc-prefix def-prefix ghi-prefix-cmd jkl-cmd" { + -re "Type commands for definition of \"abc-prefix def-prefix ghi-prefix-cmd jkl-cmd\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "echo command jkl-cmd\\n\nend" "" \ + "define user command: jkl-cmd" + } + } +# Verify jkl-cmd command works. +gdb_test "abc-prefix def-prefix ghi-prefix-cmd jkl-cmd" \ + "command jkl-cmd" \ + "use user command: jkl-cmd" + +# Define alternate-jkl-cmd and check it works. +# Define alternate-jkl-cmd command. +gdb_test_multiple "define abc-prefix def-prefix ghi-prefix-cmd alternate-jkl-cmd" \ + "define user command: abc-prefix def-prefix ghi-prefix-cmd alternate-jkl-cmd" { + -re "Type commands for definition of \"abc-prefix def-prefix ghi-prefix-cmd alternate-jkl-cmd\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "echo command alternate-jkl-cmd\\n\nend" "" \ + "define user command: alternate-jkl-cmd" + } + } +# Verify alternate-jkl-cmd command works. +gdb_test "abc-prefix def-prefix ghi-prefix-cmd alternate-jkl-cmd" \ + "command alternate-jkl-cmd" \ + "use user command: alternate-jkl-cmd" + + + +# Now redefine ghi-prefix-cmd as a real command, and check it is working. +send_gdb "define abc-prefix def-prefix ghi-prefix-cmd\n" +gdb_expect { + -re "Keeping subcommands of prefix command \"ghi-prefix-cmd\"\.\r\nRedefine command \"ghi-prefix-cmd\".*y or n. $" { + send_gdb "y\n" + gdb_expect { + -re "Type commands for definition of \"abc-prefix def-prefix ghi-prefix-cmd\".\r\nEnd with a line saying just \"end\".\r\n>$" { + send_gdb "echo redefined command ghi-prefix-cmd\\n\nend\n" + gdb_expect { + -re "$gdb_prompt $" {pass "redefine user command: ghi-prefix-cmd"} + timeout {fail "(timeout) redefine user command: ghi-prefix-cmd"} + } + } + timeout {fail "(timeout) redefine user command: ghi-prefix-cmd"} + } + } + -re "$gdb_prompt $" {fail "redefine user command: ghi-prefix-cmd"} + timeout {fail "(timeout) redefine user command: ghi-prefix-cmd"} +} + +# Verify ghi-prefix-cmd command works. +gdb_test "abc-prefix def-prefix ghi-prefix-cmd" \ + "redefined command ghi-prefix-cmd" \ + "use redefined user command: ghi-prefix-cmd" + +# Check jkl-cmd still works. +gdb_test "abc-prefix def-prefix ghi-prefix-cmd jkl-cmd" \ + "command jkl-cmd" \ + "use user command after redefining ghi-prefix-cmd: jkl-cmd" + +# Check alternate-jkl-cmd still works. +gdb_test "abc-prefix def-prefix ghi-prefix-cmd alternate-jkl-cmd" \ + "command alternate-jkl-cmd" \ + "use user command after redefining ghi-prefix-cmd: alternate-jkl-cmd" + +#################### +# Check error behaviour. + +gdb_test "define-prefix print" ".* is built-in.*" + +gdb_test "define-prefix something-not-existing something-else" \ + "Undefined command: \"something-not-existing\".*" + +gdb_test "define-prefix abc-prefix something-not-existing something-else" \ + "Undefined abc-prefix command: \"something-not-existing\".*" +