From: Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: ethtool subtest: Check failure on dd executed on guest Date: Tue, 11 Jan 2011 02:17:18 -0200 Message-ID: <1294719438-16520-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: autotest@test.kernel.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org 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 Signed-off-by: Lucas Meneghel Rodrigues --- 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