public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/testsuite] Restore breakpoint command in ui-redirect.exp
@ 2019-09-05 12:33 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2019-09-05 12:33 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=30331a6ca014f6b51b17627aa968c6b79627ce21
commit 30331a6ca014f6b51b17627aa968c6b79627ce21
Author: Tom de Vries <tdevries@suse.de>
Date: Thu Sep 5 14:33:10 2019 +0200
[gdb/testsuite] Restore breakpoint command in ui-redirect.exp
In gdb.base/ui-redirect.exp, the "save breakpoint" command is used to write
the current breakpoints to a file, but the actual output is not verified.
Consequently, the test has regressed in that the "print 1" command associated
with a breakpoint on main is removed by a subsequent runto_main, which first
deletes all breakpoints:
...
(gdb) break main
Breakpoint 1 at 0x4004d7: file start.c, line 34.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
> PASS: gdb.base/ui-redirect.exp: commands
print 1
> PASS: gdb.base/ui-redirect.exp: print 1
end
(gdb) PASS: gdb.base/ui-redirect.exp: end
delete breakpoints
Delete all breakpoints? (y or n) y
...
and consequently the "save breakpoint" output is missing the breakpoint
command for main:
...
break main
- commands
- print 1
- end
break foo
break bar
...
Fix this by replacing "gdb_breakpoint main" with runto_main, and verifying the
"save breakpoints" output.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
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.
Diff:
---
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.base/ui-redirect.exp | 31 +++++++++++++++++++++++--------
gdb/testsuite/lib/gdb.exp | 27 +++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 46c7b5f..0f6917a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp
index 4507ac5..efcac14 100644
--- a/gdb/testsuite/gdb.base/ui-redirect.exp
+++ b/gdb/testsuite/gdb.base/ui-redirect.exp
@@ -23,7 +23,10 @@ if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } {
return -1
}
-gdb_breakpoint main
+if ![runto_main] {
+ fail "can't run to main"
+ return -1
+}
set test "commands"
gdb_test_multiple $test $test {
@@ -40,18 +43,27 @@ 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:.*"
}
@@ -60,7 +72,8 @@ with_test_prefix "redirect" {
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:.*"
}
@@ -71,7 +84,9 @@ with_test_prefix "redirect while already logging" {
"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"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 76805fb..acbeb01 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6668,5 +6668,32 @@ proc gdb_write_cmd_file { cmdline } {
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-09-05 12:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 12:33 [binutils-gdb] [gdb/testsuite] Restore breakpoint command in ui-redirect.exp Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).