예제 #1
0
def test_largefile():
    if not hasattr(os, 'ftruncate'):
        py.test.skip("this os has no ftruncate :-(")
    from pypy.module.posix.test.test_posix2 import need_sparse_files
    need_sparse_files()
    filename = str(udir.join('test_largefile'))
    r4800000000  = r_longlong(4800000000L)
    r4900000000  = r_longlong(4900000000L)
    r5000000000  = r_longlong(5000000000L)
    r5200000000  = r_longlong(5200000000L)
    r9900000000  = r_longlong(9900000000L)
    r10000000000 = r_longlong(10000000000L)
    def does_stuff():
        fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0666)
        os.ftruncate(fd, r10000000000)
        res = os.lseek(fd, r9900000000, 0)
        assert res == r9900000000
        res = os.lseek(fd, -r5000000000, 1)
        assert res == r4900000000
        res = os.lseek(fd, -r5200000000, 2)
        assert res == r4800000000
        os.close(fd)
        st = os.stat(filename)
        assert st.st_size == r10000000000
    does_stuff()
    os.unlink(filename)
    f1 = compile(does_stuff, [])
    f1()
    os.unlink(filename)
예제 #2
0
    def test_standalone_large_files(self):
        from pypy.module.posix.test.test_posix2 import need_sparse_files
        need_sparse_files()
        filename = str(udir.join('test_standalone_largefile'))
        r4800000000 = r_longlong(4800000000L)

        def entry_point(argv):
            fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0644)
            os.lseek(fd, r4800000000, 0)
            os.write(fd, "$")
            newpos = os.lseek(fd, 0, 1)
            if newpos == r4800000000 + 1:
                print "OK"
            else:
                print "BAD POS"
            os.close(fd)
            return 0

        t = TranslationContext(self.config)
        t.buildannotator().build_types(entry_point, [s_list_of_strings])
        t.buildrtyper().specialize()
        cbuilder = CStandaloneBuilder(t, entry_point, t.config)
        cbuilder.generate_source()
        cbuilder.compile()
        data = cbuilder.cmdexec('hi there')
        assert data.strip() == "OK"
예제 #3
0
 def test_standalone_large_files(self):
     from pypy.module.posix.test.test_posix2 import need_sparse_files
     need_sparse_files()
     filename = str(udir.join('test_standalone_largefile'))
     r4800000000 = r_longlong(4800000000L)
     def entry_point(argv):
         fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0644)
         os.lseek(fd, r4800000000, 0)
         os.write(fd, "$")
         newpos = os.lseek(fd, 0, 1)
         if newpos == r4800000000 + 1:
             print "OK"
         else:
             print "BAD POS"
         os.close(fd)
         return 0
     t, cbuilder = self.compile(entry_point)
     data = cbuilder.cmdexec('hi there')
     assert data.strip() == "OK"
예제 #4
0
    def test_standalone_large_files(self):
        from pypy.module.posix.test.test_posix2 import need_sparse_files
        need_sparse_files()
        filename = str(udir.join('test_standalone_largefile'))
        r4800000000 = r_longlong(4800000000L)

        def entry_point(argv):
            fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0644)
            os.lseek(fd, r4800000000, 0)
            os.write(fd, "$")
            newpos = os.lseek(fd, 0, 1)
            if newpos == r4800000000 + 1:
                print "OK"
            else:
                print "BAD POS"
            os.close(fd)
            return 0

        t, cbuilder = self.compile(entry_point)
        data = cbuilder.cmdexec('hi there')
        assert data.strip() == "OK"
예제 #5
0
def test_standalone_large_files():
    from pypy.module.posix.test.test_posix2 import need_sparse_files
    need_sparse_files()
    filename = str(udir.join('test_standalone_largefile'))
    r4800000000 = r_longlong(4800000000L)
    def entry_point(argv):
        fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0644)
        os.lseek(fd, r4800000000, 0)
        os.write(fd, "$")
        newpos = os.lseek(fd, 0, 1)
        if newpos == r4800000000 + 1:
            print "OK"
        else:
            print "BAD POS"
        os.close(fd)
        return 0
    t = TranslationContext()
    t.buildannotator().build_types(entry_point, [s_list_of_strings])
    t.buildrtyper().specialize()
    cbuilder = CStandaloneBuilder(t, entry_point, t.config)
    cbuilder.generate_source()
    cbuilder.compile()
    data = cbuilder.cmdexec('hi there')
    assert data.strip() == "OK"
예제 #6
0
 def setup_method(self, meth):
     if getattr(meth, 'need_sparse_files', False):
         from pypy.module.posix.test.test_posix2 import need_sparse_files
         need_sparse_files()
예제 #7
0
 def setup_method(self, meth):
     if getattr(meth, 'need_sparse_files', False):
         from pypy.module.posix.test.test_posix2 import need_sparse_files
         need_sparse_files()