aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2020-06-22 21:56:59 +0200
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2020-06-26 22:04:46 +0200
commitc0b3b3bdc61cd632b0eaf650f6aa7dd6066c28cd (patch)
tree30cf6acc3d5e2729ec3a8d43bce6b5c4059bba1e /gdb
parentb6cd5d100a3ecc80f35d667063f94c98bdfbf20a (diff)
downloadgdb-c0b3b3bdc61cd632b0eaf650f6aa7dd6066c28cd.zip
gdb-c0b3b3bdc61cd632b0eaf650f6aa7dd6066c28cd.tar.gz
gdb-c0b3b3bdc61cd632b0eaf650f6aa7dd6066c28cd.tar.bz2
Make test names unique in python.exp and guile.exp
Version 2, handles the comments of Simon and Pedro. Note that gdb_test_multiline and gdb_py_test_multiple are using the "input line" as the test name, and so when there is a duplicated input line (such as a line containing "end"), we have duplicated test names => as gdb_test_multiline and gdb_py_test_multiple are identical, as indicated in FIXME, move this to gdb.exp, and make the test name unique by adding the inputnr to the pass message for each input. 2020-06-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * lib/gdb.exp (gdb_test_multiline): New, moved from gdb-guile.exp, have a input seq nr in each pass message. * lib/gdb-guile.exp (gdb_test_multiline): Move to gdb.exp. * lib/gdb-python.exp (gdb_py_test_multiple): Remove. * gdb.python/python.exp: Make test names unique, use gdb_test_multiline instead of gdb_py_test_multiple, use $gdb_test_name. * gdb.guile/guile.exp: Make test names unique, use $gdb_test_name
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog11
-rw-r--r--gdb/testsuite/gdb.python/python.exp118
-rw-r--r--gdb/testsuite/lib/gdb-guile.exp20
-rw-r--r--gdb/testsuite/lib/gdb-python.exp19
-rw-r--r--gdb/testsuite/lib/gdb.exp22
5 files changed, 95 insertions, 95 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bf9d2c4..adb5349 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2020-06-26 Philippe Waroquiers <philippe.waroquiers@skynet.be>
+
+ * lib/gdb.exp (gdb_test_multiline): New, moved from gdb-guile.exp,
+ have a input seq nr in each pass message.
+ * lib/gdb-guile.exp (gdb_test_multiline): Move to gdb.exp.
+ * lib/gdb-python.exp (gdb_py_test_multiple): Remove.
+ * gdb.python/python.exp: Make test names unique,
+ use gdb_test_multiline instead of gdb_py_test_multiple,
+ use $gdb_test_name.
+ * gdb.guile/guile.exp: Make test names unique, use $gdb_test_name
+
2020-06-26 Nick Alcock <nick.alcock@oracle.com>
* configure.ac: Add --enable-libctf.
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index a751787..a031ea5 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -46,7 +46,7 @@ gdb_test_multiple "python print (23)" "verify python support" {
"source source2.py when python disabled"
# Verify multi-line python commands cause an error.
- gdb_py_test_multiple "multi-line python command" \
+ gdb_test_multiline "multi-line python command" \
"python" "" \
"print (23)" "" \
"end" "not supported.*"
@@ -56,7 +56,7 @@ gdb_test_multiple "python print (23)" "verify python support" {
-re "$gdb_prompt $" {}
}
-gdb_py_test_multiple "multi-line python command" \
+gdb_test_multiline "multi-line python command" \
"python" "" \
"print (23)" "" \
"end" "23"
@@ -77,7 +77,7 @@ with_test_prefix "python interactive help" {
}
}
-gdb_py_test_multiple "show python command" \
+gdb_test_multiline "show python command" \
"define zzq" "Type commands for definition of .* just \"end\"\\.*" \
"python" "" \
"print (23)" "" \
@@ -85,7 +85,7 @@ gdb_py_test_multiple "show python command" \
"end" "" \
"show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end"
-gdb_py_test_multiple "indented multi-line python command" \
+gdb_test_multiline "indented multi-line python command" \
"python" "" \
"def foo ():" "" \
" print ('hello, world!')" "" \
@@ -124,7 +124,7 @@ gdb_test "python gdb.execute('echo 2\\necho 3\\\\n\\n')" "23" \
gdb_test " " "23" "gdb.execute does not affect repeat history"
# Test post_event.
-gdb_py_test_multiple "post event insertion" \
+gdb_test_multiline "post event insertion" \
"python" "" \
"someVal = 0" "" \
"class Foo(object):" "" \
@@ -194,7 +194,7 @@ gdb_test "python print (a)" ".*aliases -- User-defined aliases of other commands
gdb_py_test_silent_cmd "python nothread = gdb.selected_thread()" "Attempt to aquire thread with no inferior" 1
gdb_test "python print (nothread == None)" "True" "ensure that no threads are returned"
-gdb_py_test_multiple "register atexit function" \
+gdb_test_multiline "register atexit function" \
"python" "" \
"import atexit" "" \
"def printit(arg):" "" \
@@ -229,10 +229,12 @@ runto $lineno
gdb_test "python gdb.decode_line(\"main.c:43\")" \
"gdb.error: No source file named main.c.*" "test decode_line no source named main"
-gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "test decode_line current location" 1
-gdb_test "python print (len(symtab))" "2" "test decode_line current location"
-gdb_test "python print (symtab\[0\])" "None" "test decode_line expression parse"
-gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line current location"
+with_test_prefix "test decode_line current location" {
+ gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "decode current line" 1
+ gdb_test "python print (len(symtab))" "2" "length of result"
+ gdb_test "python print (symtab\[0\])" "None" "no unparsed text"
+ gdb_test "python print (len(symtab\[1\]))" "1" "length of result locations"
+}
# Test that decode_line with an empty string argument does not crash.
gdb_py_test_silent_cmd "python symtab2 = gdb.decode_line('')" \
@@ -243,21 +245,23 @@ if { [is_remote host] } {
} else {
set python_c [string_to_regexp "gdb.python/python.c"]
}
-gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "test decode_line current location filename"
-gdb_test "python print (symtab\[1\]\[0\].line)" "$lineno" "test decode_line current location line number"
-
-gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"python.c:26 if foo\")" "test decode_line python.c:26" 1
-gdb_test "python print (len(symtab))" "2" "test decode_line python.c:26 length"
-gdb_test "python print (symtab\[0\])" "if foo" "test decode_line expression parse"
-gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line python.c:26 length"
-gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "test decode_line python.c:26 filename"
-gdb_test "python print (symtab\[1\]\[0\].line)" "26" "test decode_line python.c:26 line number"
-
-gdb_test "python gdb.decode_line(\"randomfunc\")" \
- "gdb.error: Function \"randomfunc\" not defined.*" "test decode_line randomfunc"
-gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "test decode_line func1()" 1
-gdb_test "python print (len(symtab))" "2" "test decode_line func1 length"
-gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line func1 length"
+with_test_prefix "test decode_line" {
+ gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "current location filename"
+ gdb_test "python print (symtab\[1\]\[0\].line)" "$lineno" "current location line number"
+
+ gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"python.c:26 if foo\")" "python.c:26 decode" 1
+ gdb_test "python print (len(symtab))" "2" "python.c:26 length 2"
+ gdb_test "python print (symtab\[0\])" "if foo" "expression parse"
+ gdb_test "python print (len(symtab\[1\]))" "1" "python.c:26 length 1"
+ gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "python.c:26 filename"
+ gdb_test "python print (symtab\[1\]\[0\].line)" "26" "python.c:26 line number"
+
+ gdb_test "python gdb.decode_line(\"randomfunc\")" \
+ "gdb.error: Function \"randomfunc\" not defined.*" "randomfunc"
+ gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "func1()" 1
+ gdb_test "python print (len(symtab))" "2" "func1 length 2"
+ gdb_test "python print (len(symtab\[1\]))" "1" "func1 length 1"
+}
if { [is_remote host] } {
set python_1_c [string_to_regexp "python-1.c"]
@@ -284,12 +288,14 @@ gdb_py_test_silent_cmd {python symtab = gdb.decode_line ("func1,func2")} \
"test decode_line func1,func2" 1
gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec"
-gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"*0\")" "Test decode_line *0" 1
-gdb_test "python print (len(symtab))" "2" "test decode_line *0 result length"
-gdb_test "python print (symtab\[0\])" "None" "test decode_line *0 unparsed"
-gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line *0 locations length"
-gdb_test "python print (symtab\[1\]\[0\].symtab)" "None" "test decode_line *0 filename"
-gdb_test "python print (symtab\[1\]\[0\].pc)" "0" "test decode_line *0 pc"
+with_test_prefix "test decode_line" {
+ gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"*0\")" "*0" 1
+ gdb_test "python print (len(symtab))" "2" "*0 result length"
+ gdb_test "python print (symtab\[0\])" "None" "*0 unparsed"
+ gdb_test "python print (len(symtab\[1\]))" "1" "*0 locations length"
+ gdb_test "python print (symtab\[1\]\[0\].symtab)" "None" "*0 filename"
+ gdb_test "python print (symtab\[1\]\[0\].pc)" "0" "*0 pc"
+}
# gdb.write
gdb_test "python print (sys.stderr)" ".*gdb._GdbOutputErrorFile (instance|object) at.*" "test stderr location"
@@ -308,7 +314,7 @@ gdb_py_test_silent_cmd "set python print-stack full" \
# Test prompt substituion
-gdb_py_test_multiple "prompt substitution" \
+gdb_test_multiline "prompt substitution" \
"python" "" \
"someCounter = 0" "" \
"def prompt(current):" "" \
@@ -319,7 +325,7 @@ gdb_py_test_multiple "prompt substitution" \
" return \"py prompt \" + str (someCounter) + \" \"" "" \
"end" ""
-gdb_py_test_multiple "prompt substitution readline" \
+gdb_test_multiline "prompt substitution readline" \
"python" "" \
"pCounter = 0" "" \
"def program_prompt(current):" "" \
@@ -334,39 +340,39 @@ set newprompt "py prompt 1"
set newprompt2 "py prompt 2"
set testfake "testfake"
-gdb_test_multiple "python gdb.prompt_hook = prompt" "set the hook" {
+gdb_test_multiple "python gdb.prompt_hook = prompt" "set the hook = prompt" {
-re "\[\r\n\]$newprompt $" {
- pass "set hook"
+ pass $gdb_test_name
}
}
gdb_test_multiple "set prompt testfake " "set testfake prompt in GDB" {
-re "\[\r\n\]$testfake $" {
- pass "set prompt testfake"
+ pass $gdb_test_name
}
}
gdb_test_multiple "show prompt" "show testfake prompt" {
-re "Gdb's prompt is \"$testfake \"..* $" {
- pass "show prompt shows guarded prompt"
+ pass $gdb_test_name
}
}
gdb_test_multiple "set prompt blah " "set blah in GDB" {
-re "\[\r\n\]$newprompt2 $" {
- pass "set prompt blah overriden"
+ pass $gdb_test_name
}
}
gdb_test_multiple "python gdb.prompt_hook = None" "delete hook" {
-re "\[\r\n\]$newprompt2 $" {
- pass "delete old hook"
+ pass $gdb_test_name
}
}
gdb_test_multiple "set prompt $gdb_prompt " "set default prompt" {
-re "\[\r\n\]$gdb_prompt $" {
- pass "set default prompt"
+ pass $gdb_test_name
}
}
@@ -377,25 +383,25 @@ gdb_test_multiple "pwd" "pwd" {
}
}
-gdb_test_multiple "python gdb.prompt_hook = program_prompt" "set the hook" {
+gdb_test_multiple "python gdb.prompt_hook = program_prompt" "set the programming hook" {
-re "\[\r\n\]$gdb_prompt $" {
- pass "set programming hook"
+ pass $gdb_test_name
}
}
-gdb_test_multiple "python" "test we ignore substituion for seconday prompts" {
+gdb_test_multiple "python" "test we ignore substitution for seconday prompts" {
-re "\r\n>$" {
- pass "readline secondary are not substituted"
+ pass $gdb_test_name
}
}
gdb_test_multiple "end" "end programming" {
-re "\[\r\n\]$gdb_prompt $" {
- pass "end programming"
+ pass $gdb_test_name
}
}
-gdb_py_test_multiple "prompt substitution readline" \
+gdb_test_multiline "prompt substitution readline import" \
"python" "" \
"import gdb.command.prompt" "" \
"end" ""
@@ -403,21 +409,21 @@ gdb_py_test_multiple "prompt substitution readline" \
gdb_test_multiple "set extended-prompt one two three " \
"set basic extended prompt" {
-re "\[\r\n\]one two three $" {
- pass "set basic extended prompt"
+ pass $gdb_test_name
}
}
gdb_test_multiple "set extended-prompt \\w " \
"set extended prompt working directory" {
-re "\[\r\n\][string_to_regexp $working_dir] $" {
- pass "set extended prompt working directory"
+ pass $gdb_test_name
}
}
gdb_test_multiple "set extended-prompt some param \\p{python print-stack} " \
"set extended prompt parameter" {
-re "\[\r\n\]some param full $" {
- pass "set extended prompt parameter"
+ pass $gdb_test_name
}
}
@@ -449,33 +455,33 @@ gdb_test "show python print-stack" \
gdb_py_test_silent_cmd "set python print-stack message" \
"Test print-stack set setting to message" 1
-gdb_py_test_multiple "prompt substitution readline" \
+gdb_test_multiline "prompt substitution readline error_prompt" \
"python" "" \
"pCounter = 0" "" \
"def error_prompt(current):" "" \
" raise RuntimeError(\"Python exception called\")" "" \
"end" ""
-gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
+gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook error_prompt" {
-re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python exception called.*$gdb_prompt $" {
- pass "set hook"
+ pass $gdb_test_name
}
}
gdb_py_test_silent_cmd "python gdb.prompt_hook = None" \
- "set the hook to default" 1
+ "set the hook to default 1" 1
gdb_py_test_silent_cmd "set python print-stack full" \
"set print-stack full for prompt error test" 1
-gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
+gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook error_prompt traceback" {
-re "Traceback.*File.*line.*RuntimeError.*Python exception called.*$gdb_prompt $" {
- pass "set hook"
+ pass $gdb_test_name
}
}
gdb_py_test_silent_cmd "python gdb.prompt_hook = None" \
- "set the hook to default" 1
+ "set the hook to default 2" 1
# Start with a fresh gdb.
clean_restart ${testfile}
diff --git a/gdb/testsuite/lib/gdb-guile.exp b/gdb/testsuite/lib/gdb-guile.exp
index bda994b..ab6277b 100644
--- a/gdb/testsuite/lib/gdb-guile.exp
+++ b/gdb/testsuite/lib/gdb-guile.exp
@@ -54,26 +54,6 @@ proc gdb_scm_test_silent_cmd { cmd name {report_pass 1} } {
}
}
-# Usage: gdb_test_multiline NAME INPUT RESULT {INPUT RESULT} ...
-# Run a test named NAME, consisting of multiple lines of input.
-# After each input line INPUT, search for result line RESULT.
-# Succeed if all results are seen; fail otherwise.
-# FIXME: Move to gdb.exp and remove Python's gdb_py_test_multiple.
-
-proc gdb_test_multiline { name args } {
- global gdb_prompt
- foreach {input result} $args {
- if {[gdb_test_multiple $input "$name - $input" {
- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
- pass "$name - $input"
- }
- }]} {
- return 1
- }
- }
- return 0
-}
-
# Load Scheme file FILE_NAME.
# TEST_NAME can be used to specify the name of the test,
# otherwise a standard test name is provided.
diff --git a/gdb/testsuite/lib/gdb-python.exp b/gdb/testsuite/lib/gdb-python.exp
index 2408f2e..b41032f 100644
--- a/gdb/testsuite/lib/gdb-python.exp
+++ b/gdb/testsuite/lib/gdb-python.exp
@@ -27,25 +27,6 @@ proc gdb_py_test_silent_cmd { cmd name report_pass } {
}
}
-# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}...
-# Run a test named NAME, consisting of multiple lines of input.
-# After each input line INPUT, search for result line RESULT.
-# Succeed if all results are seen; fail otherwise.
-
-proc gdb_py_test_multiple { name args } {
- global gdb_prompt
- foreach {input result} $args {
- if {[gdb_test_multiple $input "$name - $input" {
- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
- pass "$name - $input"
- }
- }]} {
- return 1
- }
- }
- return 0
-}
-
# Return the result of python expression EXPR. DEFAULT is returned if
# there's an error. TEST is the test message to use. It can be
# omitted, in which case a test message is built from EXP. This is
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e34513f..af3e02d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1236,6 +1236,28 @@ proc gdb_test_multiple { command message args } {
return $result
}
+# Usage: gdb_test_multiline NAME INPUT RESULT {INPUT RESULT} ...
+# Run a test named NAME, consisting of multiple lines of input.
+# After each input line INPUT, search for result line RESULT.
+# Succeed if all results are seen; fail otherwise.
+
+proc gdb_test_multiline { name args } {
+ global gdb_prompt
+ set inputnr 0
+ foreach {input result} $args {
+ incr inputnr
+ if {[gdb_test_multiple $input "$name: input $inputnr: $input" {
+ -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
+ pass $gdb_test_name
+ }
+ }]} {
+ return 1
+ }
+ }
+ return 0
+}
+
+
# gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE
# Send a command to gdb; test the result.
#