[Python-checkins] r43666 - python/trunk/Lib/ctypes/test/test_loading.py (original) (raw)

thomas.heller python-checkins at python.org
Wed Apr 5 19:36:46 CEST 2006


Author: thomas.heller Date: Wed Apr 5 19:36:45 2006 New Revision: 43666

Modified: python/trunk/Lib/ctypes/test/test_loading.py Log: Use 'ldd' to find the libc library to load. Based on an idea from Matthias Klose.

Modified: python/trunk/Lib/ctypes/test/test_loading.py

--- python/trunk/Lib/ctypes/test/test_loading.py (original) +++ python/trunk/Lib/ctypes/test/test_loading.py Wed Apr 5 19:36:45 2006 @@ -2,59 +2,59 @@ import sys, unittest 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: + if sys.platform == "openbsd3": + libc_name = line.split()[4] + else: + libc_name = line.split()[2] +## print "libc_name is", libc_name + break + 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)



More information about the Python-checkins mailing list