From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id E9C62385802E; Mon, 10 Oct 2022 14:24:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9C62385802E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665411881; bh=wriqDLn/aIlZcivqw1vGDR26pKKXOBhH8v/pau82sls=; h=From:To:Subject:Date:From; b=oSIbRhF1qNHtJ7NdfXeG6diPR+tlCuCcM//zo72n84YGdkBrh4apW10h6nV96x952 xFXPnA3bkc/Kstq1RHcramSpJBFBc3cXZSjqRE0zh3IjoN8g3OXLIaJh2nLVEorNju qyoOXfagAXWZX7c/P4/c7W4bu7XivKV0Px2eXTGA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Detect trailing ^C/^D in command X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: ed6cd15957b80502410b771e080a88b2e4c949dd X-Git-Newrev: c52ce603561128ca3b9bc626f27abd8cda09b4d6 Message-Id: <20221010142441.E9C62385802E@sourceware.org> Date: Mon, 10 Oct 2022 14:24:41 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc52ce6035611= 28ca3b9bc626f27abd8cda09b4d6 commit c52ce603561128ca3b9bc626f27abd8cda09b4d6 Author: Tom de Vries Date: Mon Oct 10 16:24:38 2022 +0200 [gdb/testsuite] Detect trailing ^C/^D in command =20 Detect a trailing ^C/^D in the command argument of gdb_test_multiple, a= nd error out. =20 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.t= estsuite/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 =20 # Check that a command with trailing newline triggers an error. =20 -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] =20 -gdb_assert { $results =3D=3D 1 } -set expected_error_msg "Invalid trailing newline in \"pwd\n\" command" -gdb_assert { [string equal $output $expected_error_msg] } + gdb_assert { $results =3D=3D 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 =3D=3D 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" } =20 + 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" }