diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2012-01-05 21:33:38 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2012-01-05 21:33:38 +0000 |
commit | b4ce95058eab43447cbccd75e6404609bac23cdf (patch) | |
tree | 49332df2e11536f6958d29ffbef84df75db51160 | |
parent | c5fbd1d95c111972a1bed398c298bc0bf881c804 (diff) | |
download | pysendfile-b4ce95058eab43447cbccd75e6404609bac23cdf.tar.gz |
test_send_nbytes_0 on FreeBSD appears to not be reliable as sendfile() cannot send until EOF
-rw-r--r-- | test/test_sendfile.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/test/test_sendfile.py b/test/test_sendfile.py index 0d35564..a379c4c 100644 --- a/test/test_sendfile.py +++ b/test/test_sendfile.py @@ -289,15 +289,19 @@ class TestSendfile(unittest.TestCase): if sys.platform.startswith('freebsd'): def test_send_nbytes_0(self): - # On Mac OS X and FreeBSD, a value of 0 for nbytes + # On Mac OS X and FreeBSD a value of 0 for nbytes # is supposed to send the whole file in one shot. - # OSX implementation appears to be broken though. - sendfile.sendfile(self.sockno, self.fileno, 0, 0) - self.client.close() - self.server.wait() - data = self.server.handler_instance.get_data() - self.assertEqual(len(data), len(DATA)) - self.assertEqual(hash(data), hash(DATA)) + # OSX implementation appears to be just broken. + # On *BSD this works most of the times: sometimes + # EAGAIN is returned internally and here we get the + # number of bytes sent. + sent = sendfile.sendfile(self.sockno, self.fileno, 0, 0) + if sent == len(DATA): + self.client.close() + self.server.wait() + data = self.server.handler_instance.get_data() + self.assertEqual(len(data), len(DATA)) + self.assertEqual(hash(data), hash(DATA)) if hasattr(sendfile, "SF_NODISKIO"): def test_flags(self): |