[2/3] gdb/testsuite: Make test names unique in gdb.python/py-prettyprint.exp

Message ID 6398e1704bab8844536849ff3829b3eb34bf5b24.1553382150.git.andrew.burgess@embecosm.com
State New, archived
Headers

Commit Message

Andrew Burgess March 23, 2019, 11:04 p.m. UTC
  This makes the test names unique in gdb.python/py-prettyprint.exp, it
also switches to use gdb_breakpoint and gdb_continue_to_breakpoint
more so that we avoid test names with the source line number in - this
is bad if the test source ever changes as the test names will then
change.

One final change is to switch from using gdb_py_test_silent_cmd to use
gdb_test_no_output, the former should be used for running python
commands and can catch any thrown exception.  However, in this case
the command being run is not a python command, its just a normal GDB
CLI command that produces no output, so lets use the appropriate
wrapper function.

gdb/testsuite/ChangeLog:

	* gdb.python/py-prettyprint.exp: Use gdb_breakpoint and
	gdb_continue_to_breakpoint more throughout this test.
	(run_lang_tests) Supply unique test names, and use
	gdb_test_no_output.
---
 gdb/testsuite/ChangeLog                     |  7 +++++++
 gdb/testsuite/gdb.python/py-prettyprint.exp | 26 ++++++++++++++------------
 2 files changed, 21 insertions(+), 12 deletions(-)
  

Comments

Tom Tromey March 25, 2019, 3:18 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> This makes the test names unique in gdb.python/py-prettyprint.exp, it
Andrew> also switches to use gdb_breakpoint and gdb_continue_to_breakpoint
Andrew> more so that we avoid test names with the source line number in - this
Andrew> is bad if the test source ever changes as the test names will then
Andrew> change.

Thanks for doing this.  This looks good to me.

Tom
  

Patch

diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index 5ec5fdb2b8b..335908279c9 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -49,9 +49,9 @@  proc run_lang_tests {exefile lang} {
 
     gdb_test_no_output "set print pretty on"
 
-    gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
-	".*Breakpoint.*"
-    gdb_test "continue" ".*Breakpoint.*"
+    gdb_breakpoint [gdb_get_line_number "break to inspect" ${testfile}.c]
+    gdb_continue_to_breakpoint "break to inspect" ".*break to inspect.*"
+
 
     set remote_python_file [gdb_remote_download host \
 				${srcdir}/${subdir}/${testfile}.py]
@@ -78,12 +78,15 @@  proc run_lang_tests {exefile lang} {
 	gdb_test "print ref" "= a=<15> b=< a=<8> b=<$hex>>"
 	gdb_test "print derived" \
 	    " = \{.*<Vbase1> = pp class name: Vbase1.*<Vbase2> = \{.*<VirtualTest> = pp value variable is: 1,.*members of Vbase2:.*_vptr.Vbase2 = $hex.*<Vbase3> = \{.*members of Vbase3.*members of Derived:.*value = 2.*"
-	gdb_test "print ns " "\"embedded\\\\000null\\\\000string\""
-	gdb_py_test_silent_cmd "set print elements 3" "" 1
-	gdb_test "print ns" "emb\.\.\.."
-	gdb_py_test_silent_cmd "set print elements 10" "" 1
-	gdb_test "print ns" "embedded\\\\000n\.\.\.."
-	gdb_py_test_silent_cmd "set print elements 200" "" 1
+	gdb_test "print ns " "\"embedded\\\\000null\\\\000string\"" \
+	    "print ns with default element limit"
+	gdb_test_no_output "set print elements 3"
+	gdb_test "print ns" "emb\.\.\.." \
+	    "print ns with element limit of 3"
+	gdb_test_no_output "set print elements 10"
+	gdb_test "print ns" "embedded\\\\000n\.\.\.." \
+	    "print ns with element limit of 10"
+	gdb_test_no_output "set print elements 200"
     }
 
     if { ![is_address_zero_readable] } {
@@ -168,9 +171,8 @@  gdb_continue_to_breakpoint "eval-break" ".* eval-break .*"
 
 gdb_test "info locals" "eval9 = eval=<123456789>"
 
-gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
-    ".*Breakpoint.*"
-gdb_test "continue" ".*Breakpoint.*"
+gdb_breakpoint [gdb_get_line_number "break to inspect" ${testfile}.c ]
+gdb_continue_to_breakpoint "break to inspect" ".*break to inspect.*"
 
 gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
     "print ss enabled #1"