diff options
author | Josh Gao <jmgao@google.com> | 2018-08-07 16:07:25 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-08-08 17:40:15 -0700 |
commit | 6afbf7932062ba2e1575410171e36d8d3feaa3e4 (patch) | |
tree | d6067df5a0021a1a628f49bcf1a1770165ff3376 /test_adb.py | |
parent | b1df00e390c8538dfa597fb73c7a3fbc983e088b (diff) | |
download | adb-6afbf7932062ba2e1575410171e36d8d3feaa3e4.tar.gz |
adb: make test_adb.py work on windows.
Switch from os.pipe to socket.socketpair for the fake adbd termination
termination signaller, that we can select on it on windows.
Test: test_adb.py on windows (2 failures on windows)
Change-Id: I37df06e465ec8be28cfb18a5c21ef30125195004
Diffstat (limited to 'test_adb.py')
-rwxr-xr-x | test_adb.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/test_adb.py b/test_adb.py index 173251a2..f82617a9 100755 --- a/test_adb.py +++ b/test_adb.py @@ -44,7 +44,7 @@ def fake_adbd(protocol=socket.AF_INET, port=0): serversock.listen(1) # A pipe that is used to signal the thread that it should terminate. - readpipe, writepipe = os.pipe() + readsock, writesock = socket.socketpair() def _adb_packet(command: bytes, arg0: int, arg1: int, data: bytes) -> bytes: bin_command = struct.unpack('I', command)[0] @@ -55,19 +55,15 @@ def fake_adbd(protocol=socket.AF_INET, port=0): def _handle(sock): with contextlib.closing(sock) as serversock: - rlist = [readpipe, serversock] + rlist = [readsock, serversock] cnxn_sent = {} while True: read_ready, _, _ = select.select(rlist, [], []) for ready in read_ready: - if ready == readpipe: + if ready == readsock: # Closure pipe - serversock.shutdown(socket.SHUT_RDWR) for f in rlist: - if isinstance(f, int): - os.close(f) - else: - f.close() + f.close() return elif ready == serversock: # Server socket @@ -96,7 +92,7 @@ def fake_adbd(protocol=socket.AF_INET, port=0): try: yield port finally: - os.close(writepipe) + writesock.close() server_thread.join() |