summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2017-02-07 16:28:20 +0100
committerArmin Rigo <arigo@tunes.org>2017-02-07 16:28:20 +0100
commitf5d76e1b0d614520e6c9b79e995b14c177dc9575 (patch)
tree8d9b918c6f6419296292a876c52ffcfa27520804 /testing
parent0e4e34033dcbe9d4ff4070e5754fac392d79fff3 (diff)
downloadcffi-f5d76e1b0d614520e6c9b79e995b14c177dc9575.tar.gz
ffi.addressof(lib, "name") now also works in in-line mode
Diffstat (limited to 'testing')
-rw-r--r--testing/cffi0/test_ownlib.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/cffi0/test_ownlib.py b/testing/cffi0/test_ownlib.py
index afda543..0572a9a 100644
--- a/testing/cffi0/test_ownlib.py
+++ b/testing/cffi0/test_ownlib.py
@@ -282,3 +282,21 @@ class TestOwnLib(object):
assert ret.right == ownlib.right
assert ret.top == ownlib.top
assert ret.bottom == ownlib.bottom
+
+ def test_addressof_lib(self):
+ if self.module is None:
+ py.test.skip("fix the auto-generation of the tiny test lib")
+ if self.Backend is CTypesBackend:
+ py.test.skip("not implemented with the ctypes backend")
+ ffi = FFI(backend=self.Backend())
+ ffi.cdef("long left; int test_getting_errno(void);")
+ lib = ffi.dlopen(self.module)
+ lib.left = 123456
+ p = ffi.addressof(lib, "left")
+ assert ffi.typeof(p) == ffi.typeof("long *")
+ assert p[0] == 123456
+ p[0] += 1
+ assert lib.left == 123457
+ pfn = ffi.addressof(lib, "test_getting_errno")
+ assert ffi.typeof(pfn) == ffi.typeof("int(*)(void)")
+ assert pfn == lib.test_getting_errno