public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Detect trailing ^C/^D in command Date: Mon, 10 Oct 2022 14:24:41 +0000 (GMT) [thread overview] Message-ID: <20221010142441.E9C62385802E@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c52ce603561128ca3b9bc626f27abd8cda09b4d6 commit c52ce603561128ca3b9bc626f27abd8cda09b4d6 Author: Tom de Vries <tdevries@suse.de> Date: Mon Oct 10 16:24:38 2022 +0200 [gdb/testsuite] Detect trailing ^C/^D in command Detect a trailing ^C/^D in the command argument of gdb_test_multiple, and error out. Tested on x86_64-linux. Diff: --- gdb/testsuite/gdb.testsuite/gdb-test.exp | 34 ++++++++++++++++++++++++++------ gdb/testsuite/lib/gdb.exp | 4 ++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.testsuite/gdb-test.exp b/gdb/testsuite/gdb.testsuite/gdb-test.exp index 2ce8eb31d73..e891f81e7b0 100644 --- a/gdb/testsuite/gdb.testsuite/gdb-test.exp +++ b/gdb/testsuite/gdb.testsuite/gdb-test.exp @@ -19,10 +19,32 @@ clean_restart # Check that a command with trailing newline triggers an error. -set results [catch { - gdb_test "pwd\n" ".*" "cmd with trailing newline" -} output] +with_test_prefix "cmd with trailing newline" { + set results [catch { + gdb_test "pwd\n" ".*" "pwd" + } output] -gdb_assert { $results == 1 } -set expected_error_msg "Invalid trailing newline in \"pwd\n\" command" -gdb_assert { [string equal $output $expected_error_msg] } + gdb_assert { $results == 1 } + set expected_error_msg "Invalid trailing newline in \"pwd\n\" command" + gdb_assert { [string equal $output $expected_error_msg] } +} + +with_test_prefix "cmd with trailing control code" { + foreach_with_prefix control_code {^C ^D} { + switch $control_code { + ^C { + set cmd "\003" + } + ^D { + set cmd "\004" + } + } + set results [catch { + gdb_test $cmd ".*" "control code" + } output] + + gdb_assert { $results == 1 } + set expected_error_msg "Invalid trailing control code in \"$cmd\" command" + gdb_assert { [string equal $output $expected_error_msg] } + } +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 5f0acfaa530..ac28ede1b08 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1003,6 +1003,10 @@ proc gdb_test_multiple { command message args } { error "Invalid trailing newline in \"$command\" command" } + if [string match "*\[\003\004\]" $command] { + error "Invalid trailing control code in \"$command\" command" + } + if [string match "*\[\r\n\]*" $message] { error "Invalid newline in \"$message\" test" }
reply other threads:[~2022-10-10 14:24 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221010142441.E9C62385802E@sourceware.org \ --to=vries@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).