This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, testsuite] Fixes for gdb.python tests on remote Windows host


The attached patch fixes a bunch of FAILs and ERRORs I've seen in gdb.python tests running on remote Windows host. As noted in the commit message, the fixes are mostly obvious and repetitive; e.g., remember to copy the .py script to the remote host before trying to source it. Since this is a pretty big patch, though, I wasn't sure the whole thing qualifies as "obvious", and wanted to give folks a chance to object before I check it in. So I propose to push it to trunk in a week if I don't hear any objection or review (or promise to review) meanwhile.

-Sandra
commit a71336a227b8e4f78c24073168bdb45c57d156ef
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Mon Aug 12 14:39:07 2019 -0700

    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-12  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.

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index fb19b9d..6dd180c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,31 @@
+2019-08-12  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
diff --git a/gdb/testsuite/gdb.python/py-completion.exp b/gdb/testsuite/gdb.python/py-completion.exp
index 3c54360..1b1398c 100644
--- a/gdb/testsuite/gdb.python/py-completion.exp
+++ b/gdb/testsuite/gdb.python/py-completion.exp
@@ -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"
-
-# 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"
+# 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
+
+    # 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)"
-    }
-    -re "^completefilemethod ${testdir_regex}$" {
-        pass "completefilemethod completion"
+    # 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"
+	}
     }
-}
 
-# 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'" {
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index 817101c..771d1de 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -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."
diff --git a/gdb/testsuite/gdb.python/py-evsignal.exp b/gdb/testsuite/gdb.python/py-evsignal.exp
index 9e4dcf3..c79ddcf 100644
--- a/gdb/testsuite/gdb.python/py-evsignal.exp
+++ b/gdb/testsuite/gdb.python/py-evsignal.exp
@@ -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."
diff --git a/gdb/testsuite/gdb.python/py-evthreads.exp b/gdb/testsuite/gdb.python/py-evthreads.exp
index 5cd91dc..d688c5b 100644
--- a/gdb/testsuite/gdb.python/py-evthreads.exp
+++ b/gdb/testsuite/gdb.python/py-evthreads.exp
@@ -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."
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
index 2213bcf..99b9f57 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
@@ -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 {
diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp
index e3aed24..336c885 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
@@ -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"
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
index 02f0c93..0bec17e 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
@@ -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"
 
diff --git a/gdb/testsuite/gdb.python/py-objfile-script.exp b/gdb/testsuite/gdb.python/py-objfile-script.exp
index 14744c3..b318acc 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script.exp
+++ b/gdb/testsuite/gdb.python/py-objfile-script.exp
@@ -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"
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index cfe092e..154c2e5 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -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\\\)>"
\ No newline at end of file
+gdb_test "python print(objfile)" "<gdb.Objfile \\\(invalid\\\)>"
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp
index 4c65719..b592cba 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.exp
+++ b/gdb/testsuite/gdb.python/py-pp-maint.exp
@@ -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"
 
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp
index 01fc39e..fa9458f 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.exp
+++ b/gdb/testsuite/gdb.python/py-pp-registration.exp
@@ -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"
 }
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index c4a6974..0ab1519 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -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.
diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp
index 4a6a2ab..04bff8d 100644
--- a/gdb/testsuite/gdb.python/py-symtab.exp
+++ b/gdb/testsuite/gdb.python/py-symtab.exp
@@ -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"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]