Skip to content

Commit

Permalink
randomize modulename
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Oct 11, 2024
1 parent 933fd2c commit f2f0913
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions testing/cffi0/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2174,22 +2174,23 @@ def test_verify_dlopen_flags():
ffi1 = FFI()
ffi1.cdef("extern int foo_verify_dlopen_flags;")

modulename = "_cffi_test_verify_dlopen_flags_%d" % random.randint(0, 1000000000)
lib1 = ffi1.verify("int foo_verify_dlopen_flags;",
flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY,
modulename="_cffi_test_verify_dlopen_flags")
lib2 = get_second_lib()
modulename=modulename)
lib2 = get_second_lib(modulename)

lib1.foo_verify_dlopen_flags = 42
assert lib2.foo_verify_dlopen_flags == 42
lib2.foo_verify_dlopen_flags += 1
assert lib1.foo_verify_dlopen_flags == 43

def get_second_lib():
def get_second_lib(modulename):
ffi2 = FFI()
ffi2.cdef("extern int foo_verify_dlopen_flags;")
lib2 = ffi2.verify("int foo_verify_dlopen_flags;",
flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY,
modulename="_cffi_test_verify_dlopen_flags")
modulename=modulename)
return lib2

def test_consider_not_implemented_function_type():
Expand Down Expand Up @@ -2257,7 +2258,7 @@ def test_implicit_unicode_on_windows():

def test_use_local_dir():
ffi = FFI()
lib = ffi.verify("", modulename="test_use_local_dir")
lib = ffi.verify("", modulename="_cffi_test_use_local_dir")
this_dir = os.path.dirname(__file__)
pycache_files = os.listdir(os.path.join(this_dir, '__pycache__'))
assert any('test_use_local_dir' in s for s in pycache_files)
Expand Down
3 changes: 2 additions & 1 deletion testing/cffi0/test_vgen2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

# This test file runs normally after test_vgen. We only clean up the .c
# sources, to check that it also works when we have only the .so. The
# tests should run much faster than test_vgen.
# tests used to run much faster than test_vgen, but since we randomize
# the module names, it needs to recompile everything.

def setup_module():
cffi.verifier.cleanup_tmpdir(keep_so=True)
Expand Down

0 comments on commit f2f0913

Please sign in to comment.