diff options
author | Armin Rigo <arigo@tunes.org> | 2020-01-05 13:46:20 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-01-05 13:46:20 +0100 |
commit | 263cff26c5edcb9e77990078faec25431303c107 (patch) | |
tree | a38e038b27165ef09c7298912ddf758d0374b3c8 /testing/cffi0 | |
parent | 0e3aa45f0edb076fe282461509d8a19effd3d8f5 (diff) | |
download | cffi-263cff26c5edcb9e77990078faec25431303c107.tar.gz |
Issue #437
Support ffi.dlopen(<void* cdata>). See updated documentation.
Diffstat (limited to 'testing/cffi0')
-rw-r--r-- | testing/cffi0/test_ownlib.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/testing/cffi0/test_ownlib.py b/testing/cffi0/test_ownlib.py index 9295163..990f259 100644 --- a/testing/cffi0/test_ownlib.py +++ b/testing/cffi0/test_ownlib.py @@ -371,3 +371,29 @@ class TestOwnLib(object): assert s.top == 22 assert s.right == 33 assert s.bottom == 44 + + def test_dlopen_handle(self): + if self.module is None: + py.test.skip("fix the auto-generation of the tiny test lib") + if sys.platform == 'win32': + py.test.skip("uses 'dl' explicitly") + if self.__class__.Backend is CTypesBackend: + py.test.skip("not for the ctypes backend") + backend = self.Backend() + ffi1 = FFI(backend=backend) + ffi1.cdef("""void *dlopen(const char *filename, int flags); + int dlclose(void *handle);""") + lib1 = ffi1.dlopen('dl') + handle = lib1.dlopen(self.module.encode(sys.getfilesystemencoding()), + backend.RTLD_LAZY) + assert ffi1.typeof(handle) == ffi1.typeof("void *") + assert handle + + ffi = FFI(backend=backend) + ffi.cdef("""unsigned short foo_2bytes(unsigned short a);""") + lib = ffi.dlopen(handle) + x = lib.foo_2bytes(1000) + assert x == 1042 + + err = lib1.dlclose(handle) + assert err == 0 |