Skip to content

test_wantWriteError fails again because not enough data is written #768

Closed
@nh2

Description

@nh2

Similar to #37, #67, #76.

On my Ubuntu 16.04, (and I think when I build my libraries against musl instead of glibc, using nix, but that's probably not relevant), I get:

=================================== FAILURES ===================================
______________________ TestConnection.test_wantWriteError ______________________

self = <tests.test_ssl.TestConnection object at 0x7fffe9eabd10>

    def test_wantWriteError(self):
        """
            `Connection` methods which generate output raise
            `OpenSSL.SSL.WantWriteError` if writing to the connection's BIO
            fail indicating a should-write state.
            """
        client_socket, server_socket = socket_pair()
        # Fill up the client's send buffer so Connection won't be able to write
        # anything.  Only write a single byte at a time so we can be sure we
        # completely fill the buffer.  Even though the socket API is allowed to
        # signal a short write via its return value it seems this doesn't
        # always happen on all platforms (FreeBSD and OS X particular) for the
        # very last bit of available buffer space.
        msg = b"x"
        for i in range(1024 * 1024 * 4):
            try:
                client_socket.send(msg)
            except error as e:
                if e.errno == EWOULDBLOCK:
                    break
                raise
        else:
            pytest.fail(
>               "Failed to fill socket buffer, cannot test BIO want write")
E           Failed: Failed to fill socket buffer, cannot test BIO want write

tests/test_ssl.py:2593: Failed
===================== 1 failed, 490 passed in 7.54 seconds =====================

This looks like, as in the other issues, my kernel actually permits more data in a socket buffer than 1024 * 1024 * 4.

It looks that this test cannot be written so that it passes on all systems, unless it either

  • figures out what the actual max socket buffer size is before testing it, or
  • really counts up forever (e.g. possibly up to the amount of RAM available) to accomodate for any setting the system that this running on might have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions