[v2,50/79] Use "require" for Python tests

Message ID 20230112030052.3306113-51-tom@tromey.com
State Committed
Headers
Series Rewrite "require" test procedure and use it more often |

Commit Message

Tom Tromey Jan. 12, 2023, 3 a.m. UTC
  This changes various tests to use "require" for the Python feature.
---
 gdb/testsuite/gdb.ada/pp-rec-component.exp           |  5 +----
 gdb/testsuite/gdb.ada/py_range.exp                   |  5 +----
 gdb/testsuite/gdb.ada/py_taft.exp                    |  5 +----
 gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp |  5 ++---
 .../gdb.base/premature-dummy-frame-removal.exp       |  5 ++---
 gdb/testsuite/gdb.dwarf2/symtab-producer.exp         |  8 +-------
 gdb/testsuite/gdb.gdb/python-helper.exp              | 10 ++--------
 gdb/testsuite/gdb.python/compare-enum-type.exp       |  4 ++--
 gdb/testsuite/gdb.python/flexible-array-member.exp   |  5 ++---
 gdb/testsuite/gdb.python/lib-types.exp               |  5 ++---
 .../gdb.python/pretty-print-call-by-hand.exp         | 10 ++--------
 gdb/testsuite/gdb.python/py-arch-reg-groups.exp      |  4 +---
 gdb/testsuite/gdb.python/py-arch-reg-names.exp       |  4 +---
 gdb/testsuite/gdb.python/py-arch.exp                 |  4 +---
 gdb/testsuite/gdb.python/py-as-string.exp            |  4 ++--
 gdb/testsuite/gdb.python/py-auto-load-chaining.exp   |  5 ++---
 ...utoloaded-pretty-printers-in-newobjfile-event.exp | 10 ++++------
 gdb/testsuite/gdb.python/py-bad-printers.exp         |  5 ++---
 gdb/testsuite/gdb.python/py-block.exp                |  5 ++---
 gdb/testsuite/gdb.python/py-bp-locations.exp         |  4 ++--
 .../gdb.python/py-breakpoint-create-fail.exp         |  5 ++---
 gdb/testsuite/gdb.python/py-breakpoint.exp           |  5 ++---
 gdb/testsuite/gdb.python/py-caller-is.exp            |  5 ++---
 gdb/testsuite/gdb.python/py-charset.exp              |  5 ++---
 gdb/testsuite/gdb.python/py-cmd.exp                  |  5 ++---
 gdb/testsuite/gdb.python/py-completion.exp           |  5 ++---
 gdb/testsuite/gdb.python/py-connection-removed.exp   |  5 ++---
 gdb/testsuite/gdb.python/py-connection.exp           |  5 ++---
 gdb/testsuite/gdb.python/py-disasm.exp               |  5 ++---
 gdb/testsuite/gdb.python/py-doc-reformat.exp         |  4 ++--
 gdb/testsuite/gdb.python/py-error.exp                |  5 ++---
 gdb/testsuite/gdb.python/py-event-load.exp           |  4 +---
 gdb/testsuite/gdb.python/py-events.exp               |  4 +---
 gdb/testsuite/gdb.python/py-evsignal.exp             |  4 ++--
 gdb/testsuite/gdb.python/py-evthreads.exp            |  4 +---
 gdb/testsuite/gdb.python/py-explore-cc.exp           |  5 +----
 gdb/testsuite/gdb.python/py-explore.exp              |  5 ++---
 .../gdb.python/py-finish-breakpoint-deletion.exp     |  5 ++---
 gdb/testsuite/gdb.python/py-finish-breakpoint.exp    |  4 +---
 gdb/testsuite/gdb.python/py-finish-breakpoint2.exp   |  5 ++---
 gdb/testsuite/gdb.python/py-format-address.exp       |  4 +---
 gdb/testsuite/gdb.python/py-format-string.exp        |  4 ++--
 gdb/testsuite/gdb.python/py-frame-args.exp           |  5 ++---
 gdb/testsuite/gdb.python/py-frame-inline.exp         |  5 ++---
 gdb/testsuite/gdb.python/py-frame.exp                |  5 ++---
 gdb/testsuite/gdb.python/py-framefilter-addr.exp     |  5 ++---
 .../gdb.python/py-framefilter-invalidarg.exp         |  5 ++---
 gdb/testsuite/gdb.python/py-framefilter.exp          |  8 ++------
 gdb/testsuite/gdb.python/py-function.exp             |  5 ++---
 gdb/testsuite/gdb.python/py-inferior-leak.exp        |  5 ++---
 gdb/testsuite/gdb.python/py-inferior.exp             |  5 ++---
 gdb/testsuite/gdb.python/py-infthread.exp            |  5 ++---
 gdb/testsuite/gdb.python/py-label-symbol-value.exp   |  4 +---
 gdb/testsuite/gdb.python/py-lazy-string.exp          |  5 ++---
 gdb/testsuite/gdb.python/py-linetable.exp            |  4 +---
 gdb/testsuite/gdb.python/py-lookup-type.exp          |  5 ++---
 gdb/testsuite/gdb.python/py-mi-events.exp            |  4 ++--
 gdb/testsuite/gdb.python/py-mi-objfile.exp           |  4 ++--
 .../gdb.python/py-mi-var-info-path-expression.exp    |  5 ++---
 gdb/testsuite/gdb.python/py-nested-maps.exp          |  9 +--------
 gdb/testsuite/gdb.python/py-objfile-script.exp       |  5 ++---
 gdb/testsuite/gdb.python/py-objfile.exp              |  5 ++---
 gdb/testsuite/gdb.python/py-parameter.exp            |  5 ++---
 gdb/testsuite/gdb.python/py-pending-frame-level.exp  |  5 ++---
 gdb/testsuite/gdb.python/py-pp-integral.exp          |  5 ++---
 gdb/testsuite/gdb.python/py-pp-maint.exp             |  5 ++---
 gdb/testsuite/gdb.python/py-pp-re-notag.exp          |  5 ++---
 gdb/testsuite/gdb.python/py-pp-registration.exp      |  5 ++---
 gdb/testsuite/gdb.python/py-prettyprint.exp          |  5 ++---
 gdb/testsuite/gdb.python/py-progspace.exp            |  5 ++---
 gdb/testsuite/gdb.python/py-prompt.exp               | 10 +---------
 gdb/testsuite/gdb.python/py-rbreak.exp               |  5 ++---
 .../gdb.python/py-record-btrace-threads.exp          | 12 ++----------
 gdb/testsuite/gdb.python/py-record-btrace.exp        |  9 +--------
 gdb/testsuite/gdb.python/py-record-full.exp          |  9 +--------
 gdb/testsuite/gdb.python/py-recurse-unwind.exp       |  5 ++---
 gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp  |  5 +----
 gdb/testsuite/gdb.python/py-section-script.exp       |  5 ++---
 gdb/testsuite/gdb.python/py-send-packet.exp          |  6 +-----
 gdb/testsuite/gdb.python/py-shared.exp               |  5 +----
 gdb/testsuite/gdb.python/py-startup-opt.exp          |  7 +------
 gdb/testsuite/gdb.python/py-strfns.exp               |  5 ++---
 gdb/testsuite/gdb.python/py-symbol.exp               |  5 ++---
 gdb/testsuite/gdb.python/py-symtab.exp               |  5 ++---
 gdb/testsuite/gdb.python/py-sync-interp.exp          | 12 +-----------
 gdb/testsuite/gdb.python/py-template.exp             |  5 +----
 gdb/testsuite/gdb.python/py-thrhandle.exp            |  5 ++---
 gdb/testsuite/gdb.python/py-typeprint.exp            |  4 +---
 gdb/testsuite/gdb.python/py-unwind-inline.exp        |  5 ++---
 gdb/testsuite/gdb.python/py-unwind-maint.exp         |  5 ++---
 gdb/testsuite/gdb.python/py-unwind-user-regs.exp     |  5 ++---
 gdb/testsuite/gdb.python/py-unwind.exp               |  5 ++---
 gdb/testsuite/gdb.python/py-value-cc.exp             |  5 +----
 gdb/testsuite/gdb.python/py-value.exp                |  5 ++---
 gdb/testsuite/gdb.python/py-xmethods.exp             |  8 +-------
 gdb/testsuite/gdb.python/tui-window-names.exp        |  7 ++-----
 gdb/testsuite/gdb.python/tui-window.exp              |  4 +---
 gdb/testsuite/gdb.rust/pp.exp                        |  4 +---
 gdb/testsuite/gdb.server/server-kill-python.exp      | 10 +---------
 gdb/testsuite/gdb.threads/tls.exp                    |  5 +----
 100 files changed, 170 insertions(+), 374 deletions(-)
  

