summaryrefslogtreecommitdiff
path: root/testing/cffi0
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2016-12-22 15:04:02 +0100
committerArmin Rigo <arigo@tunes.org>2016-12-22 15:04:02 +0100
commitbf004e02c38c64180befc0442b36760f3dda908c (patch)
tree03483716493d7a32f46f1987ec991ff0e5377cdf /testing/cffi0
parenta5e7007477a7f56390d8989907c034ef55dfcc42 (diff)
downloadcffi-bf004e02c38c64180befc0442b36760f3dda908c.tar.gz
Detect packed structs. Improve error messages and test them.
Diffstat (limited to 'testing/cffi0')
-rw-r--r--testing/cffi0/test_verify.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py
index 5308e1d..e600908 100644
--- a/testing/cffi0/test_verify.py
+++ b/testing/cffi0/test_verify.py
@@ -1075,9 +1075,13 @@ def test_autofilled_struct_as_argument_dynamic():
int (*foo)(struct foo_s s) = &foo1;
""")
e = py.test.raises(NotImplementedError, lib.foo, "?")
- msg = ("ctype 'struct foo_s' not supported as argument (it is a struct "
- 'declared with "...;", but the C calling convention may depend '
- 'on the missing fields)')
+ msg = ("ctype 'struct foo_s' not supported as argument. It is a struct "
+ 'declared with "...;", but the C calling convention may depend on '
+ "the missing fields; or, it contains anonymous struct/unions. "
+ "Such structs are only supported as argument "
+ "if the function is 'API mode' and non-variadic (i.e. declared "
+ "inside ffibuilder.cdef()+ffibuilder.set_source() and not taking "
+ "a final '...' argument)")
assert str(e.value) == msg
def test_func_returns_struct():
@@ -2146,14 +2150,23 @@ def test_consider_not_implemented_function_type():
# assert did not crash so far
e = py.test.raises(NotImplementedError, fooptr, ffi.new("Data *"))
assert str(e.value) == (
- "ctype 'Data' (size 4) not supported as argument")
+ "ctype 'Data' not supported as argument by libffi. Unions are only "
+ "supported as argument if the function is 'API mode' and "
+ "non-variadic (i.e. declared inside ffibuilder.cdef()+"
+ "ffibuilder.set_source() and not taking a final '...' argument)")
e = py.test.raises(NotImplementedError, bazptr)
assert str(e.value) == (
- "ctype 'Data' (size 4) not supported as return value")
+ "ctype 'Data' not supported as return value by libffi. Unions are "
+ "only supported as return value if the function is 'API mode' and "
+ "non-variadic (i.e. declared inside ffibuilder.cdef()+"
+ "ffibuilder.set_source() and not taking a final '...' argument)")
e = py.test.raises(NotImplementedError, barptr)
assert str(e.value) == (
- "ctype 'MyStr' not supported as return value "
- "(it is a struct with bit fields)")
+ "ctype 'MyStr' not supported as return value. It is a struct with "
+ "bit fields, which libffi does not support. Such structs are only "
+ "supported as return value if the function is 'API mode' and non-"
+ "variadic (i.e. declared inside ffibuilder.cdef()+ffibuilder."
+ "set_source() and not taking a final '...' argument)")
def test_verify_extra_arguments():
ffi = FFI()