[pushed,3/4,gdb/testsuite] Fix test name in gdb.python/python.exp

Message ID 20211013090031.21963-3-tdevries@suse.de
State New
Headers show
Series
  • [pushed,1/4,gdb/testsuite] Remove quit in gdb.arch/i386-mpx.exp
Related show

Commit Message

Philippe Waroquiers via Gdb-patches Oct. 13, 2021, 9 a.m.
When running test-case gdb.python/python.exp, we have:
...
PASS: gdb.python/python.exp: starti via gdb.execute, not from tty
PASS: gdb.python/python.exp: starti via interactive input
...

The two tests are instances of the same test, with different values for
starti command argument from_tty, so it's strange that the test names are so
different.

This is due to using a gdb_test nested in a gdb_test_multiple, with the inner
one using a different test name than the outer one.  [ That could still make
sense if both produced passes, but that's not the case here. ]

Fix this by using $gdb_test_name, such that we have:
...
PASS: gdb.python/python.exp: starti via gdb.execute, not from tty
PASS: gdb.python/python.exp: starti via gdb.execute, from tty
...

Also make this more readable by using variables.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.python/python.exp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

-- 
2.26.2

Patch

diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index a81cd5c850e..7f9c2b4af7f 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -542,12 +542,19 @@  gdb_test "python gdb.execute(\"show commands\")" "$decimal  print \\\$cvar3.*"
 # Test that the from_tty argument to gdb.execute is effective. If
 # False, the user is not prompted for decisions such as restarting the
 # program, and "yes" is assumed. If True, the user is prompted.
+# Case 1, from_tty=False.
 gdb_test "python gdb.execute('starti', from_tty=False)" \
     "Program stopped.*" \
     "starti via gdb.execute, not from tty"
-gdb_test_multiple "python gdb.execute('starti', from_tty=True)" \
-    "starti via gdb.execute, from tty" {
-    -re {The program being debugged has been started already\.\r\nStart it from the beginning\? \(y or n\) $} {
-	gdb_test "y" "Starting program:.*" "starti via interactive input"
+
+# Case 2, from_tty=True.
+set test "starti via gdb.execute, from tty"
+set question \
+    [multi_line \
+	 {The program being debugged has been started already\.} \
+	 {Start it from the beginning\? \(y or n\) $}]
+gdb_test_multiple "python gdb.execute('starti', from_tty=True)" $test {
+    -re $question {
+	gdb_test "y" "Starting program:.*" $gdb_test_name
     }
 }