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 | # if extratime is off, turn it on and drop slice to 0 |
---|
35 | if str(e) == "0": |
---|
36 | extratime = 1 |
---|
37 | opts = "%s -e %s" %(domain.getName(), extratime) |
---|
38 | (status, output) = traceCommand("xm sched-sedf %s" %(opts)) |
---|
39 | |
---|
40 | # check rv |
---|
41 | if status != 0: |
---|
42 | FAIL("Failed to force extratime on (%d)" % status) |
---|
43 | |
---|
44 | # drop slice to 0 now that we are in extratime mode |
---|
45 | slice = 0 |
---|
46 | |
---|
47 | opts = "%s -s %s" %(domain.getName(), slice) |
---|
48 | (status, output) = traceCommand("xm sched-sedf %s" %(opts)) |
---|
49 | |
---|
50 | # check rv |
---|
51 | if status != 0: |
---|
52 | FAIL("Failed to force slice to 0 (%d)" % status) |
---|
53 | |
---|
54 | |
---|
55 | # ASSERT(extratime=1, slice=0) |
---|
56 | |
---|
57 | # attempt to disable extratime without setting slice |
---|
58 | extratime = "0" |
---|
59 | |
---|
60 | opts = "%s -e %s " %(domain.getName(), extratime) |
---|
61 | (status, output) = traceCommand("xm sched-sedf %s" %(opts)) |
---|
62 | |
---|
63 | # we should see this output from xm |
---|
64 | eyecatcher = "Failed to set sedf parameters" |
---|
65 | |
---|
66 | # check for failure |
---|
67 | if output.find(eyecatcher) >= 0: |
---|
68 | FAIL("sched-sedf let me disable extratime without a non-zero slice") |
---|
69 | |
---|
70 | # Stop the domain (nice shutdown) |
---|
71 | domain.stop() |
---|