More obvious test failure messages for QEMU test

If the test case couldn't connect to the VM with SSH, it used to fail
with a Python error of accessing the 'missing' variable without having
it defined.

With this commit, it prints out 'Could not connect to the VM via SSH'
instead.
This commit is contained in:
Oliver Smith 2018-07-09 22:26:14 +02:00
parent bbae995be8
commit 796668d7df
1 changed files with 7 additions and 1 deletions

View File

@ -148,6 +148,7 @@ def is_running(args, programs, tries=180, sleep_before_retry=1):
"""
print("Looking for programs to appear in the VM (tries: " + str(tries) +
"): " + ", ".join(programs))
ssh_works = False
for i in range(0, tries):
# Sleep
if i > 0:
@ -157,6 +158,7 @@ def is_running(args, programs, tries=180, sleep_before_retry=1):
all = ssh_run(args, "ps ax")
if not all:
continue
ssh_works = True
# Missing programs
missing = []
@ -167,7 +169,11 @@ def is_running(args, programs, tries=180, sleep_before_retry=1):
return True
# Not found
print("Programs not running: " + ", ".join(missing))
print("ERROR: Timeout reached!")
if ssh_works:
print("Programs not running: " + ", ".join(missing))
else:
print("Could not connect to the VM via SSH")
return False