From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues <lmr@redhat.com>
Subject: [PATCH 4/4] KVM test: ksm_overcommit: Trap PexpectTimeoutErrors
Date: Sat, 27 Nov 2010 15:56:31 -0200 [thread overview]
Message-ID: <1290880591-9580-4-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1290880591-9580-1-git-send-email-lmr@redhat.com>
On the KSM overcommit test, read_until_last_line_matches
is used, and now this function can raise an expect error.
Trap it accordingly.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/tests/ksm_overcommit.py | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
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)
--
1.7.2.3
prev parent reply other threads:[~2010-11-27 17:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-27 17:56 [PATCH 1/4] KVM test: kvm_subprocess: rename get_command_status_output() and friends Lucas Meneghel Rodrigues
2010-11-27 17:56 ` [PATCH 2/4] " Lucas Meneghel Rodrigues
2010-11-27 17:56 ` [PATCH 3/4] KVM test: kvm_subprocess: rename kvm_shell_session " Lucas Meneghel Rodrigues
2010-11-27 17:56 ` Lucas Meneghel Rodrigues [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290880591-9580-4-git-send-email-lmr@redhat.com \
--to=lmr@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox