diff options
author | Josh Gao <jmgao@google.com> | 2018-08-21 14:25:05 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-08-21 14:28:56 -0700 |
commit | 6d7b9655c9e0772e3635cd3fbae96504326c3391 (patch) | |
tree | f404e79cf3389b2958d9dffddb5365da543be15a /test_adb.py | |
parent | c62057b957ffde5cecc5e364ac5dc7e9340cf4f8 (diff) | |
download | adb-6d7b9655c9e0772e3635cd3fbae96504326c3391.tar.gz |
adb: fix test_adb.py's adb server spawning on Windows.
Test: test_adb.py on windows vm
Change-Id: I918678be7ececd167969789ecff7cfb58829fa1d
Diffstat (limited to 'test_adb.py')
-rwxr-xr-x | test_adb.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test_adb.py b/test_adb.py index 86c13d0a..cde2b22e 100755 --- a/test_adb.py +++ b/test_adb.py @@ -27,6 +27,7 @@ import select import socket import struct import subprocess +import sys import threading import time import unittest @@ -129,10 +130,19 @@ def adb_server(): subprocess.check_output(["adb", "-P", str(port), "kill-server"], stderr=subprocess.STDOUT) read_pipe, write_pipe = os.pipe() - os.set_inheritable(write_pipe, True) + + if sys.platform == "win32": + import msvcrt + write_handle = msvcrt.get_osfhandle(write_pipe) + os.set_handle_inheritable(write_handle, True) + reply_fd = str(write_handle) + else: + os.set_inheritable(write_pipe, True) + reply_fd = str(write_pipe) + proc = subprocess.Popen(["adb", "-L", "tcp:localhost:{}".format(port), "fork-server", "server", - "--reply-fd", str(write_pipe)], close_fds=False) + "--reply-fd", reply_fd], close_fds=False) try: os.close(write_pipe) greeting = os.read(read_pipe, 1024) |