[pypy-svn] r45710 - in pypy/branch/pypy-more-rtti-inprogress/module/posix: . test

arigo at codespeak.net arigo at codespeak.net
Thu Aug 16 13:09:55 CEST 2007


Author: arigo
Date: Thu Aug 16 13:09:54 2007
New Revision: 45710

Modified:
   pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py
   pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py
Log:
Some more large file support: os.ftruncate(), os.lseek().


Modified: pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/module/posix/interp_posix.py	Thu Aug 16 13:09:54 2007
@@ -1,4 +1,5 @@
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
+from pypy.rlib.rarithmetic import r_longlong
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.interpreter.error import OperationError, wrap_oserror
 from pypy.rpython.module.ll_os import RegisterOs
@@ -27,7 +28,7 @@
         raise wrap_oserror(space, e) 
     else: 
         return space.wrap(pos) 
-lseek.unwrap_spec = [ObjSpace, int, int, int]
+lseek.unwrap_spec = [ObjSpace, int, r_longlong, int]
 
 def isatty(space, fd):
     """Return True if 'fd' is an open file descriptor connected to the
@@ -75,7 +76,7 @@
         os.ftruncate(fd, length)
     except OSError, e: 
         raise wrap_oserror(space, e) 
-ftruncate.unwrap_spec = [ObjSpace, int, int]
+ftruncate.unwrap_spec = [ObjSpace, int, r_longlong]
 
 # ____________________________________________________________
 

Modified: pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py	Thu Aug 16 13:09:54 2007
@@ -11,6 +11,7 @@
     mod.space = gettestobjspace(usemodules=['posix'])
     mod.path = udir.join('posixtestfile.txt') 
     mod.path.write("this is a test")
+    mod.path2 = udir.join('posixtestlargefile')
     pdir = udir.ensure('posixtestdir', dir=True)
     pdir.join('file1').write("test1")
     os.chmod(str(pdir.join('file1')), 0600)
@@ -23,6 +24,7 @@
         cls.space = space 
         cls.w_posix = space.appexec([], "(): import %s as m ; return m" % os.name)
         cls.w_path = space.wrap(str(path))
+        cls.w_path2 = space.wrap(str(path2))
         cls.w_pdir = space.wrap(str(pdir))
         cls.w_getuid = space.wrap(os.getuid())
         cls.w_geteuid = space.wrap(os.geteuid())
@@ -258,6 +260,23 @@
         os.getuid() == self.getuid
         os.geteuid() == self.geteuid
 
+    def test_largefile(self):
+        os = self.posix
+        if os.__name__ == 'nt':
+            skip("no sparse files on Windows")
+        fd = os.open(self.path2, os.O_RDWR | os.O_CREAT, 0666)
+        os.ftruncate(fd, 10000000000L)
+        res = os.lseek(fd, 9900000000L, 0)
+        assert res == 9900000000L
+        res = os.lseek(fd, -5000000000L, 1)
+        assert res == 4900000000L
+        res = os.lseek(fd, -5200000000L, 2)
+        assert res == 4800000000L
+        os.close(fd)
+
+        st = os.stat(self.path2)
+        assert st.st_size == 10000000000L
+
 class AppTestEnvironment(object):
     def setup_class(cls): 
         cls.space = space 



More information about the Pypy-commit mailing list