From patchwork Tue Sep 29 20:04:27 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 50594 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8TK8Jjg029657 for ; Tue, 29 Sep 2009 20:08:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753716AbZI2UIJ (ORCPT ); Tue, 29 Sep 2009 16:08:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753494AbZI2UII (ORCPT ); Tue, 29 Sep 2009 16:08:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1028 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752901AbZI2UIF (ORCPT ); Tue, 29 Sep 2009 16:08:05 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8TK89fx004897; Tue, 29 Sep 2009 16:08:09 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8TK88OY030754; Tue, 29 Sep 2009 16:08:09 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n8TK80Na003847; Tue, 29 Sep 2009 16:08:07 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 6/6] KVM test: kvm_subprocess: use select() in read_until_output_matches() Date: Tue, 29 Sep 2009 22:04:27 +0200 Message-Id: <1254254667-19385-6-git-send-email-mgoldish@redhat.com> In-Reply-To: <1254254667-19385-5-git-send-email-mgoldish@redhat.com> References: <1254254667-19385-1-git-send-email-mgoldish@redhat.com> <1254254667-19385-2-git-send-email-mgoldish@redhat.com> <1254254667-19385-3-git-send-email-mgoldish@redhat.com> <1254254667-19385-4-git-send-email-mgoldish@redhat.com> <1254254667-19385-5-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py index 730f20e..2ac062a 100755 --- a/client/tests/kvm/kvm_subprocess.py +++ b/client/tests/kvm/kvm_subprocess.py @@ -848,8 +848,12 @@ class kvm_expect(kvm_tail): match = None data = "" + fd = self._get_fd("expect") end_time = time.time() + timeout - while time.time() < end_time: + while True: + r, w, x = select.select([fd], [], [], + max(0, end_time - time.time())) + if fd not in r: break # Read data from child newdata = self.read_nonblocking(internal_timeout) # Print it if necessary @@ -868,7 +872,8 @@ class kvm_expect(kvm_tail): done = True # Check if child has died if not self.is_alive(): - logging.debug("Process terminated with status %s" % self.get_status()) + logging.debug("Process terminated with status %s" % + self.get_status()) done = True # Are we done? if done: break