Issue #15043: skip test_gdb if the custom hooks can't be loaded
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index aea7c0c..a02f5c7 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -32,6 +32,15 @@
 if gdbpy_version == b'':
     raise unittest.SkipTest("gdb not built with embedded python support")
 
+# Verify that "gdb" can load our custom hooks
+p = subprocess.Popen(["gdb", "--batch", cmd,
+                      "--args", sys.executable],
+                     stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+__, gdbpy_errors = p.communicate()
+if b"auto-loading has been declined" in gdbpy_errors:
+    msg = "gdb security settings prevent use of custom hooks: %s"
+    raise unittest.SkipTest(msg % gdbpy_errors)
+
 def gdb_has_frame_select():
     # Does this build of gdb have gdb.Frame.select ?
     cmd = "--eval-command=python print(dir(gdb.Frame))"