mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
tests/device_tests: don't wait forever for emulator to start listening
This commit is contained in:
parent
775f5b4e66
commit
9898b9f208
@ -46,12 +46,18 @@ class EmulatorWrapper:
|
|||||||
env["TREZOR_PROFILE_DIR"] = self.workdir.name
|
env["TREZOR_PROFILE_DIR"] = self.workdir.name
|
||||||
# for firmware 2.1.1 and older
|
# for firmware 2.1.1 and older
|
||||||
env["TREZOR_PROFILE"] = self.workdir.name
|
env["TREZOR_PROFILE"] = self.workdir.name
|
||||||
|
self.client = None
|
||||||
self.process = subprocess.Popen(
|
self.process = subprocess.Popen(
|
||||||
args, cwd=self.workdir.name, env=ENV, stdout=open(os.devnull, "w")
|
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:
|
while True:
|
||||||
try:
|
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")
|
self.transport = get_transport("udp:127.0.0.1:21324")
|
||||||
except TransportException:
|
except TransportException:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@ -73,6 +79,7 @@ class EmulatorWrapper:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
|
if self.client:
|
||||||
self.client.close()
|
self.client.close()
|
||||||
self.process.terminate()
|
self.process.terminate()
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user