功能:接入Linux原生光标并完善设备接入工具
This commit is contained in:
1 parent
a14f028402
commit
a47968496e
92 files changed
+3090
-22
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import socket
|
||||
import threading
|
||||
import unittest
|
||||
|
||||
spec = importlib.util.spec_from_file_location("usb_qmp", Path(__file__).parents[1] / "usb-device-qmp.py")
|
||||
@@ -51,6 +53,24 @@ class UsbQmpTests(unittest.TestCase):
|
||||
usb.attach(q, 100, 40001, "ehci-2.0", "0951", "1666")
|
||||
self.assertEqual(q.calls[-1], ("chardev-remove", {"id": "vdi_usb_box_100"}))
|
||||
|
||||
def test_status_probe_distinguishes_ready_from_empty(self):
|
||||
listener = socket.socket()
|
||||
listener.bind(("127.0.0.1", 0))
|
||||
listener.listen()
|
||||
port = listener.getsockname()[1]
|
||||
|
||||
def serve():
|
||||
conn, _ = listener.accept()
|
||||
conn.sendall(b"ready\n")
|
||||
conn.close()
|
||||
listener.close()
|
||||
|
||||
thread = threading.Thread(target=serve)
|
||||
thread.start()
|
||||
self.assertTrue(usb.probe_status(port, timeout=1))
|
||||
thread.join(timeout=1)
|
||||
self.assertFalse(usb.probe_status(port, timeout=0.05))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user