Example #1
0
 def test_sendfile_invalid_offset():
     from rpython.rlib import rsocket
     s1, s2 = rsocket.socketpair()
     relpath = 'test_sendfile_invalid_offset'
     filename = str(udir.join(relpath))
     fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0777)
     os.write(fd, 'abcdefghij')
     with py.test.raises(OSError) as excinfo:
         rposix.sendfile(s1.fd, fd, -1, 5)
     assert excinfo.value.errno == errno.EINVAL
     os.close(fd)
     s2.close()
     s1.close()
Example #2
0
 def test_sendfile():
     from rpython.rlib import rsocket
     s1, s2 = rsocket.socketpair()
     relpath = 'test_sendfile'
     filename = str(udir.join(relpath))
     fd = os.open(filename, os.O_RDWR | os.O_CREAT, 0777)
     os.write(fd, 'abcdefghij')
     res = rposix.sendfile(s1.fd, fd, 3, 5)
     assert res == 5
     data = os.read(s2.fd, 10)
     assert data == 'defgh'
     os.close(fd)
     s2.close()
     s1.close()