Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 676f375d authored by Josh Gao's avatar Josh Gao
Browse files

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
parent 9b6522b3
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -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,18 +55,14 @@ 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()
                        return
                    elif ready == serversock:
@@ -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()