]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fixes for gdb.python tests on remote Windows host.
authorSandra Loosemore <sandra@codesourcery.com>
Tue, 13 Aug 2019 16:09:30 +0000 (09:09 -0700)
committerSandra Loosemore <sandra@codesourcery.com>
Tue, 13 Aug 2019 16:09:30 +0000 (09:09 -0700)
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.

14 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-completion.exp
gdb/testsuite/gdb.python/py-events.exp
gdb/testsuite/gdb.python/py-evsignal.exp
gdb/testsuite/gdb.python/py-evthreads.exp
gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
gdb/testsuite/gdb.python/py-framefilter.exp
gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
gdb/testsuite/gdb.python/py-objfile-script.exp
gdb/testsuite/gdb.python/py-objfile.exp
gdb/testsuite/gdb.python/py-pp-maint.exp
gdb/testsuite/gdb.python/py-pp-registration.exp
gdb/testsuite/gdb.python/py-section-script.exp
gdb/testsuite/gdb.python/py-symtab.exp

index fb19b9d7ca12a19135333f748880ab9e39ac877d..2cd9a004df0c0e173deb913a21285dd7a0417215 100644 (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
index 3c54360143c590488cdd352b85466ae33845ed13..1b1398cf2c805c5748f7b8a954addd774cd55d15 100644 (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"
-
-# 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'" {
index 817101cd163ef8a1d4091f0e1f9a474a5d8e312d..771d1de676f61a2bba448316bcf657d3317b527c 100644 (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."
index 9e4dcf3e4699aad55296ef934d710ba4b00fe9c4..c79ddcfa48c479c045b1c8387c5d0192aa069710 100644 (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."
index 5cd91dcb6f12ce450f141e80b48811cd632545a9..d688c5b77e5ea9400ef09c20f870cd875b594387 100644 (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."
index 2213bcffb2def84ab8d45e406adf59715c287e19..99b9f574c0afd7048e24968e31c9fcb98789aac6 100644 (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 {
index e3aed24c169e924945f808220bd1d217142a93fb..336c88597a9c19e9a8d4ec0665ea937618220b11 100644 (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"
index 02f0c9305ea87405d53bf0e57f060e09b58a8836..0bec17e437e2dd76029580c5ee238db3a951f59a 100644 (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"
 
index 14744c360207781ac9c94159b0adaab2c529951e..b318acc7909318c6009f3716cc1f5b42d2d92c95 100644 (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"
index cfe092ebd953d7128fdc7acd43eb8d4b42a4588a..154c2e59503c457f3700cf979a249a9a0ad02ec5 100644 (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\\\)>"
\ No newline at end of file
+gdb_test "python print(objfile)" "<gdb.Objfile \\\(invalid\\\)>"
index 4c65719f57cd0348b7f42c64e95447a3b0e663a2..b592cbaeadfc7c9b4901acfc3715ee9f266e62cb 100644 (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"
 
index 01fc39e519ba69ac064a0ad9b92a36e94c62aa90..fa9458fa2411cc302ede96ffc41ff1573567929a 100644 (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"
 }
index c4a6974ddfcf5f12ad55dd5024d26fc7f6c1454c..9eaa7911ef7ff1185fb8bb77f5684b5f6d93ad6d 100644 (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.
index 4a6a2abe7ade28005a50a5c8fdc7c8f15dd1ecee..04bff8d296d6f8de510021eac875b0cad2c2d907 100644 (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"