mirror of
https://github.com/python/cpython.git
synced 2025-10-18 04:38:07 +00:00
bpo-43795: Add a test for Stable ABI symbol availability using ctypes (GH-26354)
This is a cross-platform check that the symbols are actually exported in the ABI, not e.g. hidden in a macro. Caveat: PyModule_Create2 & PyModule_FromDefAndSpec2 are skipped. These aren't exported on some of our buildbots. This is a bug (bpo-44133). This test now makes sure all the others don't regress.
This commit is contained in:
parent
843b890334
commit
276468dddb
2 changed files with 881 additions and 0 deletions
|
@ -258,6 +258,44 @@ def gen_doc_annotations(manifest, args, outfile):
|
|||
'added': item.added,
|
||||
'ifdef_note': ifdef_note})
|
||||
|
||||
@generator("ctypes_test", 'Lib/test/test_stable_abi_ctypes.py')
|
||||
def gen_ctypes_test(manifest, args, outfile):
|
||||
"""Generate/check the ctypes-based test for exported symbols"""
|
||||
write = partial(print, file=outfile)
|
||||
write(textwrap.dedent('''
|
||||
# Generated by Tools/scripts/stable_abi.py
|
||||
|
||||
"""Test that all symbols of the Stable ABI are accessible using ctypes
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from test.support.import_helper import import_module
|
||||
|
||||
ctypes_test = import_module('ctypes')
|
||||
|
||||
class TestStableABIAvailability(unittest.TestCase):
|
||||
def test_available_symbols(self):
|
||||
for symbol_name in SYMBOL_NAMES:
|
||||
with self.subTest(symbol_name):
|
||||
ctypes_test.pythonapi[symbol_name]
|
||||
|
||||
SYMBOL_NAMES = (
|
||||
'''))
|
||||
items = manifest.select(
|
||||
{'function', 'data'},
|
||||
include_abi_only=True,
|
||||
ifdef=set())
|
||||
for item in items:
|
||||
if item.name in (
|
||||
# Some symbols aren't exported on all platforms.
|
||||
# This is a bug: https://bugs.python.org/issue44133
|
||||
'PyModule_Create2', 'PyModule_FromDefAndSpec2',
|
||||
):
|
||||
continue
|
||||
write(f' "{item.name}",')
|
||||
write(")")
|
||||
|
||||
|
||||
def generate_or_check(manifest, args, path, func):
|
||||
"""Generate/check a file with a single generator
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue