debuggers.hg

view tools/xm-test/tests/memset/03_memset_random_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 b22f9ab1716a
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Author: Dan Smith <danms@us.ibm.com>
6 import random
7 import re
9 from XmTestLib import *
11 if ENABLE_HVM_SUPPORT:
12 SKIP("Mem-set not supported for HVM domains")
14 domain = XmTestDomain()
16 try:
17 console = domain.start()
18 except DomainError, e:
19 if verbose:
20 print "Failed to start domain:"
21 print e.extra
22 FAIL(str(e))
24 times = random.randint(10,50)
26 try:
27 run = console.runCmd("cat /proc/xen/balloon | grep Current");
28 except ConsoleError, e:
29 FAIL(str(e))
31 match = re.match("[^0-9]+([0-9]+)", run["output"])
32 if not match:
33 FAIL("Invalid domU meminfo line")
35 origmem = int(match.group(1)) / 1024
36 currmem = origmem
38 for i in range(0,times):
39 amt = random.randint(-10,10)
41 target = currmem + amt
43 # Make sure we're not going over or under
44 if target < domain.minSafeMem():
45 continue
46 if target > origmem:
47 continue
49 if verbose:
50 print "[%i/%i] Current: %i Target: %i" % (i, times, currmem, target)
52 cmd = "xm mem-set %s %i" % (domain.getName(), target)
53 status, output = traceCommand(cmd)
55 if status != 0:
56 if verbose:
57 print "mem-set failed:"
58 print output
59 FAIL("mem-set from %i to %i failed" % (currmem, target))
61 try:
62 run = console.runCmd("cat /proc/xen/balloon | grep Current");
63 except ConsoleError, e:
64 FAIL(str(e))
66 match = re.match("[^0-9]+([0-9]+)", run["output"])
67 if not match:
68 FAIL("Invalid domU meminfo line")
70 domUmem = int(match.group(1)) / 1024
72 currmem = target
73 actual = int(getDomInfo(domain.getName(), "Mem"))
75 if actual != currmem:
76 FAIL("Expected %i MB, xm reported %i MB" % (currmem, actual))
77 if domUmem != currmem:
78 FAIL("Expected %i MB, domU reported %i MB" % (currmem, domUmem))