1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright (C) International Business Machines Corp., 2005 |
---|
4 | # Author: Dan Smith <danms@us.ibm.com> |
---|
5 | # Author: Ryan Harper <ryanh@us.ibm.com> |
---|
6 | |
---|
7 | from XmTestLib import * |
---|
8 | |
---|
9 | def get_sedf_params(domain): |
---|
10 | status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) |
---|
11 | return (status, output.split('\n')[1].split()) |
---|
12 | |
---|
13 | |
---|
14 | domain = XmTestDomain(extraConfig = {"sched":"sedf"}) |
---|
15 | |
---|
16 | try: |
---|
17 | domain.start(noConsole=True) |
---|
18 | except DomainError, e: |
---|
19 | if verbose: |
---|
20 | print "Failed to create test domain because:" |
---|
21 | print e.extra |
---|
22 | FAIL(str(e)) |
---|
23 | |
---|
24 | # get current param values as baseline |
---|
25 | (status, params) = get_sedf_params(domain) |
---|
26 | |
---|
27 | # check rv |
---|
28 | if status != 0: |
---|
29 | FAIL("Getting sedf parameters return non-zero rv (%d)", status) |
---|
30 | |
---|
31 | # parse out current params |
---|
32 | (name, domid, p, s, l, e, w) = params |
---|
33 | |
---|
34 | # NB: setting period requires non-zero slice |
---|
35 | # scale current period in half |
---|
36 | period = str(float(p) / 2) |
---|
37 | slice = str(float(p) / 4) |
---|
38 | |
---|
39 | opts = "%s -p %s -s %s" %(domain.getName(), period, slice) |
---|
40 | (status, output) = traceCommand("xm sched-sedf %s" %(opts)) |
---|
41 | |
---|
42 | # check rv |
---|
43 | if status != 0: |
---|
44 | FAIL("Setting sedf parameters return non-zero rv (%d)" % status) |
---|
45 | |
---|
46 | # validate |
---|
47 | (s,params) = get_sedf_params(domain) |
---|
48 | |
---|
49 | # check rv |
---|
50 | if s != 0: |
---|
51 | FAIL("Getting sedf parameters return non-zero rv (%d)" % s) |
---|
52 | |
---|
53 | (name,domid,p1,s1,l1,e1,w1) = params |
---|
54 | |
---|
55 | if p1 != period: |
---|
56 | FAIL("Failed to change domain period from %f to %f" %(p, period)) |
---|
57 | |
---|
58 | if s1 != slice: |
---|
59 | FAIL("Failed to change domain slice from %f to %f" %(s, slice)) |
---|
60 | |
---|
61 | # Stop the domain (nice shutdown) |
---|
62 | domain.stop() |
---|