Patch

diff --git a/gdb/testsuite/gdb.ada/pp-rec-component.exp b/gdb/testsuite/gdb.ada/pp-rec-component.exp
index f5963fff799..b57bde330cf 100644
--- a/gdb/testsuite/gdb.ada/pp-rec-component.exp
+++ b/gdb/testsuite/gdb.ada/pp-rec-component.exp
@@ -15,7 +15,7 @@ 
 
 load_lib "ada.exp"
 
-require !skip_ada_tests
+require !skip_ada_tests !skip_python_tests
 
 standard_ada_testfile foo
 
@@ -25,9 +25,6 @@  if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
 
 clean_restart ${testfile}
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set remote_python_file \
     [gdb_remote_download host ${srcdir}/${subdir}/${gdb_test_file_name}.py]
 gdb_test_no_output "source ${remote_python_file}" \
diff --git a/gdb/testsuite/gdb.ada/py_range.exp b/gdb/testsuite/gdb.ada/py_range.exp
index d1a84b617fa..b2c91fb4e3c 100644
--- a/gdb/testsuite/gdb.ada/py_range.exp
+++ b/gdb/testsuite/gdb.ada/py_range.exp
@@ -16,7 +16,7 @@ 
 load_lib "ada.exp"
 load_lib gdb-python.exp
 
-require !skip_ada_tests
+require !skip_ada_tests !skip_python_tests
 
 standard_ada_testfile foo
 
@@ -26,9 +26,6 @@  if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
 
 clean_restart ${testfile}
 
-# Skip this testcase if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
 runto "foo.adb:$bp_location"
 
diff --git a/gdb/testsuite/gdb.ada/py_taft.exp b/gdb/testsuite/gdb.ada/py_taft.exp
index ea9e7b1db5c..543bc728e3c 100644
--- a/gdb/testsuite/gdb.ada/py_taft.exp
+++ b/gdb/testsuite/gdb.ada/py_taft.exp
@@ -16,7 +16,7 @@ 
 load_lib "ada.exp"
 load_lib gdb-python.exp
 
-require !skip_ada_tests
+require !skip_ada_tests !skip_python_tests
 
 standard_ada_testfile main
 
@@ -26,9 +26,6 @@  if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
 
 clean_restart ${testfile}
 
-# Skip this testcase if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set bp_location [gdb_get_line_number "STOP" ${testdir}/main.adb]
 runto "main.adb:$bp_location"
 
diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
index f525b1af33a..88e95d13ae2 100644
--- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
+++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
@@ -51,13 +51,12 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
     return -1
 }
 
-# Skip this test if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
index e21ff2efab9..f5c55f58425 100644
--- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
+++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
@@ -36,6 +36,8 @@ 
 
 standard_testfile .c
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     return -1
 }
@@ -44,9 +46,6 @@  if {![runto_main]} {
     return 0
 }
 
-# Skip this test if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
 gdb_test_no_output "source ${pyfile}" "load python file"
 
diff --git a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
index 50cb428dae5..545d76f1246 100644
--- a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
+++ b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
@@ -17,10 +17,7 @@  load_lib dwarf.exp
 load_lib gdb-python.exp
 
 # This test can only be run on targets which support DWARF-2 and use gas.
-require dwarf2_support
-
-# This test can also only be run when we have python support in gdb,
-# but that test can only be done after gdb has started, below.
+require dwarf2_support !skip_python_tests
 
 standard_testfile main.c -dw.S
 
