Skip to content

Commit 13c9fa3

Browse files
authored
gh-121938: ctypes: Skip test of _pack_-ed struct with c_int64 on x86 (GH-125877)
The current auto-generated tests don't cover this; it's instead tested manually.
1 parent 9c01db4 commit 13c9fa3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_ctypes/test_generated_structs.py

+14
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ class Packed3(Structure):
135135

136136
@register()
137137
class Packed4(Structure):
138+
def _maybe_skip():
139+
# `_pack_` enables MSVC-style packing, but keeps platform-specific
140+
# alignments.
141+
# The C code we generate for GCC/clang currently uses
142+
# `__attribute__((ms_struct))`, which activates MSVC layout *and*
143+
# alignments, that is, sizeof(basic type) == alignment(basic type).
144+
# On a Pentium, int64 is 32-bit aligned, so the two won't match.
145+
# The expected behavior is instead tested in
146+
# StructureTestCase.test_packed, over in test_structures.py.
147+
if sizeof(c_int64) != alignment(c_int64):
148+
raise unittest.SkipTest('cannot test on this platform')
149+
138150
_fields_ = [('a', c_int8), ('b', c_int64)]
139151
_pack_ = 8
140152

@@ -436,6 +448,8 @@ def test_generated_data(self):
436448
"""
437449
for name, cls in TESTCASES.items():
438450
with self.subTest(name=name):
451+
if _maybe_skip := getattr(cls, '_maybe_skip', None):
452+
_maybe_skip()
439453
expected = iter(_ctypes_test.get_generated_test_data(name))
440454
expected_name = next(expected)
441455
if expected_name is None:

0 commit comments

Comments
 (0)