Skip to content

Commit 1d8f5f2

Browse files
committed
tests: work around bug in sd_is_mq
The fix was committed in v226-362-g0260d1d542.
1 parent 4be2fc7 commit 1d8f5f2

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

systemd/test/test_daemon.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import posix
44
import socket
55
import contextlib
6+
import errno
67
from systemd.daemon import (booted,
78
is_fifo, _is_fifo,
89
is_socket, _is_socket,
@@ -89,20 +90,36 @@ def test_is_fifo_bad_fd(tmpdir):
8990
with pytest.raises(OSError):
9091
assert not is_fifo(-1, path)
9192

93+
def is_mq_wrapper(arg):
94+
try:
95+
return is_mq(arg)
96+
except OSError as error:
97+
# systemd < 227 compatiblity
98+
assert error.errno == errno.EBADF
99+
return False
100+
101+
def _is_mq_wrapper(arg):
102+
try:
103+
return _is_mq(arg)
104+
except OSError as error:
105+
# systemd < 227 compatiblity
106+
assert error.errno == errno.EBADF
107+
return False
108+
92109
def test_no_mismatch():
93110
with closing_socketpair(socket.AF_UNIX) as pair:
94111
for sock in pair:
95112
assert not is_fifo(sock)
96-
assert not is_mq(sock)
113+
assert not is_mq_wrapper(sock)
97114
assert not is_socket_inet(sock)
98115

99116
fd = sock.fileno()
100117
assert not is_fifo(fd)
101-
assert not is_mq(fd)
118+
assert not is_mq_wrapper(fd)
102119
assert not is_socket_inet(fd)
103120

104121
assert not _is_fifo(fd)
105-
assert not _is_mq(fd)
122+
assert not _is_mq_wrapper(fd)
106123
assert not _is_socket_inet(fd)
107124

108125
def test_is_socket():

0 commit comments

Comments
 (0)