def test_verify_dlopen_flags():
if not hasattr(sys, 'setdlopenflags'):
py.test.skip("requires sys.setdlopenflags()")
# Careful with RTLD_GLOBAL. If by chance the FFI is not deleted
# promptly, like on PyPy, then other tests may see the same
# exported symbols as well. So we must not export a simple name
# like 'foo'!
old = sys.getdlopenflags()
try:
ffi1 = FFI()
ffi1.cdef("int foo_verify_dlopen_flags_1;")
sys.setdlopenflags(ffi1.RTLD_GLOBAL | ffi1.RTLD_NOW)
lib1 = ffi1.verify("int foo_verify_dlopen_flags_1;")
finally:
sys.setdlopenflags(old)
ffi2 = FFI()
ffi2.cdef("int *getptr(void);")
lib2 = ffi2.verify("""
extern int foo_verify_dlopen_flags_1;
static int *getptr(void) { return &foo_verify_dlopen_flags_1; }
""")
p = lib2.getptr()
assert ffi1.addressof(lib1, 'foo_verify_dlopen_flags_1') == p
评论列表
文章目录