MCPcopy Index your code
hub / github.com/RustPython/RustPython / test

Function test

Lib/ctypes/util.py:490–535  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

488# test code
489
490def test():
491 from ctypes import cdll
492 if os.name == "nt":
493 print(cdll.msvcrt)
494 print(cdll.load("msvcrt"))
495 print(find_library("msvcrt"))
496
497 if os.name == "posix":
498 # find and load_version
499 print(find_library("m"))
500 print(find_library("c"))
501 print(find_library("bz2"))
502
503 # load
504 if sys.platform == "darwin":
505 print(cdll.LoadLibrary("libm.dylib"))
506 print(cdll.LoadLibrary("libcrypto.dylib"))
507 print(cdll.LoadLibrary("libSystem.dylib"))
508 print(cdll.LoadLibrary("System.framework/System"))
509 # issue-26439 - fix broken test call for AIX
510 elif sys.platform.startswith("aix"):
511 from ctypes import CDLL
512 if sys.maxsize < 2**32:
513 print(f"Using CDLL(name, os.RTLD_MEMBER): {CDLL('libc.a(shr.o)', os.RTLD_MEMBER)}")
514 print(f"Using cdll.LoadLibrary(): {cdll.LoadLibrary('libc.a(shr.o)')}")
515 # librpm.so is only available as 32-bit shared library
516 print(find_library("rpm"))
517 print(cdll.LoadLibrary("librpm.so"))
518 else:
519 print(f"Using CDLL(name, os.RTLD_MEMBER): {CDLL('libc.a(shr_64.o)', os.RTLD_MEMBER)}")
520 print(f"Using cdll.LoadLibrary(): {cdll.LoadLibrary('libc.a(shr_64.o)')}")
521 print(f"crypt\t:: {find_library('crypt')}")
522 print(f"crypt\t:: {cdll.LoadLibrary(find_library('crypt'))}")
523 print(f"crypto\t:: {find_library('crypto')}")
524 print(f"crypto\t:: {cdll.LoadLibrary(find_library('crypto'))}")
525 else:
526 print(cdll.LoadLibrary("libm.so"))
527 print(cdll.LoadLibrary("libcrypt.so"))
528 print(find_library("crypt"))
529
530 try:
531 dllist
532 except NameError:
533 print('dllist() not available')
534 else:
535 print(dllist())
536
537if __name__ == "__main__":
538 test()

Callers 1

util.pyFile · 0.70

Calls 7

find_libraryFunction · 0.90
CDLLClass · 0.90
dllistFunction · 0.85
printFunction · 0.50
loadMethod · 0.45
LoadLibraryMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected