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

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

Issue 6551020: Merge remote branch 'autotest-upstream/master' into try-box1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 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
« no previous file with comments | « client/tests/kvm/tests/pci_hotplug.py ('k') | client/tests/kvm/tests/vlan.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/kvm/tests/set_link.py
diff --git a/client/tests/kvm/tests/set_link.py b/client/tests/kvm/tests/set_link.py
index d73a1b8502c2a1a12c628bb0ebf6bea52e676f98..a4a78ea29ea9f3a9eafe19f814ea2bb0fe7c1b02 100644
--- a/client/tests/kvm/tests/set_link.py
+++ b/client/tests/kvm/tests/set_link.py
@@ -21,40 +21,34 @@ def run_set_link(test, params, env):
timeout = float(params.get("login_timeout", 360))
session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)
- ip = vm.get_address(0)
- linkname = vm.netdev_id[0]
-
- logging.info("Pinging guest from host")
- s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
- if s != 0:
- raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o))
- ratio = kvm_test_utils.get_loss_ratio(o)
- if ratio != 0:
- raise error.TestFail("Loss ratio is %s, output: %s" % (ratio, o))
-
- logging.info("Executing 'set link %s off'", linkname)
- vm.monitor.cmd("set_link %s off" % linkname)
- logging.info(vm.monitor.info("network"))
- logging.info("Pinging guest from host")
- s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
- if s == 0:
- raise error.TestFail("Ping unexpectedly succeeded, status: %s,"
- "output: %s" % (s, o))
- ratio = kvm_test_utils.get_loss_ratio(o)
- if ratio != 100:
- raise error.TestFail("Loss ratio is not 100%%,"
- "Loss ratio is %s" % ratio)
-
- logging.info("Executing 'set link %s on'", linkname)
- vm.monitor.cmd("set_link %s on" % linkname)
- logging.info(vm.monitor.info("network"))
- logging.info("Pinging guest from host")
- s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
- if s != 0:
- raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o))
- ratio = kvm_test_utils.get_loss_ratio(o)
- if ratio != 0:
- raise error.TestFail("Loss ratio is %s, output: %s" % (ratio, o))
+ def set_link_test(linkid):
+ """
+ Issue set_link commands and test its function
+
+ @param linkid: id of netdev or devices to be tested
+ """
+ ip = vm.get_address(0)
+
+ vm.monitor.cmd("set_link %s down" % linkid)
+ s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
+ if kvm_test_utils.get_loss_ratio(o) != 100:
+ raise error.TestFail("Still can ping the %s after down %s" %
+ (ip, linkid))
+
+ vm.monitor.cmd("set_link %s up" % linkid)
+ s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
+ # we use 100% here as the notification of link status changed may be
+ # delayed in guest driver
+ if kvm_test_utils.get_loss_ratio(o) == 100:
+ raise error.TestFail("Packet loss during ping %s after up %s" %
+ (ip, linkid))
+
+ netdev_id = vm.netdev_id[0]
+ device_id = vm.get_peer(netdev_id)
+ logging.info("Issue set_link commands for netdevs")
+ set_link_test(netdev_id)
+ logging.info("Issue set_link commands for network devics")
+ set_link_test(device_id)
file_transfer.run_file_transfer(test, params, env)
session.close()
« no previous file with comments | « client/tests/kvm/tests/pci_hotplug.py ('k') | client/tests/kvm/tests/vlan.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698