proc _check_duplicates { message } {
variable all_test_names
+ # Remove test-case prefix, including the space separator.
+ set prefix [string_to_regexp "$::subdir/$::gdb_test_file_name.exp: "]
+ set message [regsub ^$prefix $message ""]
+
+ # Remove the "extra information" part.
+ set message [regsub { \([^()]*\)$} $message ""]
+
+ # Add back the test-case prefix.
+ set message "${prefix}$message"
+
# Initialise a count, or increment the count for this test name.
if {![info exists all_test_names($message)]} {
set all_test_names($message) 0
return $prompt_regexp
}
+# Generate message from COMMAND.
+#
+# This is not trivial in the case that the command contains parentheses.
+# Trailing text between parentheses prefixed with a space is interpreted as
+# extra information, and not as part of the test name [1]. Consequently,
+# "PASS: print (1)" and "PASS: print (2)" count as duplicates.
+#
+# We fix this here by using "PASS: gdb-command<print (1)>" and
+# "PASS: gdb-command<print (2)>".
+#
+# A trivial way to fix this in a test-case is by using gdb_test "print(1)",
+# which produces the nicer-looking "PASS: print(1)".
+#
+# [1] https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages
+
+proc command_to_message { command } {
+ set message $command
+
+ if { [regexp { \(([^()]*)\)$} $message] } {
+ set message gdb-command<$message>
+ }
+
+ return $message
+}
+
# gdb_test_multiple COMMAND MESSAGE [ -prompt PROMPT_REGEXP] [ -lbl ]
# EXPECT_ARGUMENTS
# Send a command to gdb; test the result.
set prompt_regexp [fill_in_default_prompt $prompt_regexp true]
if { $message == "" } {
- set message $command
+ set message [command_to_message $command]
}
if [string match "*\[\r\n\]" $command] {
return 0
}
-
# gdb_test [-prompt PROMPT_REGEXP] [-lbl]
# COMMAND [PATTERN] [MESSAGE] [QUESTION RESPONSE]
# Send a command to gdb; test the result.
}
if { $message == "" } {
- set message $command
+ set message [command_to_message $command]
}
set prompt [fill_in_default_prompt $prompt [expr !${no-prompt-anchor}]]
}
if { $message == ""} {
- set message $command
+ set message [command_to_message $command]
}
set lines ""
global gdb_prompt
if {$message == ""} {
- set message $command
+ set message [command_to_message $command]
}
set inferior_matched 0