From patchwork Sat Nov 27 17:56:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 361562 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oARHuoVL008838 for ; Sat, 27 Nov 2010 17:56:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753178Ab0K0R4n (ORCPT ); Sat, 27 Nov 2010 12:56:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39217 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706Ab0K0R4n (ORCPT ); Sat, 27 Nov 2010 12:56:43 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oARHugaD016503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 27 Nov 2010 12:56:42 -0500 Received: from freedom.redhat.com (vpn-10-239.rdu.redhat.com [10.11.10.239]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oARHuXAV028360; Sat, 27 Nov 2010 12:56:40 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 4/4] KVM test: ksm_overcommit: Trap PexpectTimeoutErrors Date: Sat, 27 Nov 2010 15:56:31 -0200 Message-Id: <1290880591-9580-4-git-send-email-lmr@redhat.com> In-Reply-To: <1290880591-9580-1-git-send-email-lmr@redhat.com> References: <1290880591-9580-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 27 Nov 2010 17:56:50 +0000 (UTC) diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py index f60929e..deadda1 100644 --- a/client/tests/kvm/tests/ksm_overcommit.py +++ b/client/tests/kvm/tests/ksm_overcommit.py @@ -27,12 +27,13 @@ def run_ksm_overcommit(test, params, env): """ logging.debug("Starting allocator.py on guest %s", vm.name) session.sendline("python /tmp/allocator.py") - (match, data) = session.read_until_last_line_matches(["PASS:", "FAIL:"], - timeout) - if match != 0: - raise error.TestFail("Command allocator.py on guest %s failed.\n" - "return code: %s\n output:\n%s" % - (vm.name, match, data)) + try: + (match, data) = session.read_until_last_line_matches( + ["PASS:", "FAIL:"], + timeout) + except kvm_subprocess.ExpectProcessTerminatedError, e: + raise error.TestFail("Command allocator.py on vm '%s' failed: %s" % + (vm.name, str(e))) def _execute_allocator(command, vm, session, timeout): @@ -50,12 +51,14 @@ def run_ksm_overcommit(test, params, env): logging.debug("Executing '%s' on allocator.py loop, vm: %s, timeout: %s", command, vm.name, timeout) session.sendline(command) - (match, data) = session.read_until_last_line_matches(["PASS:","FAIL:"], + try: + (match, data) = session.read_until_last_line_matches( + ["PASS:","FAIL:"], timeout) - if match != 0: - raise error.TestFail("Failed to execute '%s' on allocator.py, " - "vm: %s, output:\n%s" % - (command, vm.name, data)) + except kvm_subprocess.ExpectProcessTerminatedError, e: + e_str = ("Failed to execute command '%s' on allocator.py, " + "vm '%s': %s" % (command, vm.name, str(e))) + raise error.TestFail(e_str) return (match, data)