diff options
author | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2017-07-20 13:26:21 +0100 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2017-07-20 15:50:21 +0100 |
commit | df71a761fa68392ad1fc6983daabfc153cb7e249 (patch) | |
tree | aaa81090180af25ef74df8ca2187835aecbcb5c9 | |
parent | 855acbe11feeada72041395002fc8e9349146c63 (diff) |
test-runner: fail gracefully if SSH connection is closed
Environment is collected after the tests are executed. In case SSH
connection is closed during test execution, environment collection
should fail gracefully so at least test results can be presented.
Change-Id: I55e1874dae2f20f9960bf0a12d05a35a48d321fc
Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
-rwxr-xr-x | automated/utils/test-runner.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/automated/utils/test-runner.py b/automated/utils/test-runner.py index 4c40bb7..b3833b9 100755 --- a/automated/utils/test-runner.py +++ b/automated/utils/test-runner.py @@ -25,7 +25,8 @@ except ImportError as e: sys.exit(1) -SSH_PARAMS = "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +# quit gracefully if the connection is closed by remote host +SSH_PARAMS = "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=5" def run_command(command, target=None): @@ -516,10 +517,21 @@ def get_environment(target=None, skip_collection=False): environment = {} if skip_collection: return environment - environment['linux_distribution'] = run_command( - "grep ^ID= /etc/os-release", target).split('=')[-1].strip('"').lower() - environment['kernel'] = run_command("uname -r", target) - environment['uname'] = run_command("uname -a", target) + try: + environment['linux_distribution'] = run_command( + "grep ^ID= /etc/os-release", target).split('=')[-1].strip('"').lower() + except subprocess.CalledProcessError: + environment['linux_distribution'] = "" + + try: + environment['kernel'] = run_command("uname -r", target) + except subprocess.CalledProcessError: + environment['kernel'] = "" + + try: + environment['uname'] = run_command("uname -a", target) + except subprocess.CalledProcessError: + environment['uname'] = "" try: environment['bios_version'] = run_command( @@ -539,7 +551,10 @@ def get_environment(target=None, skip_collection=False): except subprocess.CalledProcessError: environment['board_name'] = "" - environment['packages'] = get_packages(environment['linux_distribution'], target) + try: + environment['packages'] = get_packages(environment['linux_distribution'], target) + except subprocess.CalledProcessError: + environment['packages'] = [] return environment |