ia64/xen-unstable

changeset 13351:7fd4e256196b

Update sched-credit test to match new format from xm sched-credit.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Jan 09 17:38:48 2007 +0000 (2007-01-09)
parents 56e2341f02c4
children 51fd5bdc2744
files tools/xm-test/tests/sched-credit/01_sched_credit_weight_cap_pos.py
line diff
     1.1 --- a/tools/xm-test/tests/sched-credit/01_sched_credit_weight_cap_pos.py	Tue Jan 09 17:25:28 2007 +0000
     1.2 +++ b/tools/xm-test/tests/sched-credit/01_sched_credit_weight_cap_pos.py	Tue Jan 09 17:38:48 2007 +0000
     1.3 @@ -2,14 +2,27 @@
     1.4  #
     1.5  # Sched-credit tests modified from SEDF tests
     1.6  #
     1.7 +
     1.8 +import re
     1.9 +
    1.10  from XmTestLib import *
    1.11  
    1.12 +paramsRE = re.compile(r'^[^ ]* *[^ ]* *([^ ]*) *([^ ]*)$')
    1.13 +
    1.14  def get_sched_credit_params(domain):
    1.15 -    status, output = traceCommand("xm sched-credit -d %s" %(domain.getName()))
    1.16 -    params = output.strip('{}').split(', ')
    1.17 -    cap = int(params[0].split(':')[1].strip(' '))
    1.18 -    weight = int(params[1].split(':')[1].strip(' '))
    1.19 -    return (status, (weight, cap))
    1.20 +    status, output = traceCommand("xm sched-credit -d %s | tail -1" %
    1.21 +                                  domain.getName())
    1.22 +
    1.23 +    if status != 0:
    1.24 +        FAIL("Getting sched-credit parameters return non-zero rv (%d)",
    1.25 +             status)
    1.26 +
    1.27 +    m = paramsRE.match(output)
    1.28 +    if not m:
    1.29 +        FAIL("xm sched-credit gave bad output")
    1.30 +    weight = int(m.group(1))
    1.31 +    cap = int(m.group(2))
    1.32 +    return (weight, cap)
    1.33  
    1.34  def set_sched_credit_weight(domain, weight):
    1.35      status, output = traceCommand("xm sched-credit -d %s -w %d" %(domain.getName(), weight))
    1.36 @@ -31,11 +44,8 @@ except DomainError, e:
    1.37      FAIL(str(e))
    1.38  
    1.39  # check default param values
    1.40 -(status, params) = get_sched_credit_params(domain)
    1.41 -if status != 0:
    1.42 -    FAIL("Getting sched-credit parameters return non-zero rv (%d)", status)
    1.43 +(weight, cap) = get_sched_credit_params(domain)
    1.44  
    1.45 -(weight, cap) = params
    1.46  if weight != 256:
    1.47      FAIL("default weight is 256 (got %d)", weight)
    1.48  if cap != 0:
    1.49 @@ -51,11 +61,8 @@ if status != 0:
    1.50      FAIL("Setting sched-credit cap return non-zero rv (%d)", status)
    1.51  
    1.52  # check new param values
    1.53 -(status, params) = get_sched_credit_params(domain)
    1.54 -if status != 0:
    1.55 -    FAIL("Getting sched-credit parameters return non-zero rv (%d)", status)
    1.56 +(weight, cap) = get_sched_credit_params(domain)
    1.57  
    1.58 -(weight, cap) = params
    1.59  if weight != 512:
    1.60      FAIL("expected weight of 512 (got %d)", weight)
    1.61  if cap != 100: