aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-10-10 16:24:38 +0200
committerTom de Vries <tdevries@suse.de>2022-10-10 16:24:38 +0200
commitc52ce603561128ca3b9bc626f27abd8cda09b4d6 (patch)
treecb691ce5af99359b995c5b22e6244d2db2cdd5b8
parented6cd15957b80502410b771e080a88b2e4c949dd (diff)
downloadgdb-c52ce603561128ca3b9bc626f27abd8cda09b4d6.zip
gdb-c52ce603561128ca3b9bc626f27abd8cda09b4d6.tar.gz
gdb-c52ce603561128ca3b9bc626f27abd8cda09b4d6.tar.bz2
[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.
-rw-r--r--gdb/testsuite/gdb.testsuite/gdb-test.exp34
-rw-r--r--gdb/testsuite/lib/gdb.exp4
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 2ce8eb3..e891f81 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 5f0acfa..ac28ede 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"
}