Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-121938: ctypes: Skip test of _pack_-ed struct with c_int64 on x86 #125877

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Lib/test/test_ctypes/test_generated_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ class Packed3(Structure):

@register()
class Packed4(Structure):
def _maybe_skip():
# `_pack_` enables MSVC-style packing, but keeps platform-specific
# alignments.
# The C code we generate for GCC/clang currently uses
# `__attribute__((ms_struct))`, which activates MSVC layout *and*
# alignments, that is, sizeof(basic type) == alignment(basic type).
# On a Pentium, int64 is 32-bit aligned, so the two won't match.
# The expected behavior is instead tested in
# StructureTestCase.test_packed, over in test_structures.py.
if sizeof(c_int64) != alignment(c_int64):
raise unittest.SkipTest('cannot test on this platform')

_fields_ = [('a', c_int8), ('b', c_int64)]
_pack_ = 8

Expand Down Expand Up @@ -436,6 +448,8 @@ def test_generated_data(self):
"""
for name, cls in TESTCASES.items():
with self.subTest(name=name):
if _maybe_skip := getattr(cls, '_maybe_skip', None):
_maybe_skip()
expected = iter(_ctypes_test.get_generated_test_data(name))
expected_name = next(expected)
if expected_name is None:
Expand Down
Loading