[pypy-svn] r45301 - in pypy/dist/pypy/rpython/module: . test

fijal at codespeak.net fijal at codespeak.net
Tue Jul 24 13:54:40 CEST 2007


Author: fijal
Date: Tue Jul 24 13:54:39 2007
New Revision: 45301

Modified:
   pypy/dist/pypy/rpython/module/ll_os.py
   pypy/dist/pypy/rpython/module/test/test_posix.py
Log:
Make it truly portable (I hope). Cannot run it on top of ll2ctypes yet


Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py	(original)
+++ pypy/dist/pypy/rpython/module/ll_os.py	Tue Jul 24 13:54:39 2007
@@ -16,6 +16,7 @@
 from pypy.annotation.model import SomeString, SomeInteger, s_ImpossibleValue, \
     s_None
 from pypy.rpython.lltypesystem import rffi
+from pypy.rpython.lltypesystem.rffi import platform
 from pypy.rpython.lltypesystem import lltype
 
 # a simple, yet usefull factory
@@ -126,12 +127,18 @@
 # ------------------------------- os.uname ------------------------------
 
 if hasattr(os, 'uname'):
-    UTSNAMEP = rffi.CStruct('utsname', ('sysname', rffi.CCHARP),
-                            ('nodename', rffi.CCHARP),
-                            ('release', rffi.CCHARP),
-                            ('version', rffi.CCHARP),
-                            ('machine', rffi.CCHARP),
-                            ('stuff', rffi.CCHARP))
+    lgt = platform.intdefined('_UTSNAME_LENGTH', includes=['sys/utsname.h'])
+    UTCHARP = lltype.FixedSizeArray(lltype.Char, lgt)
+    fields = [('sysname', UTCHARP),
+              ('nodename', UTCHARP),
+              ('release', UTCHARP),
+              ('version', UTCHARP),
+              ('machine', UTCHARP)]
+    # heh, that's a valid question whether asking for defines NOW
+    # makes any sense
+    if platform.defined('_GNU_SOURCE'):
+        fields.append('domainname', UTCHARP)
+    UTSNAMEP = rffi.CStruct('utsname', *fields)
     
     os_uname = rffi.llexternal('uname', [UTSNAMEP], rffi.INT,
                                includes=['sys/utsname.h'])

Modified: pypy/dist/pypy/rpython/module/test/test_posix.py
==============================================================================
--- pypy/dist/pypy/rpython/module/test/test_posix.py	(original)
+++ pypy/dist/pypy/rpython/module/test/test_posix.py	Tue Jul 24 13:54:39 2007
@@ -110,16 +110,15 @@
     del BaseTestPosix.test_ftruncate
 
 class TestLLtype(BaseTestPosix, LLRtypeMixin):
-    # XXX segfaulting while run on top of llinterp
-    # XXX but should be there for backends reusing it
     if hasattr(os, 'uname'):
         def test_os_uname(self):
-            from pypy.translator.c.test.test_genc import compile
+            py.test.skip("Cannot do it (yet) because ll2ctypes cannot handle str -> fixedsizearray")
+            #from pypy.translator.c.test.test_genc import compile
             for num in range(5):
                 def fun():
                     return os.uname()[num]
-                fn = compile(fun, [])
-                assert fn() == os.uname()[num]
+                #fn = compile(fun, [])
+                assert self.interpret(fun, []) == os.uname()[num]
 
 class TestOOtype(BaseTestPosix, OORtypeMixin):
     pass



More information about the Pypy-commit mailing list