scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Flaky DoIP test on MacOSX

Open polybassa opened this issue 1 year ago • 1 comments

Brief description

The following issue occurs sometimes in the CI pipeline:

Regression tests for the DoIP layer
━ Run at 15:14:56 from [test/contrib/automotive/doip.uts] by UTscapy in 1.744396448135376
 └ Passed=35
 └ Failed=1

######
## DoIP Communication tests
######


###(029)=[failed] Test DoIPSocket 2

>>> server_up = threading.Event()
>>> def server():
...     buffer = b'\x02\xfd\x80\x02\x00\x00\x00\x05\x00\x00\x00\x00\x00\x02\xfd\x80\x01\x00\x00\x00\n\x10\x10\x0e\x80P\x03\x002\x01\xf4'
...     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
...     try:
...         sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
...         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
...         sock.bind(('127.0.0.1', 13400))
...         sock.listen(1)
...         server_up.set()
...         connection, address = sock.accept()
...         for i in range(len(buffer)):
...             connection.send(buffer[i:i+1])
...             time.sleep(0.01)
...         connection.close()
...     finally:
...         sock.close()
... 
>>> 
>>> server_thread = threading.Thread(target=server)
>>> server_thread.start()
>>> server_up.wait(timeout=1)
True
>>> sock = DoIPSocket(activate_routing=False)
>>> 
>>> pkts = sock.sniff(timeout=1, count=2)
>>> server_thread.join(timeout=1)
>>> assert len(pkts) == 2
Traceback (most recent call last):
  File "<input>", line 2, in <module>
AssertionError

@gpotter2 Do you may have an idea what could go wrong in this test?

Scapy version

Latest

Python version

3.12

Operating system

Mac OSX

Additional environment information

No response

How to reproduce

https://github.com/secdev/scapy/actions/runs/8911100231/job/24471714477

Actual result

No response

Expected result

No response

Related resources

No response

polybassa avatar May 01 '24 17:05 polybassa

Unfortunately I don't have a Mac so I can't debug this issue in depth. Since this test doesn't fail every time, I guess it might be some race condition or something OSX specific. Do you may have an idea?

polybassa avatar May 01 '24 17:05 polybassa