1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-21 23:18:13 +00:00

tests/device_tests: don't wait forever for emulator to start listening

This commit is contained in:
Pavol Rusnak 2019-09-10 23:34:28 +02:00
parent 775f5b4e66
commit 9898b9f208
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -46,12 +46,18 @@ class EmulatorWrapper:
env["TREZOR_PROFILE_DIR"] = self.workdir.name
# for firmware 2.1.1 and older
env["TREZOR_PROFILE"] = self.workdir.name
self.client = None
self.process = subprocess.Popen(
args, cwd=self.workdir.name, env=ENV, stdout=open(os.devnull, "w")
)
# wait until emulator is started
# wait until emulator is listening
i = 0
while True:
try:
i += 1
if i > 100:
self.__exit__(None, None, None)
raise RuntimeError("Can't connect to emulator")
self.transport = get_transport("udp:127.0.0.1:21324")
except TransportException:
time.sleep(0.1)
@ -73,7 +79,8 @@ class EmulatorWrapper:
return self
def __exit__(self, exc_type, exc_value, traceback):
self.client.close()
if self.client:
self.client.close()
self.process.terminate()
try:
self.process.wait(1)