ia64/xen-unstable

changeset 10111:ea609f28ec01

The enforce_dom0_cpus test sets the number of vcpus for the Dom0 and
checks to see if they have been set correctly. We found that on
multi-proc systems, it takes a certain amount of time for the number of
vcpus to change.

This patch checks the number of vcpus inside a loop until it is correct
or 20 seconds elapse, whichever happens first. If after 20 seconds the
number of vcpus is not changed correctly, an error is raised.

Signed-off-by: Rajagopalan Subrahmanian <raj.subrahmanian@unisys.com>
author emellor@leeni.uk.xensource.com
date Fri May 19 16:21:43 2006 +0100 (2006-05-19)
parents 167790b102ac
children 33b2ae024663
files tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
line diff
     1.1 --- a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py	Fri May 19 15:52:35 2006 +0100
     1.2 +++ b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py	Fri May 19 16:21:43 2006 +0100
     1.3 @@ -65,13 +65,24 @@ if check_status and status != 0:
     1.4          FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
     1.5  
     1.6  # 5) check /proc/cpuinfo for cpu count
     1.7 -cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
     1.8 -status, output = traceCommand(cmd)
     1.9 -if check_status and status != 0:
    1.10 -    os.unsetenv("XEND_CONFIG")
    1.11 -    restartXend()
    1.12 -    FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
    1.13  
    1.14 +# It takes some time for the CPU count to change, on multi-proc systems, so check the number of procs in a loop for 20 seconds. 
    1.15 +#Sleep inside the loop for a second each time.
    1.16 +timeout = 20
    1.17 +starttime = time.time()
    1.18 +while timeout + starttime > time.time():
    1.19 +# Check /proc/cpuinfo
    1.20 +    cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
    1.21 +    status, output = traceCommand(cmd)
    1.22 +    if check_status and status != 0:
    1.23 +        os.unsetenv("XEND_CONFIG")
    1.24 +        restartXend()
    1.25 +        FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
    1.26 +# Has it succeeded? If so, we can leave the loop
    1.27 +    if output == str(enforce_dom0_cpus):
    1.28 +        break
    1.29 +# Sleep for 1 second before trying again
    1.30 +    time.sleep(1)
    1.31  if output != str(enforce_dom0_cpus):
    1.32      os.unsetenv("XEND_CONFIG")
    1.33      restartXend()
    1.34 @@ -94,7 +105,14 @@ if check_status and status != 0:
    1.35      FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
    1.36  
    1.37  # check restore worked
    1.38 -num_online = int(getDomInfo("Domain-0", "VCPUs"))
    1.39 +# Since this also takes time, we will do it in a loop with a 20 second timeout.
    1.40 +timeout=20
    1.41 +starttime=time.time()
    1.42 +while timeout + starttime > time.time(): 
    1.43 +    num_online = int(getDomInfo("Domain-0", "VCPUs"))
    1.44 +    if num_online == dom0_online_vcpus:
    1.45 +        break
    1.46 +    time.sleep(1)
    1.47  if num_online != dom0_online_vcpus:
    1.48      os.unsetenv("XEND_CONFIG")
    1.49      restartXend()