ia64/xen-unstable

view tools/xm-test/tests/unpause/01_unpause_basic_pos.py @ 8069:3c21a174e8fc

Fix the unpause_basic test. The console will appear to have failed, given the
current Console.py API, because no bytes have come from it, but that's not a
failure -- an unpaused domain has no reason to output any more data. We need
to send a command to the domain before we can be sure whether it is alive or
dead, so move the FAIL call, allowing the console connection to throw
ConsoleError.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sat Nov 26 01:13:51 2005 +0000 (2005-11-26)
parents 40f3ce3516cb
children b67f9f21fd9c
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Author: Paul Larson <pl@us.ibm.com>
6 # Description:
7 # Positive Tests:
8 # Tests for xm unpause
9 # 1) Create domain, verify it's up with console
10 # 2) randomly pause and unpause the domain
11 # 3) unpause it one last time
12 # 4) verify it's still alive with console
14 import time
15 import commands
16 from random import *
18 from XmTestLib import *
20 # Create a domain (default XmTestDomain, with our ramdisk)
21 domain = XmTestDomain()
23 # Start it
24 try:
25 domain.start()
26 except DomainError, e:
27 if verbose:
28 print "Failed to create test domain because:"
29 print e.extra
30 FAIL(str(e))
32 # Attach a console to it
33 try:
34 console = XmConsole(domain.getName(), historySaveCmds=True)
35 except ConsoleError, e:
36 FAIL(str(e))
38 try:
39 # Activate the console
40 console.sendInput("foo")
41 # Make sure a command succeeds
42 run = console.runCmd("ls")
43 except ConsoleError, e:
44 FAIL(str(e))
46 # Close the console
47 console.closeConsole()
49 seed(time.time())
51 for i in range(100):
52 pauseit = randint(0,1)
53 if(pauseit):
54 # Pause the domain
55 status, output = traceCommand("xm pause %s" % domain.getName())
56 if status != 0:
57 FAIL("xm pause returned invalid %i != 0", status)
58 else:
59 # Unpause the domain
60 status, output = traceCommand("xm unpause %s" % domain.getName())
61 if status != 0:
62 FAIL("xm unpause returned invalud %i != 0", status)
65 # Make sure the domain is unpaused before we finish up
66 status, output = traceCommand("xm unpause %s" % domain.getName())
67 if status != 0:
68 FAIL("xm unpause returned invalid %i != 0", status)
70 # Are we still alive after all that?
71 try:
72 console = XmConsole(domain.getName(), historySaveCmds=True)
73 except ConsoleError, e:
74 pass
75 try:
76 run = console.runCmd("ls")
77 except ConsoleError, e:
78 FAIL(str(e))
80 # Close the console
81 console.closeConsole()
83 if run["return"] != 0:
84 FAIL("console failed to attach to supposedly unpaused domain")
86 # Stop the domain (nice shutdown)
87 domain.stop()