Skip to content

Commit

Permalink
tests: Unset O_NONBLOCK|O_NDELAY to fix SPARC
Browse files Browse the repository at this point in the history
Fix TestGreenSocket.test_skip_nonblocking() to unset both O_NONBLOCK
and O_NDELAY.  This is necessary to fix tests on SPARC where both flags
are used simultaneously, and unsetting one is ineffective (flags remain
the same).  This should not affect other platforms where O_NDELAY
is an alias for O_NONBLOCK.
  • Loading branch information
mgorny authored and jstasiak committed Jul 1, 2020
1 parent 5846e1c commit 6508a38
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/greenio_test.py
Expand Up @@ -634,13 +634,15 @@ def test_skip_nonblocking(self):
sock1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
fd = sock1.fd.fileno()
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
# on SPARC, nonblocking mode sets O_NDELAY as well
fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~(os.O_NONBLOCK
| os.O_NDELAY))
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
assert flags & os.O_NONBLOCK == 0
assert flags & (os.O_NONBLOCK | os.O_NDELAY) == 0

sock2 = socket.socket(sock1.fd, set_nonblocking=False)
flags = fcntl.fcntl(sock2.fd.fileno(), fcntl.F_GETFL)
assert flags & os.O_NONBLOCK == 0
assert flags & (os.O_NONBLOCK | os.O_NDELAY) == 0

def test_sockopt_interface(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand Down

0 comments on commit 6508a38

Please sign in to comment.