debuggers.hg

view tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Authors: Dan Smith <danms@us.ibm.com>
5 # Ryan Harper <ryanh@us.ibm.com>
7 # 1) Make sure we have a multi cpu system
8 # 2) Create a test domain with 2 VCPUs
9 # 3) Verify that both VCPUs are alive
10 # 4) Disable DOM VCPU1 by setting the VCPU count to 1
11 # 5) Assert that the VCPU has been disabled
12 # 6) Enable DOM VCPU1 (restore VCPU count to 2)
13 # 7) Assert that the VCPUs are both alive again
15 import sys
16 import re
17 import time
19 from XmTestLib import *
21 check_status = 1
22 max_tries = 10
24 def safecmd(cmd):
25 i=0
26 while i < max_tries:
27 status, output = traceCommand(cmd)
28 if status == 0:
29 break
30 i = i+1
31 # print "output: [%s]"%(output)
32 time.sleep(1)
33 return status, output
35 # Verify that we can run this test on this host
36 if smpConcurrencyLevel() <= 1:
37 print "*** NOTE: This machine does not have more than one physical"
38 print " or logical cpu. The vcpu-disable test cannot be run!"
39 SKIP("Host not capable of running test")
41 # Start a XmTestDomain with 2 VCPUs
42 domain = XmTestDomain(extraConfig={"vcpus":2})
44 try:
45 domain.start(noConsole=True)
46 except DomainError, e:
47 if verbose:
48 print "Failed to create test domain because:"
49 print e.extra
50 FAIL(str(e))
52 # Disable VCPU 1
53 cmd = "xm vcpu-set %s 1" % domain.getName()
54 status, output = safecmd(cmd)
55 if check_status and status != 0:
56 FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
58 # Wait for the change to become active
59 for i in [1,2,3,4,5,6,7,8,9,10]:
60 domUvcpu1 = getVcpuInfo(domain.getName())[1]
61 status, output = traceCommand("xm vcpu-list")
62 if domUvcpu1 is None:
63 break
64 time.sleep(1)
66 if domUvcpu1 is not None:
67 print "domUvcpu1: [%s] output: [%s]"%(domUvcpu1, output)
68 FAIL("failed to disable VCPU1")
70 # Enable VCPU 1
71 cmd = "xm vcpu-set %s 2" % domain.getName()
72 status, output = safecmd(cmd)
73 if check_status and status != 0:
74 FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
76 for i in [1,2,3,4,5,6,7,8,9,10]:
77 domUvcpu1 = getVcpuInfo(domain.getName())[1]
78 if domUvcpu1 is not None:
79 break
80 time.sleep(1)
82 domain.destroy()