提交 9262e6ff 编写于 作者: Q Qingtang Zhou 提交者: Lucas Meneghel Rodrigues

tests.ethtool: Update session operation

There could be problem when this test fails, so add
try...except block in the end of this script to avoid
unexpected exception when test fails.

Changes from V1:
 * Rebase this patch against merged tree
 * Verify session before close it.
Signed-off-by: NQingtang Zhou <qzhou@redhat.com>
Acked-by: NFeng Yang <fyang@redhat.com>
上级 3e0a0f73
......@@ -121,7 +121,8 @@ def run_ethtool(test, params, env):
@param src: Source host of transfer file
@return: Tuple (status, error msg/tcpdump result)
"""
session2.cmd_output("rm -rf %s" % filename)
sess = vm.wait_for_login(timeout=login_timeout)
sess.cmd_output("rm -rf %s" % filename)
dd_cmd = ("dd if=/dev/urandom of=%s bs=1M count=%s" %
(filename, params.get("filesize")))
......@@ -134,7 +135,7 @@ def run_ethtool(test, params, env):
tcpdump_cmd += " and src %s" % guest_ip
copy_files_func = vm.copy_files_from
try:
session.cmd_output(dd_cmd, timeout=360)
sess.cmd_output(dd_cmd, timeout=360)
except aexpect.ShellCmdError, e:
return failure
else:
......@@ -153,7 +154,7 @@ def run_ethtool(test, params, env):
tcpdump_cmd += " and not port %s" % i
logging.debug("Listening traffic using command: %s", tcpdump_cmd)
session2.sendline(tcpdump_cmd)
sess.sendline(tcpdump_cmd)
if not utils_misc.wait_for(
lambda:session.cmd_status("pgrep tcpdump") == 0, 30):
return (False, "Tcpdump process wasn't launched")
......@@ -166,7 +167,7 @@ def run_ethtool(test, params, env):
session.cmd("killall tcpdump")
try:
tcpdump_string = session2.read_up_to_prompt(timeout=60)
tcpdump_string = sess.read_up_to_prompt(timeout=60)
except aexpect.ExpectError:
return (False, "Failed to read tcpdump's output")
......@@ -217,7 +218,6 @@ def run_ethtool(test, params, env):
# Let's just error the test if we identify that there's no ethtool installed
session.cmd("ethtool -h")
session2 = vm.wait_for_login(timeout=login_timeout)
mtu = 1514
feature_status = {}
filename = "/tmp/ethtool.dd"
......@@ -277,6 +277,15 @@ def run_ethtool(test, params, env):
raise error.TestFail("Failed tests: %s" % failed_tests)
finally:
ethtool_restore_params()
session.close()
session2.close()
try:
if session:
session.close()
except Exception, detail:
logging.error("Fail to close session: '%s'", detail)
try:
session = vm.wait_for_serial_login(timeout=login_timeout)
ethtool_restore_params(session)
except Exception, detail:
logging.warn("Could not restore parameter of"
" eth card: '%s'", detail)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册