Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: client/tests/kvm/tests/nicdriver_unload.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/tests/kvm/tests/nicdriver_unload.py
diff --git a/client/tests/kvm/tests/nicdriver_unload.py b/client/tests/kvm/tests/nicdriver_unload.py
index 47318ba9c0193d5db8d48bde57167b4b91f98f5d..065c60eeb0d62e83e063513b38b301dcec0e599f 100644
--- a/client/tests/kvm/tests/nicdriver_unload.py
+++ b/client/tests/kvm/tests/nicdriver_unload.py
@@ -1,7 +1,8 @@
import logging, threading, os
from autotest_lib.client.common_lib import error
from autotest_lib.client.bin import utils
-import kvm_utils, kvm_test_utils
+import kvm_test_utils
+
def run_nicdriver_unload(test, params, env):
"""
@@ -18,19 +19,14 @@ def run_nicdriver_unload(test, params, env):
@param env: Dictionary with test environment.
"""
timeout = int(params.get("login_timeout", 360))
- vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
- session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
- logging.info("Trying to log into guest '%s' by serial", vm.name)
- session2 = kvm_utils.wait_for(lambda: vm.serial_login(),
- timeout, 0, step=2)
- if not session2:
- raise error.TestFail("Could not log into guest '%s'" % vm.name)
+ vm = env.get_vm(params["main_vm"])
+ vm.verify_alive()
+ session = vm.wait_for_login(timeout=timeout)
+ session_serial = vm.wait_for_serial_login(timeout=timeout)
ethname = kvm_test_utils.get_linux_ifname(session, vm.get_mac_address(0))
sys_path = "/sys/class/net/%s/device/driver" % (ethname)
- s, o = session.get_command_status_output('readlink -e %s' % sys_path)
- if s:
- raise error.TestError("Could not find driver name")
+ o = session.cmd("readlink -e %s" % sys_path)
driver = os.path.basename(o.strip())
logging.info("driver is %s", driver)
@@ -38,19 +34,12 @@ def run_nicdriver_unload(test, params, env):
def run(self):
remote_file = '/tmp/' + self.getName()
file_list.append(remote_file)
- ret = vm.copy_files_to(file_name, remote_file, timeout=scp_timeout)
- if ret:
- logging.debug("File %s was transfered successfuly", remote_file)
- else:
- logging.debug("Failed to transfer file %s", remote_file)
+ vm.copy_files_to(file_name, remote_file, timeout=scp_timeout)
+ logging.debug("File %s was transfered successfuly", remote_file)
def compare(origin_file, receive_file):
- cmd = "md5sum %s"
check_sum1 = utils.hash_file(origin_file, method="md5")
- s, output2 = session.get_command_status_output(cmd % receive_file)
- if s != 0:
- logging.error("Could not get md5sum of receive_file")
- return False
+ output2 = session.cmd("md5sum %s" % receive_file)
check_sum2 = output2.strip().split()[0]
logging.debug("original file md5: %s, received file md5: %s",
check_sum1, check_sum2)
@@ -77,9 +66,11 @@ def run_nicdriver_unload(test, params, env):
logging.info("Unload/load NIC driver repeatedly in guest...")
while True:
logging.debug("Try to unload/load nic drive once")
- if session2.get_command_status(unload_load_cmd, timeout=120) != 0:
- session.get_command_output("rm -rf /tmp/Thread-*")
- raise error.TestFail("Unload/load nic driver failed")
+ try:
+ session_serial.cmd(unload_load_cmd, timeout=120)
+ except:
+ session.cmd_output("rm -rf /tmp/Thread-*")
+ raise
pid, s = os.waitpid(pid, os.WNOHANG)
status = os.WEXITSTATUS(s)
if (pid, status) != (0, 0):
@@ -96,7 +87,6 @@ def run_nicdriver_unload(test, params, env):
t.join(timeout = scp_timeout)
os._exit(0)
- session2.close()
try:
logging.info("Check MD5 hash for received files in multi-session")
@@ -105,11 +95,10 @@ def run_nicdriver_unload(test, params, env):
raise error.TestFail("Fail to compare (guest) file %s" % f)
logging.info("Test nic function after load/unload")
- if not vm.copy_files_to(file_name, file_name):
- raise error.TestFail("Fail to copy file from host to guest")
+ vm.copy_files_to(file_name, file_name)
if not compare(file_name, file_name):
raise error.TestFail("Test nic function after load/unload fail")
finally:
- session.get_command_output("rm -rf /tmp/Thread-*")
+ session.cmd_output("rm -rf /tmp/Thread-*")
session.close()

Powered by Google App Engine
This is Rietveld 408576698