WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XM-TEST] Improve detection of a guest ha

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XM-TEST] Improve detection of a guest having booted to prompt.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Jun 2006 15:01:29 +0000
Delivery-date: Tue, 20 Jun 2006 08:03:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 410c81420109918fa9ebeac3a350a9d13ccf463f
# Parent  06afd218b3b78c291fb7b18fa3076293c0689700
[XM-TEST] Improve detection of a guest having booted to prompt.

Lots of xm-test tests are failing with console timeouts on some machines
at the moment.  I reproduced the problem and found it was due to some
probing activity in the boot process of the -xen kernel.  The behaviour
of the current xm-test code is to assume that the boot process has
finished after performing three one-second waits for input---when the
probing activity introduces more than three one-second delays the test
suite breaks.

This patch changes the test suite to wait for the command prompt
before attempting to submit a command.  The timeout is increased from 3
seconds to 3 minutes but the wait exits early when the prompt is found
so the test suite doesn't take any longer to run.

Signed-off-by: Harry Butterworth <butterwo@xxxxxxxxxx>
---
 tools/xm-test/lib/XmTestLib/Console.py |   70 ++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 30 deletions(-)

diff -r 06afd218b3b7 -r 410c81420109 tools/xm-test/lib/XmTestLib/Console.py
--- a/tools/xm-test/lib/XmTestLib/Console.py    Mon Jun 19 17:26:54 2006 +0100
+++ b/tools/xm-test/lib/XmTestLib/Console.py    Mon Jun 19 17:43:04 2006 +0100
@@ -82,9 +82,6 @@ class XmConsole:
 
         tty.setraw(self.consoleFd, termios.TCSANOW)
 
-        self.__chewall(self.consoleFd)
-
-
     def __addToHistory(self, line):
         self.historyBuffer.append(line)
         self.historyLines += 1
@@ -120,34 +117,47 @@ class XmConsole:
         output"""
         self.PROMPT = prompt
 
-
-    def __chewall(self, fd):
+    def __getprompt(self, fd):
         timeout = 0
-        bytes   = 0
-        
-        while timeout < 3:
-            i, o, e = select.select([fd], [], [], 1)
-            if fd in i:
-                try:
-                    foo = os.read(fd, 1)
-                    if self.debugMe:
-                        sys.stdout.write(foo)
-                    bytes += 1
-                except Exception, exn:
-                    raise ConsoleError(str(exn))
-
-            else:
-                timeout += 1
-
-            if self.limit and bytes >= self.limit:
+        bytes = 0
+        while timeout < 180:
+            # eat anything while total bytes less than limit else raise RUNAWAY
+            while (not self.limit) or (bytes < self.limit):
+                i, o, e = select.select([fd], [], [], 1)
+                if fd in i:
+                    try:
+                        foo = os.read(fd, 1)
+                        if self.debugMe:
+                            sys.stdout.write(foo)
+                        bytes += 1
+                    except Exception, exn:
+                        raise ConsoleError(str(exn))
+                else:
+                    break
+            else:
                 raise ConsoleError("Console run-away (exceeded %i bytes)"
                                    % self.limit, RUNAWAY)
-
-        if self.debugMe:
-            print "Ignored %i bytes of miscellaneous console output" % bytes
-        
-        return bytes
-
+            # press enter
+            os.write(self.consoleFd, "\n")
+            # look for prompt
+            for prompt_char in "\r\n" + self.PROMPT:
+                i, o, e = select.select([fd], [], [], 1)
+                if fd in i:
+                    try:
+                        foo = os.read(fd, 1)
+                        if self.debugMe:
+                            sys.stdout.write(foo)
+                        if foo != prompt_char:
+                            break
+                    except Exception, exn:
+                        raise ConsoleError(str(exn))
+                else:
+                    timeout += 1
+                    break
+            else:
+                break
+        else:
+            raise ConsoleError("Timed out waiting for console prompt")
 
     def __runCmd(self, command, saveHistory=True):
         output = ""
@@ -155,7 +165,7 @@ class XmConsole:
         lines  = 0
         bytes  = 0
 
-        self.__chewall(self.consoleFd)
+        self.__getprompt(self.consoleFd)
 
         if verbose:
             print "[%s] Sending `%s'" % (self.domain, command)
@@ -176,7 +186,7 @@ class XmConsole:
                         "Failed to read from console (fd=%i): %s" %
                         (self.consoleFd, exn))
             else:
-                raise ConsoleError("Timed out waiting for console")
+                raise ConsoleError("Timed out waiting for console command")
 
             if self.limit and bytes >= self.limit:
                 raise ConsoleError("Console run-away (exceeded %i bytes)"

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XM-TEST] Improve detection of a guest having booted to prompt., Xen patchbot-unstable <=