From 9a5fac15a41146666bf61dcd07f28b9124bc8d62 Mon Sep 17 00:00:00 2001 From: Yihuang Yu Date: Fri, 17 Jul 2020 16:57:05 +0800 Subject: [PATCH] ping.ext_host: Only execute ext_host_get_cmd when it is not empty `process.run` cannot pass empty command line and will raise IndexError, only execute the ext_host_get_cmd if it is not empty. Signed-off-by: Yihuang Yu --- generic/tests/ping.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/generic/tests/ping.py b/generic/tests/ping.py index 1983e0f9..1ae700a5 100644 --- a/generic/tests/ping.py +++ b/generic/tests/ping.py @@ -68,13 +68,14 @@ def run(test, params, env): if ping_ext_host: ext_host = params.get("ext_host", "") ext_host_get_cmd = params.get("ext_host_get_cmd", "") - try: - ext_host = process.system_output(ext_host_get_cmd, shell=True) - ext_host = ext_host.decode() - except process.CmdError: - logging.warn("Can't get specified host with cmd '%s'," - " Fallback to default host '%s'", - ext_host_get_cmd, ext_host) + if ext_host_get_cmd: + try: + ext_host = process.system_output(ext_host_get_cmd, shell=True) + ext_host = ext_host.decode() + except process.CmdError: + logging.warn("Can't get specified host with cmd '%s'," + " Fallback to default host '%s'", + ext_host_get_cmd, ext_host) dest_ips = [ext_host] sessions = [session] interfaces = [None] -- GitLab