+2019-09-05 Tom de Vries <tdevries@suse.de>
+
+ * lib/gdb.exp (cmp_file_string): New proc.
+ * gdb.base/ui-redirect.exp: Replace "gdb_breakpoint main" with
+ runto_main. Verify save breakpoints output.
+
2019-09-04 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/info-var.exp: Test info variables without running
return -1
}
-gdb_breakpoint main
+if ![runto_main] {
+ fail "can't run to main"
+ return -1
+}
set test "commands"
gdb_test_multiple $test $test {
}
gdb_test_no_output "end"
-if ![runto_main] {
- fail "can't run to main"
- return -1
-}
gdb_breakpoint "foo"
gdb_breakpoint "bar"
+set cmds [multi_line_input \
+ "break main" \
+ " commands" \
+ " print 1" \
+ " end" \
+ "break foo" \
+ "break bar"]
+set cmds "$cmds\n"
+set outdir [standard_output_file {}]
+set cmds_file "$outdir/cmds.txt"
+
with_test_prefix "logging" {
gdb_test_no_output "set logging file /dev/null"
gdb_test "set logging on" \
"Copying output to /dev/null.*Copying debug output to /dev/null\\."
- gdb_test "save breakpoints /dev/null" "Saved to file '/dev/null'\\."
+ gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
+ "save breakpoints cmds.txt"
+ cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
gdb_test "set logging redirect on"
gdb_test "set logging on" \
"Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
- gdb_test_no_output "save breakpoints /dev/null"
+ gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
+ cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
"Copying output to /dev/null.*Copying debug output to /dev/null\\."
gdb_test "set logging redirect on" \
".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*"
- gdb_test "save breakpoints /dev/null" "Saved to file '/dev/null'\\."
+ gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
+ "save breakpoints cmds.txt"
+ cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
gdb_test_no_output "set logging redirect off"
catch "close $cmd_file"
}
+# Compare contents of FILE to string STR. Pass with MSG if equal, otherwise
+# fail with MSG.
+
+proc cmp_file_string { file str msg } {
+ if { ![file exists $file]} {
+ fail "$msg"
+ return
+ }
+
+ set caught_error [catch {
+ set fp [open "$file" r]
+ set file_contents [read $fp]
+ close $fp
+ } error_message]
+ if { $caught_error } then {
+ error "$error_message"
+ fail "$msg"
+ return
+ }
+
+ if { $file_contents == $str } {
+ pass "$msg"
+ } else {
+ fail "$msg"
+ }
+}
+
# Always load compatibility stuff.
load_lib future.exp