[PATCH] KVM test: ethtool subtest: Check failure on dd executed on guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch also checks failures in dd commands executed inside
the guest. It also gets rid of the commands API usage and uses
utils.run.

Signed-off-by: Amos Kong <akong@xxxxxxxxxx>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/tests/ethtool.py |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/client/tests/kvm/tests/ethtool.py b/client/tests/kvm/tests/ethtool.py
index 9708497..2d5b0fc 100644
--- a/client/tests/kvm/tests/ethtool.py
+++ b/client/tests/kvm/tests/ethtool.py
@@ -1,4 +1,4 @@
-import logging, commands, re
+import logging, re
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 import kvm_test_utils, kvm_utils, kvm_subprocess
@@ -99,18 +99,23 @@ def run_ethtool(test, params, env):
         session2.cmd_output("rm -rf %s" % filename)
         dd_cmd = ("dd if=/dev/urandom of=%s bs=1M count=%s" %
                   (filename, params.get("filesize")))
-        logging.info("Creat file in source host, cmd: %s" % dd_cmd)
+        failure = (False, "Failed to create file using dd, cmd: %s" % dd_cmd)
+        logging.info("Creating file in source host, cmd: %s" % dd_cmd)
         tcpdump_cmd = "tcpdump -lep -s 0 tcp -vv port ssh"
         if src == "guest":
-            session.cmd_output(dd_cmd, timeout=360)
             tcpdump_cmd += " and src %s" % guest_ip
             copy_files_from = vm.copy_files_from
+            try:
+                session.cmd_output(dd_cmd, timeout=360)
+            except kvm_subprocess.ShellCmdError, e:
+                return failure
         else:
-            s, o = commands.getstatusoutput(dd_cmd)
             tcpdump_cmd += " and dst %s" % guest_ip
             copy_files_from = vm.copy_files_to
-        if s != 0:
-            return (False, "Fail to create file by dd, cmd: %s" % dd_cmd)
+            try:
+                utils.system(dd_cmd)
+            except error.CmdError, e:
+                return failure
 
         # only capture the new tcp port after offload setup
         original_tcp_ports = re.findall("tcp.*:(\d+).*%s" % guest_ip,
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux