Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerator tests keep failing on Windows #4185

Open
gpotter2 opened this issue Nov 17, 2023 · 0 comments
Open

Enumerator tests keep failing on Windows #4185

gpotter2 opened this issue Nov 17, 2023 · 0 comments

Comments

@gpotter2
Copy link
Member

gpotter2 commented Nov 17, 2023

Disabled in #4186

###(014)=[failed] ServiceEnumerator execute
>>> from queue import Queue
>>> from scapy.supersocket import SuperSocket
>>> 
>>> class MockISOTPSocket(SuperSocket):
...     nonblocking_socket = True
...     @property
...     def closed(self):
...         return False
...     @closed.setter
...     def closed(self, var):
...         pass
...     def __init__(self, rcvd_queue=None):
...         self.rcvd_queue = Queue()
...         self.sent_queue = Queue()
...         if rcvd_queue is not None:
...             for c in rcvd_queue:
...                 self.rcvd_queue.put(c)
...     def recv_raw(self, x=MTU):
...         pkt = bytes(self.rcvd_queue.get(True, 0.01))
...         return UDS, pkt, 10.0
...     def send(self, x):
...         sx = raw(x)
...         try:
...             x.sent_time = 9.0
...         except AttributeError:
...             pass
...         self.sent_queue.put(sx)
...         return len(sx)
...     @staticmethod
...     def select(sockets, remain=None):
...         return sockets
... 
>>> sock = MockISOTPSocket()
>>> sock.rcvd_queue.put(b"\x41")
>>> sock.rcvd_queue.put(b"\x42")
>>> sock.rcvd_queue.put(b"\x43")
>>> sock.rcvd_queue.put(b"\x44")
>>> sock.rcvd_queue.put(b"\x45")
>>> sock.rcvd_queue.put(b"\x46")
>>> sock.rcvd_queue.put(b"\x47")
>>> sock.rcvd_queue.put(b"\x48")
>>> sock.rcvd_queue.put(b"\x49")
>>> sock.rcvd_queue.put(b"\x4A")
>>> 
>>> e = MyTestCase()
>>> 
>>> e.execute(sock, EcuState(session=1))
Finished iterator execution
>>> 
>>> assert len(e.filtered_results) == 10
>>> assert len(e.results_with_response) == 10
>>> assert len(e.results_without_response) == 0
>>> 
>>> assert e.has_completed(EcuState(session=1))
>>> assert e.completed
>>> 
>>> e.execute(sock, EcuState(session=2), timeout=0.01)
Socket <MockISOTPSocket object at 0x0000013F716E7F08> failed with ''. It was closed.
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:\projects\scapy\scapy\contrib\automotive\scanner\enumerator.py", line 309, in execute
    res = self.sr1_with_retry_on_error(req, socket, state, timeout)
  File "C:\projects\scapy\scapy\contrib\automotive\scanner\enumerator.py", line 347, in sr1_with_retry_on_error
    chainEX=True, chainCC=True)
  File "C:\projects\scapy\scapy\supersocket.py", line 223, in sr1
    ans = sendrecv.sndrcv(self, *args, **kargs)[0]  # type: SndRcvList
  File "C:\projects\scapy\scapy\sendrecv.py", line 330, in sndrcv
    sndrcver = SndRcvHandler(*args, **kwargs)
  File "C:\projects\scapy\scapy\sendrecv.py", line 189, in __init__
    self._sndrcv_rcv(self._sndrcv_snd)
  File "C:\projects\scapy\scapy\sendrecv.py", line 317, in _sndrcv_rcv
    started_callback=callback
  File "C:\projects\scapy\scapy\sendrecv.py", line 1247, in _run
    for p in packets:
  File "C:\projects\scapy\scapy\sessions.py", line 56, in recv
    pkt = sock.recv()
  File "C:\projects\scapy\scapy\supersocket.py", line 180, in recv
    cls, val, ts = self.recv_raw(x)
  File "<input>", line 17, in recv_raw
  File "C:\Python37-x64\lib\queue.py", line 178, in get
    raise Empty
_queue.Empty
PACKET DISSECTION FAILED ON:
 Ether(hex_bytes('00155da5c62c00155da5c65c08004500003848b80000fe01814143e1a4030a0000e70b005831000000004500002848b80000010622310a0000e7ac4097c0733100505554d3f8'))
