Fixes for gdb.python tests on remote Windows host.

This patch fixes several test ERRORs and FAILs seen from running
gdb.python tests on a remote Windows host.  The problems fixed
generally fall into these categories:
- Failure to copy the .py script to the host.
- Confusion between build and host pathnames.
- Assuming pathnames printed on the host include "/" as a directory
  separator.
- Tests that need to be conditionally disabled due to missing features
  on the host, etc.

2019-08-13  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.python/py-completion.exp: Download the .py file to the host
	and use its host pathname.  Conditionalize tests that use
	tab completion and manipulate files on the build machine.
	* gdb.python/py-events.exp: Download the .py file to the host
	and use its host pathname.
	* gdb.python/py-evsignal.exp: Likewise.
	* gdb.python/py-evthreads.exp: Likewise.
	* gdb.python/py-framefilter-invalidarg.exp: Match Windows
	pathname syntax.
	* gdb.python/py-framefilter.exp: Download the .py file to the right
	place on the host.  Match Windows pathname syntax.
	* gdb.python/py-mi-var-info-path-expression.exp: Download the
	.py file to the host and use its host pathname.
	* gdb.python/py-objfile-script.exp: Match Windows pathname syntax.
	* gdb.python/py-objfile.exp: Expect a host pathname, not a
	build pathname.  Skip symlink test on Windows host.  Add missing
	newline at end of file.
	* gdb.python/py-pp-maint.exp: Download the .py file to the host
	and use its host pathname.
	* gdb.python/py-pp-registration.exp: Match Windows pathname syntax.
	* gdb.python/py-section-script.exp: Use host location of binfile
	on safe-path.  Use correct path separator on Windows host.
	Reorder alternatives in gdb_test_multiple to prevent matching
	the wrong alternative on success.
	* gdb.python/py-symtab.exp: Match Windows pathname syntax.
This commit is contained in:
Sandra Loosemore 2019-08-13 09:09:30 -07:00
parent 5067f530c3
commit 74c2c1f45f
14 changed files with 116 additions and 69 deletions

View File

@ -1,3 +1,31 @@
2019-08-13 Sandra Loosemore <sandra@codesourcery.com>
* gdb.python/py-completion.exp: Download the .py file to the host
and use its host pathname. Conditionalize tests that use
tab completion and manipulate files on the build machine.
* gdb.python/py-events.exp: Download the .py file to the host
and use its host pathname.
* gdb.python/py-evsignal.exp: Likewise.
* gdb.python/py-evthreads.exp: Likewise.
* gdb.python/py-framefilter-invalidarg.exp: Match Windows
pathname syntax.
* gdb.python/py-framefilter.exp: Download the .py file to the right
place on the host. Match Windows pathname syntax.
* gdb.python/py-mi-var-info-path-expression.exp: Download the
.py file to the host and use its host pathname.
* gdb.python/py-objfile-script.exp: Match Windows pathname syntax.
* gdb.python/py-objfile.exp: Expect a host pathname, not a
build pathname. Skip symlink test on Windows host. Add missing
newline at end of file.
* gdb.python/py-pp-maint.exp: Download the .py file to the host
and use its host pathname.
* gdb.python/py-pp-registration.exp: Match Windows pathname syntax.
* gdb.python/py-section-script.exp: Use host location of binfile
on safe-path. Use correct path separator on Windows host.
Reorder alternatives in gdb_test_multiple to prevent matching
the wrong alternative on success.
* gdb.python/py-symtab.exp: Match Windows pathname syntax.
2019-08-12 Patrick Palka <patrick@parcs.ath.cx>
* gdb.gdb/selftest.exp (test_with_self): Update test to now

View File

@ -17,65 +17,69 @@ set testfile "py-completion"
load_lib gdb-python.exp
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
set discard 0
gdb_exit
gdb_start
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
"load python file"
# Tab completion tests require readline support, and this set of tests
# doesn't work on a remote host either.
if { [readline_is_used] && ![is_remote host] } {
gdb_test_no_output "source ${pyfile}" "load python file"
# Create a temporary directory
set testdir "[standard_output_file "py-completion-testdir"]/"
set testdir_regex [string_to_regexp $testdir]
set testdir_complete [standard_output_file "py-completion-test"]
file mkdir $testdir
# Create a temporary directory
set testdir "[standard_output_file "py-completion-testdir"]/"
set testdir_regex [string_to_regexp $testdir]
set testdir_complete [standard_output_file "py-completion-test"]
file mkdir $testdir
# This one should always pass.
send_gdb "completefileinit ${testdir_complete}\t"
gdb_test_multiple "" "completefileinit completion" {
-re "^completefileinit ${testdir_regex}$" {
pass "completefileinit completion"
# This one should always pass.
send_gdb "completefileinit ${testdir_complete}\t"
gdb_test_multiple "" "completefileinit completion" {
-re "^completefileinit ${testdir_regex}$" {
pass "completefileinit completion"
}
}
}
# Just discarding whatever we typed.
set discard 0
gdb_test " " ".*" "discard #[incr discard]"
# Just discarding whatever we typed.
gdb_test " " ".*" "discard #[incr discard]"
# This is the problematic one.
send_gdb "completefilemethod ${testdir_complete}\t"
gdb_test_multiple "" "completefilemethod completion" {
-re "^completefilemethod ${testdir_regex} $" {
fail "completefilemethod completion (completed filename as wrong command arg)"
# This is the problematic one.
send_gdb "completefilemethod ${testdir_complete}\t"
gdb_test_multiple "" "completefilemethod completion" {
-re "^completefilemethod ${testdir_regex} $" {
fail "completefilemethod completion (completed filename as wrong command arg)"
}
-re "^completefilemethod ${testdir_regex}$" {
pass "completefilemethod completion"
}
}
-re "^completefilemethod ${testdir_regex}$" {
pass "completefilemethod completion"
}
}
# Discarding again
gdb_test " " ".*" "discard #[incr discard]"
# Discarding again
gdb_test " " ".*" "discard #[incr discard]"
# Another problematic
set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
gdb_test_multiple "" "completefilecommandcond completion" {
-re "^completefilecommandcond ${testdir}$" {
fail "completefilecommandcond completion (completed filename instead of command)"
}
-re "^completefilecommandcond ${completion_regex}\007$" {
pass "completefilecommandcond completion"
# Another problematic
set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
gdb_test_multiple "" "completefilecommandcond completion" {
-re "^completefilecommandcond ${testdir}$" {
fail "completefilecommandcond completion (completed filename instead of command)"
}
-re "^completefilecommandcond ${completion_regex}\007$" {
pass "completefilecommandcond completion"
}
}
}
# Start gdb over again to clear out current state. This can interfere
# with the expected output of the below tests in a buggy gdb.
gdb_exit
gdb_start
gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
"load python file again"
gdb_test_no_output "source ${pyfile}" "load python file again"
gdb_test_sequence "complete completel" \
"list all completions of 'complete completel'" {

View File

@ -26,7 +26,6 @@ set lib_opts debug
standard_testfile
set exec_opts [list debug shlib=$lib_sl]
set pyfile ${srcdir}/${subdir}/${testfile}.py
if [get_compiler_info] {
return -1
@ -43,6 +42,7 @@ clean_restart ${testfile}
if { [skip_python_tests] } { continue }
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-objfile-events" "Object file events registered."

View File

@ -23,7 +23,6 @@ if {[target_info gdb_protocol] == "remote"
load_lib gdb-python.exp
standard_testfile py-evthreads.c
set pyfile ${srcdir}/${subdir}/py-events.py
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
return -1
@ -32,6 +31,7 @@ clean_restart $testfile
if { [skip_python_tests] } { continue }
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-events" "Event testers registered."

View File

@ -21,7 +21,6 @@ if { ![support_displaced_stepping] } {
load_lib gdb-python.exp
standard_testfile
set pyfile ${srcdir}/${subdir}/py-events.py
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
return -1
@ -34,6 +33,7 @@ save_vars { GDBFLAGS } {
if { [skip_python_tests] } { continue }
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-events" "Event testers registered."

View File

@ -48,7 +48,7 @@ gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
"set auto-load safe-path"
gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Test auto-load had loaded python scripts"
if ![runto_main] then {

View File

@ -41,16 +41,15 @@ gdb_test "info frame-filter" \
# Care is taken to put it in the same directory as the binary so that
# gdb will find it.
set remote_obj_python_file \
[remote_download \
host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
[standard_output_file ${testfile}-gdb.py]]
[gdb_remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
${testfile}-gdb.py]
gdb_reinitialize_dir $srcdir/$subdir
gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
"set auto-load safe-path"
gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Test auto-load had loaded python scripts"
if ![runto_main] then {
@ -302,9 +301,8 @@ if { [skip_python_tests] } { continue }
# Care is taken to put it in the same directory as the binary so that
# gdb will find it.
set remote_obj_python_file \
[remote_download \
host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
[standard_output_file ${testfile}-gdb.py]]
[gdb_remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
${testfile}-gdb.py]
gdb_reinitialize_dir $srcdir/$subdir
gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
@ -312,7 +310,7 @@ gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Set autoload path for no debug info tests"
if ![runto_main] then {
perror "couldn't run to breakpoint"

View File

@ -35,7 +35,8 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" }
# Skip all tests if Python scripting is not enabled.
if { [mi_skip_python_tests] } { continue }
mi_gdb_test "source ${srcdir}/${subdir}/${testfile}.py" \
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
mi_gdb_test "source ${pyfile}" \
".*\\^done" \
"load python file"

View File

@ -40,7 +40,7 @@ gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-loa
gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*"
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*"
if ![runto_main] {
perror "couldn't run to main"

View File

@ -46,7 +46,7 @@ gdb_test "python print (objfile.username)" "${testfile}" \
"Get objfile user name"
gdb_test "python print (objfile)" \
"<gdb.Objfile filename=[string_to_regexp ${binfile}]>"
"<gdb.Objfile filename=.*${testfile}.*>"
gdb_test_no_output "python dir(objfile)"
@ -158,17 +158,20 @@ if { [get_python_valueof "sep_objfile.build_id" "None"] != "None" } {
# An objfile that was a symlink to a differently named file is still
# findable with its original name.
set symlink_binary [standard_output_file "symlink-binary"]
remote_exec host "rm -f ${symlink_binary}"
remote_exec host "ln -sf ${testfile} ${symlink_binary}"
if [remote_file host exists "${symlink_binary}"] {
clean_restart "${symlink_binary}"
gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \
"${testfile}" "gdb.lookup_objfile of symlinked binary"
# On Windows we don't have proper symlinks, so skip this.
if ![ishost *-*-mingw*] {
set symlink_binary [standard_output_file "symlink-binary"]
remote_exec host "rm -f ${symlink_binary}"
remote_exec host "ln -sf ${testfile} ${symlink_binary}"
if [remote_file host exists "${symlink_binary}"] {
clean_restart "${symlink_binary}"
gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \
"${testfile}" "gdb.lookup_objfile of symlinked binary"
}
}
# Test printing an Objfile object that is no longer valid.
gdb_py_test_silent_cmd "python objfile = gdb.objfiles()\[0\]" \
"get first objfile" 1
gdb_file_cmd ${binfile}
gdb_test "python print(objfile)" "<gdb.Objfile \\\(invalid\\\)>"
gdb_test "python print(objfile)" "<gdb.Objfile \\\(invalid\\\)>"

View File

@ -41,7 +41,7 @@ gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
".*Breakpoint.*"
gdb_test "continue" ".*Breakpoint.*"
set python_file ${srcdir}/${subdir}/${testfile}.py
set python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
gdb_test_no_output "source ${python_file}" "load python file"

View File

@ -91,7 +91,7 @@ with_test_prefix "verbose on" {
gdb_test "py gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test)" \
"Registering global lookup_function_lookup_test pretty-printer ..."
gdb_test "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer1)" \
"Registering pp-test pretty-printer for .*/py-pp-registration ..."
"Registering pp-test pretty-printer for .*py-pp-registration ..."
test_printers "s1"
}

View File

@ -77,22 +77,35 @@ gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_test_no_output "set auto-load safe-path ${remote_python_file}:${binfile}" \
# Get the name of the binfile on the host; on a remote host this means
# stripping off any directory prefix.
if [is_remote host] {
set remote_binfile [file tail ${binfile}]
} else {
set remote_binfile ${binfile}
}
if [ishost *-*-mingw*] {
set remote_pathsep ";"
} else {
set remote_pathsep ":"
}
gdb_test_no_output "set auto-load safe-path ${remote_python_file}${remote_pathsep}${remote_binfile}" \
"set auto-load safe-path"
gdb_load ${binfile}
# Verify gdb loaded each script and they appear once in the list.
set test_name "verify scripts loaded"
gdb_test_multiple "info auto-load python-scripts" "$test_name" {
-re "Yes.*${testfile}.py.*Yes.*inlined-script.*$gdb_prompt $" {
pass "$test_name"
}
-re "${testfile}.py.*${testfile}.py.*$gdb_prompt $" {
fail "$test_name"
}
-re "inlined-script.*inlined-script.*$gdb_prompt $" {
fail "$test_name"
}
-re "Yes.*${testfile}.py.*Yes.*inlined-script.*$gdb_prompt $" {
pass "$test_name"
}
}
# Again, with a regexp this time.

View File

@ -66,8 +66,8 @@ gdb_test "python print (sal.is_valid())" "True" "test sal.is_valid"
# Test symbol table.
gdb_test "python print (symtab.filename)" ".*${py_symbol_c}" "test symtab.filename"
gdb_test "python print (symtab.objfile)" "<gdb.Objfile filename=${binfile}>" \
"test symtab.objfile"
gdb_test "python print (symtab.objfile)" \
"<gdb.Objfile filename=.*${testfile}.*>" "test symtab.objfile"
gdb_test "python print (symtab.fullname())" ".*${full_py_symbol_c}" "test symtab.fullname"
gdb_test "python print (symtab.is_valid())" "True" "test symtab.is_valid()"
gdb_test "python print (\"qq\" in global_symbols)" "True" "test qq in global symbols"