Home - Summaries: (main) : (py3.11) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

cffi_tests.cffi0.test_ffi_backend.TestBitfield:test_bitfield_zero

self = <extra_tests.cffi_tests.cffi0.test_ffi_backend.TestBitfield object at 0x0000000110bfe9f8>

    @pytest.mark.skipif(
        "not (sys.platform == 'darwin' and platform.machine() == 'arm64')"
        " and "
        "platform.machine().startswith(('arm', 'aarch64'))")
    def test_bitfield_zero(self):
        L = FFI().alignof("long long")
>       self.check("char y; int :0;", 0, 1, 4)

../build/extra_tests/cffi_tests/cffi0/test_ffi_backend.py:307: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <extra_tests.cffi_tests.cffi0.test_ffi_backend.TestBitfield object at 0x0000000110bfe9f8>
source = 'char y; int :0;', expected_ofs_y = 0, expected_align = 1
expected_size = 4

    def check(self, source, expected_ofs_y, expected_align, expected_size):
        # NOTE: 'expected_*' is the numbers expected from GCC.
        # The numbers expected from MSVC are not explicitly written
        # in this file, and will just be taken from the compiler.
        ffi = FFI()
        ffi.cdef("struct s1 { %s };" % source)
        ctype = ffi.typeof("struct s1")
        # verify the information with gcc
        ffi1 = FFI()
        ffi1.cdef("""
            static const int Gofs_y, Galign, Gsize;
            struct s1 *try_with_value(int fieldnum, long long value);
        """)
        fnames = [name for name, cfield in ctype.fields
                       if name and cfield.bitsize > 0]
        setters = ['case %d: s.%s = value; break;' % iname
                   for iname in enumerate(fnames)]
        lib = ffi1.verify("""
            #include <string.h>
            struct s1 { %s };
            struct sa { char a; struct s1 b; };
            #define Gofs_y  offsetof(struct s1, y)
            #define Galign  offsetof(struct sa, b)
            #define Gsize   sizeof(struct s1)
            struct s1 *try_with_value(int fieldnum, long long value)
            {
                static struct s1 s;
                memset(&s, 0, sizeof(s));
                switch (fieldnum) { %s }
                return &s;
            }
        """ % (source, ' '.join(setters)))
        if sys.platform == 'win32':
            expected_ofs_y = lib.Gofs_y
            expected_align = lib.Galign
            expected_size  = lib.Gsize
        else:
            assert (lib.Gofs_y, lib.Galign, lib.Gsize) == (
                expected_ofs_y, expected_align, expected_size)
        # the real test follows
        assert ffi.offsetof("struct s1", "y") == expected_ofs_y
>       assert ffi.alignof("struct s1") == expected_align
E       AssertionError: assert 4 == 1
E        +  where 4 = <bound method FFI.alignof of <cffi.api.FFI object at 0x0000000110bfea30>>('struct s1')
E        +    where <bound method FFI.alignof of <cffi.api.FFI object at 0x0000000110bfea30>> = <cffi.api.FFI object at 0x0000000110bfea30>.alignof

../build/extra_tests/cffi_tests/cffi0/test_ffi_backend.py:224: AssertionError
builder: pypy-c-jit-macos-arm64 build #1308+
test: cffi_tests.cffi0.test_ffi_backend.TestBitfield:test_bitfield_zero