cffi_tests.cffi1.test_verify1:test_varargs_struct
def test_varargs_struct():
ffi = FFI()
ffi.cdef("struct foo_s { char a; int b; }; int foo(int x, ...);")
lib = ffi.verify("""
struct foo_s {
char a; int b;
};
int foo(int x, ...) {
va_list vargs;
struct foo_s s;
va_start(vargs, x);
s = va_arg(vargs, struct foo_s);
va_end(vargs);
return s.a - s.b;
}
""")
s = ffi.new("struct foo_s *", [b'B', 1])
> assert lib.foo(50, s[0]) == ord('A')
E AssertionError: assert 0 == 65
E + where 0 = <cdata 'int(*)(int, ...)' 0x10c2d3f50>(50, <cdata 'struct foo_s' owning 8 bytes>)
E + where <cdata 'int(*)(int, ...)' 0x10c2d3f50> = <Lib object for 'verify235'>.foo
E + and 65 = ord('A')
../build/extra_tests/cffi_tests/cffi1/test_verify1.py:1031: AssertionError
builder: pypy-c-jit-macos-arm64 build #1295+
test: cffi_tests.cffi1.test_verify1:test_varargs_struct