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
This commit is contained in:
Philippe Waroquiers 2020-06-22 21:56:59 +02:00
parent b6cd5d100a
commit c0b3b3bdc6
5 changed files with 93 additions and 93 deletions

View File

@ -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> 2020-06-26 Nick Alcock <nick.alcock@oracle.com>
* configure.ac: Add --enable-libctf. * configure.ac: Add --enable-libctf.

View File

@ -46,7 +46,7 @@ gdb_test_multiple "python print (23)" "verify python support" {
"source source2.py when python disabled" "source source2.py when python disabled"
# Verify multi-line python commands cause an error. # Verify multi-line python commands cause an error.
gdb_py_test_multiple "multi-line python command" \ gdb_test_multiline "multi-line python command" \
"python" "" \ "python" "" \
"print (23)" "" \ "print (23)" "" \
"end" "not supported.*" "end" "not supported.*"
@ -56,7 +56,7 @@ gdb_test_multiple "python print (23)" "verify python support" {
-re "$gdb_prompt $" {} -re "$gdb_prompt $" {}
} }
gdb_py_test_multiple "multi-line python command" \ gdb_test_multiline "multi-line python command" \
"python" "" \ "python" "" \
"print (23)" "" \ "print (23)" "" \
"end" "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\"\\.*" \ "define zzq" "Type commands for definition of .* just \"end\"\\.*" \
"python" "" \ "python" "" \
"print (23)" "" \ "print (23)" "" \
@ -85,7 +85,7 @@ gdb_py_test_multiple "show python command" \
"end" "" \ "end" "" \
"show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* 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" "" \ "python" "" \
"def foo ():" "" \ "def foo ():" "" \
" print ('hello, world!')" "" \ " 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" gdb_test " " "23" "gdb.execute does not affect repeat history"
# Test post_event. # Test post_event.
gdb_py_test_multiple "post event insertion" \ gdb_test_multiline "post event insertion" \
"python" "" \ "python" "" \
"someVal = 0" "" \ "someVal = 0" "" \
"class Foo(object):" "" \ "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_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_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" "" \ "python" "" \
"import atexit" "" \ "import atexit" "" \
"def printit(arg):" "" \ "def printit(arg):" "" \
@ -229,10 +229,12 @@ runto $lineno
gdb_test "python gdb.decode_line(\"main.c:43\")" \ 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.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 with_test_prefix "test decode_line current location" {
gdb_test "python print (len(symtab))" "2" "test decode_line current location" gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "decode current line" 1
gdb_test "python print (symtab\[0\])" "None" "test decode_line expression parse" gdb_test "python print (len(symtab))" "2" "length of result"
gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line current location" 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. # Test that decode_line with an empty string argument does not crash.
gdb_py_test_silent_cmd "python symtab2 = gdb.decode_line('')" \ gdb_py_test_silent_cmd "python symtab2 = gdb.decode_line('')" \
@ -243,21 +245,23 @@ if { [is_remote host] } {
} else { } else {
set python_c [string_to_regexp "gdb.python/python.c"] 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" with_test_prefix "test decode_line" {
gdb_test "python print (symtab\[1\]\[0\].line)" "$lineno" "test decode_line current location line number" 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\")" "test decode_line python.c:26" 1 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" "test decode_line python.c:26 length" gdb_test "python print (len(symtab))" "2" "python.c:26 length 2"
gdb_test "python print (symtab\[0\])" "if foo" "test decode_line expression parse" gdb_test "python print (symtab\[0\])" "if foo" "expression parse"
gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line python.c:26 length" gdb_test "python print (len(symtab\[1\]))" "1" "python.c:26 length 1"
gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "test decode_line python.c:26 filename" gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "python.c:26 filename"
gdb_test "python print (symtab\[1\]\[0\].line)" "26" "test decode_line python.c:26 line number" gdb_test "python print (symtab\[1\]\[0\].line)" "26" "python.c:26 line number"
gdb_test "python gdb.decode_line(\"randomfunc\")" \ gdb_test "python gdb.decode_line(\"randomfunc\")" \
"gdb.error: Function \"randomfunc\" not defined.*" "test decode_line randomfunc" "gdb.error: Function \"randomfunc\" not defined.*" "randomfunc"
gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "test decode_line func1()" 1 gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "func1()" 1
gdb_test "python print (len(symtab))" "2" "test decode_line func1 length" gdb_test "python print (len(symtab))" "2" "func1 length 2"
gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line func1 length" gdb_test "python print (len(symtab\[1\]))" "1" "func1 length 1"
}
if { [is_remote host] } { if { [is_remote host] } {
set python_1_c [string_to_regexp "python-1.c"] 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 "test decode_line func1,func2" 1
gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec" 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 with_test_prefix "test decode_line" {
gdb_test "python print (len(symtab))" "2" "test decode_line *0 result length" gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"*0\")" "*0" 1
gdb_test "python print (symtab\[0\])" "None" "test decode_line *0 unparsed" gdb_test "python print (len(symtab))" "2" "*0 result length"
gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line *0 locations length" gdb_test "python print (symtab\[0\])" "None" "*0 unparsed"
gdb_test "python print (symtab\[1\]\[0\].symtab)" "None" "test decode_line *0 filename" gdb_test "python print (len(symtab\[1\]))" "1" "*0 locations length"
gdb_test "python print (symtab\[1\]\[0\].pc)" "0" "test decode_line *0 pc" 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.write
gdb_test "python print (sys.stderr)" ".*gdb._GdbOutputErrorFile (instance|object) at.*" "test stderr location" 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 # Test prompt substituion
gdb_py_test_multiple "prompt substitution" \ gdb_test_multiline "prompt substitution" \
"python" "" \ "python" "" \
"someCounter = 0" "" \ "someCounter = 0" "" \
"def prompt(current):" "" \ "def prompt(current):" "" \
@ -319,7 +325,7 @@ gdb_py_test_multiple "prompt substitution" \
" return \"py prompt \" + str (someCounter) + \" \"" "" \ " return \"py prompt \" + str (someCounter) + \" \"" "" \
"end" "" "end" ""
gdb_py_test_multiple "prompt substitution readline" \ gdb_test_multiline "prompt substitution readline" \
"python" "" \ "python" "" \
"pCounter = 0" "" \ "pCounter = 0" "" \
"def program_prompt(current):" "" \ "def program_prompt(current):" "" \
@ -334,39 +340,39 @@ set newprompt "py prompt 1"
set newprompt2 "py prompt 2" set newprompt2 "py prompt 2"
set testfake "testfake" 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 $" { -re "\[\r\n\]$newprompt $" {
pass "set hook" pass $gdb_test_name
} }
} }
gdb_test_multiple "set prompt testfake " "set testfake prompt in GDB" { gdb_test_multiple "set prompt testfake " "set testfake prompt in GDB" {
-re "\[\r\n\]$testfake $" { -re "\[\r\n\]$testfake $" {
pass "set prompt testfake" pass $gdb_test_name
} }
} }
gdb_test_multiple "show prompt" "show testfake prompt" { gdb_test_multiple "show prompt" "show testfake prompt" {
-re "Gdb's prompt is \"$testfake \"..* $" { -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" { gdb_test_multiple "set prompt blah " "set blah in GDB" {
-re "\[\r\n\]$newprompt2 $" { -re "\[\r\n\]$newprompt2 $" {
pass "set prompt blah overriden" pass $gdb_test_name
} }
} }
gdb_test_multiple "python gdb.prompt_hook = None" "delete hook" { gdb_test_multiple "python gdb.prompt_hook = None" "delete hook" {
-re "\[\r\n\]$newprompt2 $" { -re "\[\r\n\]$newprompt2 $" {
pass "delete old hook" pass $gdb_test_name
} }
} }
gdb_test_multiple "set prompt $gdb_prompt " "set default prompt" { gdb_test_multiple "set prompt $gdb_prompt " "set default prompt" {
-re "\[\r\n\]$gdb_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 $" { -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>$" { -re "\r\n>$" {
pass "readline secondary are not substituted" pass $gdb_test_name
} }
} }
gdb_test_multiple "end" "end programming" { gdb_test_multiple "end" "end programming" {
-re "\[\r\n\]$gdb_prompt $" { -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" "" \ "python" "" \
"import gdb.command.prompt" "" \ "import gdb.command.prompt" "" \
"end" "" "end" ""
@ -403,21 +409,21 @@ gdb_py_test_multiple "prompt substitution readline" \
gdb_test_multiple "set extended-prompt one two three " \ gdb_test_multiple "set extended-prompt one two three " \
"set basic extended prompt" { "set basic extended prompt" {
-re "\[\r\n\]one two three $" { -re "\[\r\n\]one two three $" {
pass "set basic extended prompt" pass $gdb_test_name
} }
} }
gdb_test_multiple "set extended-prompt \\w " \ gdb_test_multiple "set extended-prompt \\w " \
"set extended prompt working directory" { "set extended prompt working directory" {
-re "\[\r\n\][string_to_regexp $working_dir] $" { -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} " \ gdb_test_multiple "set extended-prompt some param \\p{python print-stack} " \
"set extended prompt parameter" { "set extended prompt parameter" {
-re "\[\r\n\]some param full $" { -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" \ gdb_py_test_silent_cmd "set python print-stack message" \
"Test print-stack set setting to message" 1 "Test print-stack set setting to message" 1
gdb_py_test_multiple "prompt substitution readline" \ gdb_test_multiline "prompt substitution readline error_prompt" \
"python" "" \ "python" "" \
"pCounter = 0" "" \ "pCounter = 0" "" \
"def error_prompt(current):" "" \ "def error_prompt(current):" "" \
" raise RuntimeError(\"Python exception called\")" "" \ " raise RuntimeError(\"Python exception called\")" "" \
"end" "" "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 $" { -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" \ 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" \ gdb_py_test_silent_cmd "set python print-stack full" \
"set print-stack full for prompt error test" 1 "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 $" { -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" \ 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. # Start with a fresh gdb.
clean_restart ${testfile} clean_restart ${testfile}

View File

@ -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. # Load Scheme file FILE_NAME.
# TEST_NAME can be used to specify the name of the test, # TEST_NAME can be used to specify the name of the test,
# otherwise a standard test name is provided. # otherwise a standard test name is provided.

View File

@ -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 # 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 # 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 # omitted, in which case a test message is built from EXP. This is

View File

@ -1236,6 +1236,28 @@ proc gdb_test_multiple { command message args } {
return $result 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 # gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE
# Send a command to gdb; test the result. # Send a command to gdb; test the result.
# #