###(016)=[failed] Test negative response code retry if busy
>>> sock.rcvd_queue.put(b"\x7f\x01\x21")
>>> sock.rcvd_queue.put(b"\x7f\x01\x10")
>>> 
>>> e = MyTestCase()
>>> 
>>> e.execute(sock, EcuState(session=1))
>>> 
>>> assert e._retry_pkt[EcuState(session=1)]
>>> assert len(e.results_with_response) == 1
>>> assert len(e.results_with_negative_response) == 1
>>> assert len(e.results_without_response) == 0
>>> assert not e.completed
>>> 
>>> e.execute(sock, EcuState(session=1))
Socket <MockISOTPSocket object at 0x0000013F716E7F08> failed with ''. It was closed.
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:\projects\scapy\scapy\contrib\automotive\scanner\enumerator.py", line 309, in execute
    res = self.sr1_with_retry_on_error(req, socket, state, timeout)
  File "C:\projects\scapy\scapy\contrib\automotive\scanner\enumerator.py", line 347, in sr1_with_retry_on_error
    chainEX=True, chainCC=True)
  File "C:\projects\scapy\scapy\supersocket.py", line 223, in sr1
    ans = sendrecv.sndrcv(self, *args, **kargs)[0]  # type: SndRcvList
  File "C:\projects\scapy\scapy\sendrecv.py", line 330, in sndrcv
    sndrcver = SndRcvHandler(*args, **kwargs)
  File "C:\projects\scapy\scapy\sendrecv.py", line 189, in __init__
    self._sndrcv_rcv(self._sndrcv_snd)
  File "C:\projects\scapy\scapy\sendrecv.py", line 317, in _sndrcv_rcv
    started_callback=callback
  File "C:\projects\scapy\scapy\sendrecv.py", line 1247, in _run
    for p in packets:
  File "C:\projects\scapy\scapy\sessions.py", line 56, in recv
    pkt = sock.recv()
  File "C:\projects\scapy\scapy\supersocket.py", line 180, in recv
    cls, val, ts = self.recv_raw(x)
  File "<input>", line 17, in recv_raw
  File "C:\Python37-x64\lib\queue.py", line 178, in get
    raise Empty
_queue.Empty
###(017)=[failed] Test negative response code don't retry if busy
>>> sock.rcvd_queue.put(b"\x7f\x01\x21")
>>> 
>>> e = MyTestCase()
>>> 
>>> e.execute(sock, EcuState(session=1), retry_if_busy_returncode=False)
more Socket <MockISOTPSocket object at 0x0000013F716E7F08> failed with ''. It was closed.
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:\projects\scapy\scapy\contrib\automotive\scanner\enumerator.py", line 309, in execute
    res = self.sr1_with_retry_on_error(req, socket, state, timeout)
  File "C:\projects\scapy\scapy\contrib\automotive\scanner\enumerator.py", line 347, in sr1_with_retry_on_error
    chainEX=True, chainCC=True)
  File "C:\projects\scapy\scapy\supersocket.py", line 223, in sr1
    ans = sendrecv.sndrcv(self, *args, **kargs)[0]  # type: SndRcvList
  File "C:\projects\scapy\scapy\sendrecv.py", line 330, in sndrcv
    sndrcver = SndRcvHandler(*args, **kwargs)
  File "C:\projects\scapy\scapy\sendrecv.py", line 189, in __init__
    self._sndrcv_rcv(self._sndrcv_snd)
  File "C:\projects\scapy\scapy\sendrecv.py", line 317, in _sndrcv_rcv
    started_callback=callback
  File "C:\projects\scapy\scapy\sendrecv.py", line 1247, in _run
    for p in packets:
  File "C:\projects\scapy\scapy\sessions.py", line 56, in recv
    pkt = sock.recv()
  File "C:\projects\scapy\scapy\supersocket.py", line 180, in recv
    cls, val, ts = self.recv_raw(x)
  File "<input>", line 17, in recv_raw
  File "C:\Python37-x64\lib\queue.py", line 178, in get
    raise Empty
_queue.Empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant