From: Lucas Meneghel Rodrigues Subject: [PATCH] virt.tests.netstress_kill_guest: Workaround udev writing to serial Date: Wed, 7 Mar 2012 18:53:47 -0300 Message-ID: <1331157227-16445-1-git-send-email-lmr@redhat.com> Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues To: autotest@test.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:22032 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964997Ab2CGVyA (ORCPT ); Wed, 7 Mar 2012 16:54:00 -0500 Sender: kvm-owner@vger.kernel.org List-ID: On some Linux guests such as RHEL 6.2, it's common that when the succession of rmmods and modprobes happen, udev, SELinux and other platform software write messages directly to the serial, confusing aexpect. So let's write some code to work around this peculiarity, being more robust in handling these situations. Signed-off-by: Lucas Meneghel Rodrigues --- client/virt/tests/netstress_kill_guest.py | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/client/virt/tests/netstress_kill_guest.py b/client/virt/tests/netstress_kill_guest.py index 50eb0af..722169c 100644 --- a/client/virt/tests/netstress_kill_guest.py +++ b/client/virt/tests/netstress_kill_guest.py @@ -121,17 +121,29 @@ def run_netstress_kill_guest(test, params, env): os.kill(pid, signal.SIGCONT) + def send_cmd_safe(session_serial, cmd): + logging.debug("Sending command: %s", cmd) + session_serial.sendline(cmd) + got_prompt = False + while not got_prompt: + time.sleep(0.2) + session_serial.sendline() + try: + session_serial.read_up_to_prompt() + got_prompt = True + except aexpect.ExpectTimeoutError: + pass + + def netdriver_kill_problem(session_serial): modules = get_ethernet_driver(session_serial) logging.debug(modules) for _ in range(50): for module in modules: - session_serial.cmd("rmmod %s" % (module)) - time.sleep(0.2) + send_cmd_safe(session_serial, "rmmod %s" % module) for module in modules: - logging.debug("Sending command: modprobe %s", module) - session_serial.sendline("modprobe %s\n" % (module)) - time.sleep(0.2) + send_cmd_safe(session_serial, "modprobe %s" % module) + kill_and_check(vm) -- 1.7.7.6