[ctypes-commit] ctypes/ctypes/test test_loading.py,1.10,1.11
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-04-05 14:05:39
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15972/ctypes/test Modified Files: test_loading.py Log Message: Use ldd to find the libc library. Suggested by Matthias Klose. Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_loading.py 5 Apr 2006 12:37:45 -0000 1.10 --- test_loading.py 5 Apr 2006 14:05:33 -0000 1.11 *************** *** 3,31 **** import os, StringIO class LoaderTest(unittest.TestCase): unknowndll = "xxrandomnamexx" ! def test_load(self): ! if os.name == "nt": ! name = "msvcrt" ! elif os.name == "ce": ! name = "coredll" ! elif sys.platform == "darwin": ! name = "libc.dylib" ! elif sys.platform.startswith("freebsd"): ! name = "libc.so" ! elif sys.platform in ("sunos5", "osf1V5"): ! name = "libc.so" ! elif sys.platform.startswith("netbsd") or sys.platform.startswith("openbsd"): ! name = "libc.so" ! else: ! name = "libc.so.6" ! ## print (sys.platform, os.name) ! try: ! cdll.load(name) ! except Exception, details: ! self.fail((str(details), name, (os.name, sys.platform))) ! self.assertRaises(OSError, cdll.load, self.unknowndll) def test_load_version(self): --- 3,33 ---- import os, StringIO + libc_name = None + if os.name == "nt": + libc_name = "msvcrt" + elif os.name == "ce": + libc_name = "coredll" + elif sys.platform == "darwin": + libc_name = "libc.dylib" + elif sys.platform == "cygwin": + libc_name = "cygwin1.dll" + else: + for line in os.popen("ldd %s" % sys.executable): + if "libc.so" in line: + libc_name = line.split()[2] + print "libc_name is", libc_name + break + class LoaderTest(unittest.TestCase): unknowndll = "xxrandomnamexx" ! if libc_name is not None: ! def test_load(self): ! cdll.load(libc_name) ! cdll.load(os.path.basename(libc_name)) ! self.assertRaises(OSError, cdll.load, self.unknowndll) ! else: ! print "Warning: libc not found" def test_load_version(self): |