mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
[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.
This commit is contained in:
@ -19,10 +19,32 @@ clean_restart
|
|||||||
|
|
||||||
# Check that a command with trailing newline triggers an error.
|
# Check that a command with trailing newline triggers an error.
|
||||||
|
|
||||||
set results [catch {
|
with_test_prefix "cmd with trailing newline" {
|
||||||
gdb_test "pwd\n" ".*" "cmd with trailing newline"
|
set results [catch {
|
||||||
} output]
|
gdb_test "pwd\n" ".*" "pwd"
|
||||||
|
} output]
|
||||||
|
|
||||||
gdb_assert { $results == 1 }
|
gdb_assert { $results == 1 }
|
||||||
set expected_error_msg "Invalid trailing newline in \"pwd\n\" command"
|
set expected_error_msg "Invalid trailing newline in \"pwd\n\" command"
|
||||||
gdb_assert { [string equal $output $expected_error_msg] }
|
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] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1003,6 +1003,10 @@ proc gdb_test_multiple { command message args } {
|
|||||||
error "Invalid trailing newline in \"$command\" command"
|
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] {
|
if [string match "*\[\r\n\]*" $message] {
|
||||||
error "Invalid newline in \"$message\" test"
|
error "Invalid newline in \"$message\" test"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user