Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r90594:a88dd1282cf9 Date: 2017-03-08 15:56 +0100 http://bitbucket.org/pypy/pypy/changeset/a88dd1282cf9/
Log: test and fix: rposix.sendfile() didn't capture errno diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -2434,7 +2434,8 @@ _OFF_PTR_T = rffi.CArrayPtr(OFF_T) c_sendfile = rffi.llexternal('sendfile', [rffi.INT, rffi.INT, _OFF_PTR_T, rffi.SIZE_T], - rffi.SSIZE_T, compilation_info=sendfile_eci) + rffi.SSIZE_T, save_err=rffi.RFFI_SAVE_ERRNO, + compilation_info=sendfile_eci) def sendfile(out_fd, in_fd, offset, count): with lltype.scoped_alloc(_OFF_PTR_T.TO, 1) as p_offset: diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py --- a/rpython/rlib/test/test_rposix.py +++ b/rpython/rlib/test/test_rposix.py @@ -693,6 +693,20 @@ s2.close() s1.close() + 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() + if sys.platform.startswith('linux'): def test_sendfile_no_offset(): from rpython.rlib import rsocket _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit