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

Unified Diff: client/tests/kvm/tests/mac_change.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/mac_change.py
diff --git a/client/tests/kvm/tests/mac_change.py b/client/tests/kvm/tests/mac_change.py
index c614e1568179bcaa231afb21bcdeb4f466e2f816..3fd196f79e75288f54b652a5fcc36af87ceb0a9a 100644
--- a/client/tests/kvm/tests/mac_change.py
+++ b/client/tests/kvm/tests/mac_change.py
@@ -15,14 +15,12 @@ def run_mac_change(test, params, env):
@param params: Dictionary with the test parameters.
@param env: Dictionary with test environment.
"""
+ vm = env.get_vm(params["main_vm"])
+ vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
- vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
- logging.info("Trying to log into guest '%s' by serial", vm.name)
- session = kvm_utils.wait_for(lambda: vm.serial_login(),
- timeout, 0, step=2)
- if not session:
- raise error.TestFail("Could not log into guest '%s'" % vm.name)
-
+ session_serial = vm.wait_for_serial_login(timeout=timeout)
+ # This session will be used to assess whether the IP change worked
+ session = vm.wait_for_login(timeout=timeout)
old_mac = vm.get_mac_address(0)
while True:
vm.free_mac_address(0)
@@ -30,23 +28,21 @@ def run_mac_change(test, params, env):
if old_mac != new_mac:
break
logging.info("The initial MAC address is %s", old_mac)
- interface = kvm_test_utils.get_linux_ifname(session, old_mac)
+ interface = kvm_test_utils.get_linux_ifname(session_serial, old_mac)
# Start change MAC address
logging.info("Changing MAC address to %s", new_mac)
change_cmd = ("ifconfig %s down && ifconfig %s hw ether %s && "
"ifconfig %s up" % (interface, interface, new_mac, interface))
- if session.get_command_status(change_cmd) != 0:
- raise error.TestFail("Fail to send mac_change command")
+ session_serial.cmd(change_cmd)
# Verify whether MAC address was changed to the new one
logging.info("Verifying the new mac address")
- if session.get_command_status("ifconfig | grep -i %s" % new_mac) != 0:
- raise error.TestFail("Fail to change MAC address")
+ session_serial.cmd("ifconfig | grep -i %s" % new_mac)
# Restart `dhclient' to regain IP for new mac address
logging.info("Restart the network to gain new IP")
dhclient_cmd = "dhclient -r && dhclient %s" % interface
- session.sendline(dhclient_cmd)
+ session_serial.sendline(dhclient_cmd)
# Re-log into the guest after changing mac address
if kvm_utils.wait_for(session.is_responsive, 120, 20, 3):
@@ -57,8 +53,7 @@ def run_mac_change(test, params, env):
# Re-log into guest and check if session is responsive
logging.info("Re-log into the guest")
- session = kvm_test_utils.wait_for_login(vm,
- timeout=int(params.get("login_timeout", 360)))
+ session = vm.wait_for_login(timeout=timeout)
if not session.is_responsive():
raise error.TestFail("The new session is not responsive.")

Powered by Google App Engine
This is Rietveld 408576698