@@ -87,9 +84,6 @@  if { [prepare_for_testing "failed to prepare" ${testfile} \
 
 set GDBFLAGS $saved_gdbflags
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_py_test_silent_cmd "python with_producer = gdb.lookup_global_symbol(\"with_producer\")" \
     "get with_producer symbol" 0
 
diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index d6c316caf85..3c0e2e57304 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -24,6 +24,8 @@  if [target_info exists gdb,noinferiorio] {
     return
 }
 
+require !skip_python_tests
+
 standard_testfile .cc
 
 if { [build_executable "failed to build" $testfile $srcfile {debug c++}] } {
@@ -38,14 +40,6 @@  if { ![file readable $py_helper_script] \
     return
 }
 
-# Start GDB and check that we have python support.
-gdb_start
-if { [skip_python_tests] } {
-    untested "skipped gdb-gdb.py tests due to lack of python support"
-    return
-}
-gdb_exit
-
 # The main test.  This is called by the self-test framework once GDB
 # has been started on a copy of itself.
 proc test_python_helper {} {
diff --git a/gdb/testsuite/gdb.python/compare-enum-type.exp b/gdb/testsuite/gdb.python/compare-enum-type.exp
index 8d5d65e25f6..0cc6bd93daa 100644
--- a/gdb/testsuite/gdb.python/compare-enum-type.exp
+++ b/gdb/testsuite/gdb.python/compare-enum-type.exp
@@ -17,11 +17,11 @@ 
 
 standard_testfile -a.c -b.c
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" "compare-enum-type" \
 	  [list $srcfile $srcfile2]] } {
     return
 }
 
-if { [skip_python_tests] } { continue }
-
 gdb_test "py print(gdb.parse_and_eval('e1').type == gdb.parse_and_eval('e2').type)" "True"
diff --git a/gdb/testsuite/gdb.python/flexible-array-member.exp b/gdb/testsuite/gdb.python/flexible-array-member.exp
index bed3c972d94..23f1da067a5 100644
--- a/gdb/testsuite/gdb.python/flexible-array-member.exp
+++ b/gdb/testsuite/gdb.python/flexible-array-member.exp
@@ -17,14 +17,13 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" \
 	${testfile} ${srcfile}] } {
     return
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if { ![runto break_here] } {
     untested "could not run to break_here"
     return
diff --git a/gdb/testsuite/gdb.python/lib-types.exp b/gdb/testsuite/gdb.python/lib-types.exp
index bf3aff1e2e3..92359c941a6 100644
--- a/gdb/testsuite/gdb.python/lib-types.exp
+++ b/gdb/testsuite/gdb.python/lib-types.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile .cc
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
index f58044e273d..64414a3c23b 100644
--- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
+++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
@@ -19,15 +19,9 @@ 
 
 load_lib gdb-python.exp
 
-standard_testfile
-
-# gdb needs to be started here for skip_python_tests to work.
-# prepare_for_testing could be used instead, but it could compile the program
-# unnecessarily, so starting GDB like this is preferable.
-gdb_start
+require !skip_python_tests
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
+standard_testfile
 
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
     untested "failed to compile"
diff --git a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
index a4cafdccdc8..5a0077d020d 100644
--- a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
+++ b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
@@ -16,15 +16,13 @@ 
 # Check the gdb.Architecture.register_groups functionality.
 
 load_lib gdb-python.exp
+require !skip_python_tests
 standard_testfile py-arch.c
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-arch-reg-names.exp b/gdb/testsuite/gdb.python/py-arch-reg-names.exp
index 67ceeff09b8..73e41401f51 100644
--- a/gdb/testsuite/gdb.python/py-arch-reg-names.exp
+++ b/gdb/testsuite/gdb.python/py-arch-reg-names.exp
@@ -16,15 +16,13 @@ 
 # Check the gdb.Architecture.registers functionality.
 
 load_lib gdb-python.exp
+require !skip_python_tests
 standard_testfile py-arch.c
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index e9967ae0006..449613bc0fb 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -13,15 +13,13 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 load_lib gdb-python.exp
+require !skip_python_tests
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-as-string.exp b/gdb/testsuite/gdb.python/py-as-string.exp
index 9ae6f5d929a..8bf248a59ad 100644
--- a/gdb/testsuite/gdb.python/py-as-string.exp
+++ b/gdb/testsuite/gdb.python/py-as-string.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
@@ -28,8 +30,6 @@  if ![runto_main] {
     return 0
 }
 
-if { [skip_python_tests] } { continue }
-
 proc test_as_string { } {
     gdb_test "p \$_as_string(2)" "\"2\""
     gdb_test "p \$_as_string(enum_valid)" "\"ENUM_VALUE_B\""
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
index 9b7b0b5c202..aac6eb305b9 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
@@ -19,6 +19,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile .c -f1.c -f2.c
 
 # Two additional object files needed for this test.
@@ -47,9 +49,6 @@  if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp
index 97a0f24732b..a67ae48b316 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp
@@ -19,6 +19,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile -main.cc
 
 set srcfile_lib "${testfile}-lib.cc"
@@ -27,12 +29,6 @@  set libname "lib${testfile}"
 set python_autoload_file "${srcdir}/${subdir}/${libname}.so-gdb.py"
 set binfile_lib [standard_output_file "${libname}.so"]
 
-# Start GDB first - needed for skip_python_tests.
-clean_restart
-
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # Compile library.
 if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} \
       {debug c++}] != "" } {
@@ -47,6 +43,8 @@  if { [gdb_compile ${srcdir}/${subdir}/${srcfile} \
     return -1
 }
 
+clean_restart
+
 # Make the -gdb.py script available to gdb, it is automatically loaded by
 # gdb if it is put in the same directory as the library.
 set remote_python_autoload_file \
diff --git a/gdb/testsuite/gdb.python/py-bad-printers.exp b/gdb/testsuite/gdb.python/py-bad-printers.exp
index 7249639dc7c..26e6a97916c 100644
--- a/gdb/testsuite/gdb.python/py-bad-printers.exp
+++ b/gdb/testsuite/gdb.python/py-bad-printers.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp
index bbf9eafa10b..90c3b4d0fb0 100644
--- a/gdb/testsuite/gdb.python/py-block.exp
+++ b/gdb/testsuite/gdb.python/py-block.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-bp-locations.exp b/gdb/testsuite/gdb.python/py-bp-locations.exp
index a3894436b2c..55aca67eb9d 100644
--- a/gdb/testsuite/gdb.python/py-bp-locations.exp
+++ b/gdb/testsuite/gdb.python/py-bp-locations.exp
@@ -15,6 +15,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
@@ -25,8 +27,6 @@  save_vars { GDBFLAGS } {
     clean_restart $testfile
 }
 
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
index ec9d553dc0e..6c1a262ad47 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 clean_restart "${testfile}"
 if ![runto_main] {
     return
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 49c09795206..0995ae49ead 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -26,6 +26,8 @@  set skip_hw_watchpoint_tests_p [skip_hw_watchpoint_tests]
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 set options {debug c++}
@@ -34,9 +36,6 @@  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${options}]
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 proc_with_prefix test_bkpt_basic { } {
     global srcfile testfile hex decimal
 
diff --git a/gdb/testsuite/gdb.python/py-caller-is.exp b/gdb/testsuite/gdb.python/py-caller-is.exp
index d1bf56fda67..66e0ce516e4 100644
--- a/gdb/testsuite/gdb.python/py-caller-is.exp
+++ b/gdb/testsuite/gdb.python/py-caller-is.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
@@ -28,9 +30,6 @@  if ![runto_main] {
     return 0
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_breakpoint "bottom_func"
 gdb_continue_to_breakpoint "bottom_func"
 
diff --git a/gdb/testsuite/gdb.python/py-charset.exp b/gdb/testsuite/gdb.python/py-charset.exp
index b49617823ba..9e831954cdd 100644
--- a/gdb/testsuite/gdb.python/py-charset.exp
+++ b/gdb/testsuite/gdb.python/py-charset.exp
@@ -15,12 +15,11 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # Each test data has 4 parts:
 # 1. The string used in 'show XXX-charset' command,
 # 2. The string expected in the output of the command used in #1,
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index 707068899fa..0eb785f6d4d 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-completion.exp b/gdb/testsuite/gdb.python/py-completion.exp
index f466853353f..bf1abf32ee2 100644
--- a/gdb/testsuite/gdb.python/py-completion.exp
+++ b/gdb/testsuite/gdb.python/py-completion.exp
@@ -17,14 +17,13 @@  set testfile "py-completion"
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 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 }
-
 # 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] } {
diff --git a/gdb/testsuite/gdb.python/py-connection-removed.exp b/gdb/testsuite/gdb.python/py-connection-removed.exp
index 8ffd99567ac..efbcf46516f 100644
--- a/gdb/testsuite/gdb.python/py-connection-removed.exp
+++ b/gdb/testsuite/gdb.python/py-connection-removed.exp
@@ -25,15 +25,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile py-connection.c
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] then {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-connection.exp b/gdb/testsuite/gdb.python/py-connection.exp
index 0719fe3b1f6..78710fd27de 100644
--- a/gdb/testsuite/gdb.python/py-connection.exp
+++ b/gdb/testsuite/gdb.python/py-connection.exp
@@ -20,15 +20,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp
index 3aa77d44b61..57f8fdfce41 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp
+++ b/gdb/testsuite/gdb.python/py-disasm.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug"] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     fail "can't run to main"
     return 0
diff --git a/gdb/testsuite/gdb.python/py-doc-reformat.exp b/gdb/testsuite/gdb.python/py-doc-reformat.exp
index 5af64d61d5d..3829873c4cc 100644
--- a/gdb/testsuite/gdb.python/py-doc-reformat.exp
+++ b/gdb/testsuite/gdb.python/py-doc-reformat.exp
@@ -19,9 +19,9 @@ 
 
 load_lib gdb-python.exp
 
-# Check that Python is supported.
+require !skip_python_tests
+
 clean_restart
-if { [skip_python_tests] } { continue }
 
 # A global counter used to number the tests.
 set idx 0
diff --git a/gdb/testsuite/gdb.python/py-error.exp b/gdb/testsuite/gdb.python/py-error.exp
index b04be6a774f..0a8fd190c18 100644
--- a/gdb/testsuite/gdb.python/py-error.exp
+++ b/gdb/testsuite/gdb.python/py-error.exp
@@ -20,13 +20,12 @@  set testfile "py-error"
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 # Start with a fresh gdb.
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set charset "IBM1047"
 
 set test2 "main reached"
diff --git a/gdb/testsuite/gdb.python/py-event-load.exp b/gdb/testsuite/gdb.python/py-event-load.exp
index 8dce6f19e5a..f3631251148 100644
--- a/gdb/testsuite/gdb.python/py-event-load.exp
+++ b/gdb/testsuite/gdb.python/py-event-load.exp
@@ -18,7 +18,7 @@ 
 
 load_lib gdb-python.exp
 
-require !skip_shlib_tests
+require !skip_shlib_tests !skip_python_tests
 
 if {[get_compiler_info]} {
     warning "Could not get compiler info"
@@ -49,8 +49,6 @@  if {![runto_main]} {
     return
 }
 
-if { [skip_python_tests] } { return }
-
 gdb_test_no_output "set var libname = \"$binfile2_dlopen\""
 
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-event-load.py]
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index 109f8c1ca4e..ea1a6f502ff 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -13,7 +13,7 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require !use_gdb_stub
+require !use_gdb_stub !skip_python_tests
 
 load_lib gdb-python.exp
 
@@ -34,8 +34,6 @@  if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
 # Start with a fresh gdb.
 clean_restart ${testfile}
 
-if { [skip_python_tests] } { continue }
-
 gdb_test_no_output "python import gdb.events"
 
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
diff --git a/gdb/testsuite/gdb.python/py-evsignal.exp b/gdb/testsuite/gdb.python/py-evsignal.exp
index 03e2f8b0f80..2f0e791884e 100644
--- a/gdb/testsuite/gdb.python/py-evsignal.exp
+++ b/gdb/testsuite/gdb.python/py-evsignal.exp
@@ -22,6 +22,8 @@  if {[target_info gdb_protocol] == "remote"
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile py-evthreads.c
 
 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -29,8 +31,6 @@  if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
 }
 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"
 
diff --git a/gdb/testsuite/gdb.python/py-evthreads.exp b/gdb/testsuite/gdb.python/py-evthreads.exp
index fde5501b1db..e993c6fe9b2 100644
--- a/gdb/testsuite/gdb.python/py-evthreads.exp
+++ b/gdb/testsuite/gdb.python/py-evthreads.exp
@@ -13,7 +13,7 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require support_displaced_stepping
+require support_displaced_stepping !skip_python_tests
 
 load_lib gdb-python.exp
 
@@ -28,8 +28,6 @@  save_vars { GDBFLAGS } {
     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"
 
diff --git a/gdb/testsuite/gdb.python/py-explore-cc.exp b/gdb/testsuite/gdb.python/py-explore-cc.exp
index bb42b56b5a8..d3678cf71ca 100644
--- a/gdb/testsuite/gdb.python/py-explore-cc.exp
+++ b/gdb/testsuite/gdb.python/py-explore-cc.exp
@@ -16,7 +16,7 @@ 
 # This file is part of the GDB testsuite.  It tests the mechanism
 # exposing values to Python.
 
-require !skip_cplus_tests
+require !skip_cplus_tests !skip_python_tests
 
 standard_testfile py-explore.cc
 
@@ -24,9 +24,6 @@  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set int_ptr_ref_desc "The value of 'int_ptr_ref' is of type 'int_ptr' which is a typedef of type 'int \\*'.*\'int_ptr_ref' is a pointer to a value of type 'int'.*"
 
 set b_desc "The value of 'b' is a struct/class of type 'B' with the following fields:.*\
diff --git a/gdb/testsuite/gdb.python/py-explore.exp b/gdb/testsuite/gdb.python/py-explore.exp
index 8b6e677446b..dd36740bac5 100644
--- a/gdb/testsuite/gdb.python/py-explore.exp
+++ b/gdb/testsuite/gdb.python/py-explore.exp
@@ -15,13 +15,12 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set SS "struct SimpleStruct"
 set SU "union SimpleUnion"
 set CS "struct ComplexStruct"
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp
index 7855714c781..d414268b1cb 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp
@@ -17,15 +17,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] then {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index 7cc2c40a299..d37508c7d5c 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -16,7 +16,7 @@ 
 # This file is part of the GDB testsuite.  It tests the mechanism
 # exposing values to Python.
 
-require !skip_shlib_tests
+require !skip_shlib_tests !skip_python_tests
 
 load_lib gdb-python.exp
 
@@ -37,8 +37,6 @@  if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
 # Start with a fresh gdb.
 clean_restart ${testfile}
 
-if { [skip_python_tests] } { continue }
-
 #
 # Test FinishBreakpoint in normal conditions
 #
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
index 7eb394ee29a..300020553a1 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile .cc
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp
index c90acad56c8..d9fed3f6ef2 100644
--- a/gdb/testsuite/gdb.python/py-format-address.exp
+++ b/gdb/testsuite/gdb.python/py-format-address.exp
@@ -14,6 +14,7 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 load_lib gdb-python.exp
+require !skip_python_tests
 standard_testfile
 
 foreach func_name { foo bar } {
@@ -31,9 +32,6 @@  set binary_bar [standard_output_file "${testfile}-bar"]
 
 clean_restart $binary_foo
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 6599fe31876..30a57b2254f 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -18,12 +18,12 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
-# Skip all tests if Python scripting is not enabled.
 gdb_exit
 gdb_start
-if { [skip_python_tests] } { continue }
 
 # Build inferior to language specification.
 proc build_inferior {exefile lang} {
diff --git a/gdb/testsuite/gdb.python/py-frame-args.exp b/gdb/testsuite/gdb.python/py-frame-args.exp
index 2ecc80ddae8..091e26dd5b1 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.exp
+++ b/gdb/testsuite/gdb.python/py-frame-args.exp
@@ -15,13 +15,12 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-frame-inline.exp b/gdb/testsuite/gdb.python/py-frame-inline.exp
index d755c663fe8..719ec18aa37 100644
--- a/gdb/testsuite/gdb.python/py-frame-inline.exp
+++ b/gdb/testsuite/gdb.python/py-frame-inline.exp
@@ -15,15 +15,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index fca732cf142..f17e2f9844a 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # The following tests require execution.
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.exp b/gdb/testsuite/gdb.python/py-framefilter-addr.exp
index 2cda4e596e8..5dad3bd0f2d 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-addr.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-addr.exp
@@ -19,15 +19,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
index 43bb53540ae..86a830d5eef 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
@@ -15,6 +15,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile amd64-py-framefilter-invalidarg.S
 
 if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
@@ -32,9 +34,6 @@  if {[build_executable $testfile.exp $testfile $srcfile {}] == -1} {
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
 # Care is taken to put it in the same directory as the binary so that
 # gdb will find it.
diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp
index ac214fc6cbc..81101c11809 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 # We cannot use prepare_for_testing as we have to set the safe-patch
@@ -30,9 +32,6 @@  if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_test "info frame-filter" \
     "No frame filters\\." \
     "info frame filter before loading filters"
@@ -291,9 +290,6 @@  if {[build_executable $testfile.exp $testfile $srcfile {nodebug}] == -1} {
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
 # Care is taken to put it in the same directory as the binary so that
 # gdb will find it.
diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp
index 358a0855fb8..7c48f7a0bd8 100644
--- a/gdb/testsuite/gdb.python/py-function.exp
+++ b/gdb/testsuite/gdb.python/py-function.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 # Start with a fresh gdb.
 
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_test_multiline "input convenience function" \
   "python" "" \
   "class test_func (gdb.Function):" "" \
diff --git a/gdb/testsuite/gdb.python/py-inferior-leak.exp b/gdb/testsuite/gdb.python/py-inferior-leak.exp
index 1eff7ae0316..4e2fa641545 100644
--- a/gdb/testsuite/gdb.python/py-inferior-leak.exp
+++ b/gdb/testsuite/gdb.python/py-inferior-leak.exp
@@ -18,13 +18,12 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 clean_restart
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { return }
-
 # Skip this test if the tracemalloc module is not available.
 if { ![gdb_py_module_available "tracemalloc"] } {
     unsupported "tracemalloc module not available"
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index ee6b9fc97c5..0286d82394c 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}] != "" } {
@@ -27,9 +29,6 @@  if { [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable
 # Start with a fresh gdb.
 clean_restart ${testfile}
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 switch [get_endianness] {
     little { set python_pack_char "<" }
     big { set python_pack_char ">" }
diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp
index 4e468bfef18..47c6b19dbfc 100644
--- a/gdb/testsuite/gdb.python/py-infthread.exp
+++ b/gdb/testsuite/gdb.python/py-infthread.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_test_multiline "install new_thread event handler" \
     "python" "" \
     "seen_a_thread = False" "" \
diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.exp b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
index 3aea2bb4f2c..f3e91b74a46 100644
--- a/gdb/testsuite/gdb.python/py-label-symbol-value.exp
+++ b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
@@ -17,15 +17,13 @@ 
 # symbol (i.e. a symbol for a goto label).
 
 load_lib gdb-python.exp
+require !skip_python_tests
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index 57c6c1c87b7..9f3bad5c660 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main ] {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index 19c3e745676..ff438216cf3 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -14,6 +14,7 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 load_lib gdb-python.exp
+require !skip_python_tests
 set opts {}
 standard_testfile .S
 
@@ -34,9 +35,6 @@  if ![runto_main] {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_py_test_silent_cmd "python lt = gdb.selected_frame().find_sal().symtab.linetable()" \
     "get instruction" 0
 
diff --git a/gdb/testsuite/gdb.python/py-lookup-type.exp b/gdb/testsuite/gdb.python/py-lookup-type.exp
index d81b3520b5c..7527c13a925 100644
--- a/gdb/testsuite/gdb.python/py-lookup-type.exp
+++ b/gdb/testsuite/gdb.python/py-lookup-type.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 # Note that the purpose of this testcase is to test the behavior
 # of gdb.lookup_type searching for the primitive types internally
 # created by each language since GDB.  So, we must start GDB without
@@ -27,9 +29,6 @@  gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 proc test_lookup_type { lang type_name } {
     gdb_test_no_output "set language ${lang}"
     gdb_test "python print(gdb.lookup_type('${type_name}').name)" \
diff --git a/gdb/testsuite/gdb.python/py-mi-events.exp b/gdb/testsuite/gdb.python/py-mi-events.exp
index d3ffb154d91..4ed3405730a 100644
--- a/gdb/testsuite/gdb.python/py-mi-events.exp
+++ b/gdb/testsuite/gdb.python/py-mi-events.exp
@@ -18,6 +18,8 @@ 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
+require !skip_python_tests
+
 gdb_exit
 if [mi_gdb_start] {
     return
@@ -31,8 +33,6 @@  if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-if { [skip_python_tests] } { return }
-
 set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}]
 
 mi_delete_breakpoints
diff --git a/gdb/testsuite/gdb.python/py-mi-objfile.exp b/gdb/testsuite/gdb.python/py-mi-objfile.exp
index 2aaf65d0b7c..1b258623fb8 100644
--- a/gdb/testsuite/gdb.python/py-mi-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-mi-objfile.exp
@@ -18,6 +18,8 @@ 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
+require !skip_python_tests
+
 gdb_exit
 if [mi_gdb_start] {
     return
@@ -31,8 +33,6 @@  if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-if { [skip_python_tests] } { return }
-
 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
 # Care is taken to put it in the same directory as the binary so that
 # gdb will find it.
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 77227b60e34..b618b08e393 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
@@ -18,6 +18,8 @@ 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
+require !skip_python_tests
+
 #
 # Start here
 #
@@ -29,9 +31,6 @@  if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" }
 
 mi_clean_restart $binfile
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
 mi_gdb_test "source ${pyfile}" \
   ".*\\^done" \
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.exp b/gdb/testsuite/gdb.python/py-nested-maps.exp
index 35cb1007bb5..76e38c2555c 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.exp
+++ b/gdb/testsuite/gdb.python/py-nested-maps.exp
@@ -19,14 +19,7 @@ 
 
 load_lib gdb-python.exp
 
-standard_testfile
-
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
+require !skip_python_tests
 
 standard_testfile
 
diff --git a/gdb/testsuite/gdb.python/py-objfile-script.exp b/gdb/testsuite/gdb.python/py-objfile-script.exp
index 33068a72c8c..550a68447b8 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script.exp
+++ b/gdb/testsuite/gdb.python/py-objfile-script.exp
@@ -18,6 +18,8 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     return -1
 }
@@ -26,9 +28,6 @@  if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
 # Care is taken to put it in the same directory as the binary so that
 # gdb will find it.
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 811db0c7eb9..cf9d5aedc19 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index 3a117072e3a..ab99817b5f3 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -18,12 +18,11 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 # Start with a fresh gdb.
 clean_restart
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 proc py_param_test_maybe_no_output { command pattern args } {
     if [string length $pattern] {
 	gdb_test $command $pattern $args
diff --git a/gdb/testsuite/gdb.python/py-pending-frame-level.exp b/gdb/testsuite/gdb.python/py-pending-frame-level.exp
index a00a23c40c2..b83eaa31095 100644
--- a/gdb/testsuite/gdb.python/py-pending-frame-level.exp
+++ b/gdb/testsuite/gdb.python/py-pending-frame-level.exp
@@ -17,15 +17,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-pp-integral.exp b/gdb/testsuite/gdb.python/py-pp-integral.exp
index a576bcb0f39..3fa247661ae 100644
--- a/gdb/testsuite/gdb.python/py-pp-integral.exp
+++ b/gdb/testsuite/gdb.python/py-pp-integral.exp
@@ -15,13 +15,12 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto tick_tock] {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp
index 7e8afa4d49b..5e6f23aeb9d 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.exp
+++ b/gdb/testsuite/gdb.python/py-pp-maint.exp
@@ -23,15 +23,14 @@  if [is_remote host] {
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.exp b/gdb/testsuite/gdb.python/py-pp-re-notag.exp
index a576bcb0f39..3fa247661ae 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.exp
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.exp
@@ -15,13 +15,12 @@ 
 
 standard_testfile
 
+require !skip_python_tests
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto tick_tock] {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp
index 32bd2acf5ec..c85fc4a1a79 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.exp
+++ b/gdb/testsuite/gdb.python/py-pp-registration.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set remote_python_file [gdb_remote_download host \
 			    ${srcdir}/${subdir}/${testfile}.py]
 
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index bdd92ec4bfd..8166e118693 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 # Start with a fresh gdb.
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 proc run_lang_tests {exefile lang} {
     global srcdir subdir srcfile testfile hex
     if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "debug $lang"] != "" } {
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index 33460b80b32..23b328aa680 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
@@ -30,9 +32,6 @@  gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_test "python print (gdb.current_progspace().filename)" "None" \
   "current progspace filename (None)"
 gdb_test "python print (gdb.progspaces())" "\\\[<gdb.Progspace object at $hex>\\\]"
diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp
index 03a730bcd46..56a0b47c78d 100644
--- a/gdb/testsuite/gdb.python/py-prompt.exp
+++ b/gdb/testsuite/gdb.python/py-prompt.exp
@@ -21,15 +21,7 @@  standard_testfile
 load_lib gdb-python.exp
 load_lib prompt.exp
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-gdb_exit
+require !skip_python_tests
 
 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     return -1
diff --git a/gdb/testsuite/gdb.python/py-rbreak.exp b/gdb/testsuite/gdb.python/py-rbreak.exp
index 2d39141285f..6c5f77ef3b1 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.exp
+++ b/gdb/testsuite/gdb.python/py-rbreak.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile py-rbreak.c py-rbreak-func2.c
 
 if {[prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } {
     return 1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
index ef14edceded..f0845f8bbd5 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
@@ -15,9 +15,9 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Skip this test if btrace is disabled.
+load_lib gdb-python.exp
 
-require !skip_btrace_tests
+require !skip_btrace_tests !skip_python_tests
 
 standard_testfile
 
@@ -27,14 +27,6 @@  if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {deb
 }
 clean_restart $testfile
 
-# Skip this test if python is disabled.
-
-load_lib gdb-python.exp
-if { [skip_python_tests] } {
-    untested "skipping python tests"
-    return -1
-}
-
 if { ![runto_main] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index 38c326f555f..1326e8283b9 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -17,7 +17,7 @@ 
 
 # Skip this test if btrace is disabled.
 
-require !skip_btrace_tests
+require !skip_btrace_tests !skip_python_tests
 
 load_lib gdb-python.exp
 
@@ -25,13 +25,6 @@  standard_testfile
 
 if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
 
-# Skip this test if python is disabled.
-
-if { [skip_python_tests] } {
-    untested "skipping python tests"
-    return -1
-}
-
 if {![runto_main]} {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp
index fe19d6b207c..eb40d51f218 100644
--- a/gdb/testsuite/gdb.python/py-record-full.exp
+++ b/gdb/testsuite/gdb.python/py-record-full.exp
@@ -17,7 +17,7 @@ 
 
 # Skip this test if target does not support recording.
 
-require supports_process_record
+require supports_process_record !skip_python_tests
 
 load_lib gdb-python.exp
 
@@ -25,13 +25,6 @@  standard_testfile
 
 if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
 
-# Skip this test if python is disabled.
-
-if { [skip_python_tests] } {
-    untested "skipping python tests"
-    return -1
-}
-
 if {![runto_main]} {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-recurse-unwind.exp b/gdb/testsuite/gdb.python/py-recurse-unwind.exp
index 6e623933f6c..498443e9e54 100644
--- a/gdb/testsuite/gdb.python/py-recurse-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-recurse-unwind.exp
@@ -24,15 +24,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
 
 gdb_test "source ${pyfile}" "Python script imported" \
diff --git a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
index 98eb94f5d2c..66a010108f4 100644
--- a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
@@ -17,7 +17,7 @@ 
 # exposing rvalue reference values to Python.  It is based on
 # gdb.python/py-value-cc.exp.
 
-require !skip_cplus_tests
+require !skip_cplus_tests !skip_python_tests
 
 standard_testfile .cc
 
@@ -26,9 +26,6 @@  if {[prepare_for_testing $testfile.exp $testfile $srcfile \
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if {[skip_python_tests]} { continue }
-
 if {![runto_main]} {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index d3d2a6ccd60..96dafdbfd67 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -28,6 +28,8 @@  if {![istarget *-*-linux*]
     return
 }
 
+require !skip_python_tests
+
 standard_testfile
 
 # Make this available to gdb before the program starts, it is
@@ -48,9 +50,6 @@  if {[build_executable $testfile.exp $testfile $srcfile \
 gdb_exit
 gdb_start
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 gdb_reinitialize_dir $srcdir/$subdir
 
 # Try first with a restrictive safe-path.
diff --git a/gdb/testsuite/gdb.python/py-send-packet.exp b/gdb/testsuite/gdb.python/py-send-packet.exp
index c6305ed6291..e09dbb05fd4 100644
--- a/gdb/testsuite/gdb.python/py-send-packet.exp
+++ b/gdb/testsuite/gdb.python/py-send-packet.exp
@@ -24,16 +24,12 @@  load_lib gdbserver-support.exp
 
 standard_testfile
 
-require !skip_gdbserver_tests
+require !skip_gdbserver_tests !skip_python_tests
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-if { [skip_python_tests] } {
-    return 0
-}
-
 # Make sure we're disconnected, in case we're testing with an
 # extended-remote board, therefore already connected.
 gdb_test "disconnect" ".*"
diff --git a/gdb/testsuite/gdb.python/py-shared.exp b/gdb/testsuite/gdb.python/py-shared.exp
index ac68e2cbd07..fdec1df2cc8 100644
--- a/gdb/testsuite/gdb.python/py-shared.exp
+++ b/gdb/testsuite/gdb.python/py-shared.exp
@@ -17,7 +17,7 @@ 
 
 load_lib gdb-python.exp
 
-require !skip_shlib_tests
+require !skip_shlib_tests !skip_python_tests
 
 standard_testfile
 
@@ -41,9 +41,6 @@  if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opt
 clean_restart $testfile
 gdb_load_shlib ${library}
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # The following tests require execution.
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.python/py-startup-opt.exp b/gdb/testsuite/gdb.python/py-startup-opt.exp
index 89f97fd729c..2d9fd2a0444 100644
--- a/gdb/testsuite/gdb.python/py-startup-opt.exp
+++ b/gdb/testsuite/gdb.python/py-startup-opt.exp
@@ -16,12 +16,7 @@ 
 # Test the flags within GDB that can be used to control how Python is
 # initialized.
 
-gdb_start
-
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
-gdb_exit
+require !skip_python_tests
 
 # Return a list containing two directory paths for newly created home
 # directories.
diff --git a/gdb/testsuite/gdb.python/py-strfns.exp b/gdb/testsuite/gdb.python/py-strfns.exp
index 94d71800584..162e1026eb5 100644
--- a/gdb/testsuite/gdb.python/py-strfns.exp
+++ b/gdb/testsuite/gdb.python/py-strfns.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
@@ -28,9 +30,6 @@  if ![runto_main] {
     return 0
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 proc test_all_strfns { } {
     gdb_test "p \$_streq (str1, str2)" " = 1"
     gdb_test "p \$_streq (str1, str3)" " = 0"
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index d2192bf5d88..a0bf34d8aa1 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile py-symbol.c py-symbol-2.c
 
 set opts { debug additional_flags=-DUSE_TWO_FILES }
@@ -26,9 +28,6 @@  if {[prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set readnow_p [readnow]
 
 # Check that we find all static symbols before the inferior has
diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp
index 43d693e16f3..5b68524140e 100644
--- a/gdb/testsuite/gdb.python/py-symtab.exp
+++ b/gdb/testsuite/gdb.python/py-symtab.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile py-symbol.c
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-sync-interp.exp b/gdb/testsuite/gdb.python/py-sync-interp.exp
index 408a165e648..1e994bf7393 100644
--- a/gdb/testsuite/gdb.python/py-sync-interp.exp
+++ b/gdb/testsuite/gdb.python/py-sync-interp.exp
@@ -20,20 +20,10 @@ 
 
 standard_testfile
 
-require can_spawn_for_attach
+require can_spawn_for_attach !skip_python_tests
 
 load_lib gdb-python.exp
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-gdb_exit
-
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp
index 1383e3a1089..14ebb670188 100644
--- a/gdb/testsuite/gdb.python/py-template.exp
+++ b/gdb/testsuite/gdb.python/py-template.exp
@@ -16,7 +16,7 @@ 
 # This file is part of the GDB testsuite.  It tests the mechanism
 # exposing values to Python.
 
-require !skip_cplus_tests
+require !skip_cplus_tests !skip_python_tests
 
 standard_testfile .cc
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
@@ -31,9 +31,6 @@  gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 proc test_template_arg {exefile type} {
     global testfile srcdir subdir srcfile
     if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" \
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index d8fa2e6f1a2..0806f8995c1 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -21,6 +21,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
@@ -29,9 +31,6 @@  if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
 
 clean_restart ${binfile}
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 runto_main
 
 gdb_test "break after_mc_barrier" \
diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp
index abf95e5c486..37e29294805 100644
--- a/gdb/testsuite/gdb.python/py-typeprint.exp
+++ b/gdb/testsuite/gdb.python/py-typeprint.exp
@@ -13,7 +13,7 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require !skip_cplus_tests
+require !skip_cplus_tests !skip_python_tests
 
 load_lib gdb-python.exp
 load_lib cp-support.exp
@@ -24,8 +24,6 @@  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-if { [skip_python_tests] } { continue }
-
 set remote_python_file [gdb_remote_download host \
 			    ${srcdir}/${subdir}/${testfile}.py]
 
diff --git a/gdb/testsuite/gdb.python/py-unwind-inline.exp b/gdb/testsuite/gdb.python/py-unwind-inline.exp
index 964d90a75f2..c0dc7f2f49b 100644
--- a/gdb/testsuite/gdb.python/py-unwind-inline.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-inline.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
@@ -25,9 +27,6 @@  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # The following tests require execution.
 if {![runto_main]} {
     return 0
diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.exp b/gdb/testsuite/gdb.python/py-unwind-maint.exp
index f0506691ec2..3fcbe4f6054 100644
--- a/gdb/testsuite/gdb.python/py-unwind-maint.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.exp
@@ -18,15 +18,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.python/py-unwind-user-regs.exp b/gdb/testsuite/gdb.python/py-unwind-user-regs.exp
index c62d4f0bde8..1598f865699 100644
--- a/gdb/testsuite/gdb.python/py-unwind-user-regs.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-user-regs.exp
@@ -38,15 +38,14 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index 1810214082a..2d279bf71b1 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 # Stack protection can make the stack look a bit different, breaking the
@@ -29,9 +31,6 @@  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug $fla
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 # This test runs on a specific platform.
 if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { continue }
 
diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp
index f62c1df4aa5..4085a87440e 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-value-cc.exp
@@ -16,7 +16,7 @@ 
 # This file is part of the GDB testsuite.  It tests the mechanism
 # exposing values to Python.
 
-require !skip_cplus_tests
+require !skip_cplus_tests !skip_python_tests
 
 standard_testfile .cc
 
@@ -24,9 +24,6 @@  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index a4964e11dd2..8ab188c7ea5 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 standard_testfile
 
 set has_argv0 [gdb_has_argv0]
@@ -634,9 +636,6 @@  if { [build_inferior "${binfile}" "c"] < 0 } {
 # Start with a fresh gdb.
 clean_restart ${binfile}
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 test_history_count
 test_value_creation
 test_value_reinit
diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp
index 8db5c39080b..6a9e5f22dc1 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.exp
+++ b/gdb/testsuite/gdb.python/py-xmethods.exp
@@ -18,7 +18,7 @@ 
 
 load_lib gdb-python.exp
 
-require !skip_cplus_tests
+require !skip_cplus_tests !skip_python_tests
 
 standard_testfile py-xmethods.cc
 
@@ -26,12 +26,6 @@  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } {
-    untested "skipping Python tests"
-    return
-}
-
 if ![runto_main] {
    return -1
 }
diff --git a/gdb/testsuite/gdb.python/tui-window-names.exp b/gdb/testsuite/gdb.python/tui-window-names.exp
index 9fcd8649117..48f3c6b07cd 100644
--- a/gdb/testsuite/gdb.python/tui-window-names.exp
+++ b/gdb/testsuite/gdb.python/tui-window-names.exp
@@ -18,6 +18,8 @@ 
 
 load_lib gdb-python.exp
 
+require !skip_python_tests
+
 tuiterm_env
 
 clean_restart
@@ -26,11 +28,6 @@  if {[skip_tui_tests]} {
     return
 }
 
-if { [skip_python_tests] } {
-    untested "skipping Python tests"
-    return
-}
-
 # Define a function we can use as a window constructor.  If this ever
 # gets called we'll throw an error, but that's OK, this test doesn't
 # actually try to create any windows.
diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp
index 1dd8e373c24..2f0415557bd 100644
--- a/gdb/testsuite/gdb.python/tui-window.exp
+++ b/gdb/testsuite/gdb.python/tui-window.exp
@@ -16,6 +16,7 @@ 
 # Test a TUI window implemented in Python.
 
 load_lib gdb-python.exp
+require !skip_python_tests
 tuiterm_env
 
 # This test doesn't care about the inferior.
@@ -32,9 +33,6 @@  if {[skip_tui_tests]} {
 
 Term::clean_restart 24 80 $testfile
 
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
 set remote_python_file [gdb_remote_download host \
 			    ${srcdir}/${subdir}/${testfile}.py]
 gdb_test_no_output "source ${remote_python_file}" \
diff --git a/gdb/testsuite/gdb.rust/pp.exp b/gdb/testsuite/gdb.rust/pp.exp
index a456afc1b35..d23463e89dd 100644
--- a/gdb/testsuite/gdb.rust/pp.exp
+++ b/gdb/testsuite/gdb.rust/pp.exp
@@ -17,15 +17,13 @@ 
 
 load_lib gdb-python.exp
 load_lib rust-support.exp
-require !skip_rust_tests
+require !skip_rust_tests !skip_python_tests
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
     return -1
 }
 
-if { [skip_python_tests] } { return }
-
 set remote_python_file [gdb_remote_download host \
 			    ${srcdir}/${subdir}/${testfile}.py]
 gdb_test_no_output "source ${remote_python_file}" "load python file"
diff --git a/gdb/testsuite/gdb.server/server-kill-python.exp b/gdb/testsuite/gdb.server/server-kill-python.exp
index 1eb9e2e51c5..4ef70daaf90 100644
--- a/gdb/testsuite/gdb.server/server-kill-python.exp
+++ b/gdb/testsuite/gdb.server/server-kill-python.exp
@@ -23,15 +23,7 @@  load_lib gdbserver-support.exp
 
 standard_testfile multi-ui-errors.c
 
-require !skip_gdbserver_tests
-
-# Gdb needs to be running for skip_python_tests, but exit once we're done,
-# we'll start a custom gdb after this.
-clean_restart
-if { [skip_python_tests] } {
-    return 0
-}
-gdb_exit
+require !skip_gdbserver_tests !skip_python_tests
 
 if {[build_executable "failed to prepare" ${testfile} \
 	 ${srcfile}] == -1} {
diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp
index d2c55db0cac..78ce9879b42 100644
--- a/gdb/testsuite/gdb.threads/tls.exp
+++ b/gdb/testsuite/gdb.threads/tls.exp
@@ -72,7 +72,7 @@  proc check_thread_local {number} {
 	    "= $expected_value" \
 	    "${number} thread local storage"
 
-    if {!$::has_python_support} {
+    if {![skip_python_tests]} {
 	gdb_test_no_output \
 	    "python sym = gdb.lookup_symbol('a_thread_local')\[0\]" \
 	    "${number} look up a_thread_local symbol"
@@ -155,9 +155,6 @@  proc check_thread_stack {number spin_threads spin_threads_level} {
 
 clean_restart ${binfile}
 
-# Set this to avoid calling skip_python_tests repeatedly.
-set has_python_support [skip_python_tests]
-
 gdb_test_multiple "print a_thread_local" "" {
     -re -wrap "Cannot find thread-local variables on this target" {
 	kfail "gdb/25807" $gdb_test_name