aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-07-29 09:20:46 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-07-29 09:20:46 +0100
commit41859f692541d9ee99d9033166de2e5d3cac41b1 (patch)
treefb44a7b8077ea6b8654fc03b8b6faa2527bd2e3f /tools/xm-test
parentd0c233bbf877e7424fc9a52a69a8af155572bf2f (diff)
downloadxen-41859f692541d9ee99d9033166de2e5d3cac41b1.tar.gz
xen-41859f692541d9ee99d9033166de2e5d3cac41b1.tar.bz2
xen-41859f692541d9ee99d9033166de2e5d3cac41b1.zip
xm-test: Fix memset 01 and 02 tests: add support for sysfs memory interface
From: Andreas Florath <xen@flonatel.org> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/xm-test')
-rw-r--r--tools/xm-test/lib/XmTestLib/XenMemory.py68
-rw-r--r--tools/xm-test/lib/XmTestLib/__init__.py1
-rw-r--r--tools/xm-test/lib/XmTestLib/arch.py1
-rw-r--r--tools/xm-test/tests/memset/01_memset_basic_pos.py25
-rw-r--r--tools/xm-test/tests/memset/03_memset_random_pos.py24
5 files changed, 77 insertions, 42 deletions
diff --git a/tools/xm-test/lib/XmTestLib/XenMemory.py b/tools/xm-test/lib/XmTestLib/XenMemory.py
new file mode 100644
index 0000000000..e8da5ebbe3
--- /dev/null
+++ b/tools/xm-test/lib/XmTestLib/XenMemory.py
@@ -0,0 +1,68 @@
+"""
+ XenMemory.py - grep memory from domU
+
+ This module can handle the /proc/xen/balloon as well as the sysfs
+ memory interface.
+
+ Copyright (C) flonatel GmbH & Co. KG, 2009
+ Author: Andreas Florath
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; under version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+import os
+
+from Test import *
+
+class XenMemory:
+
+ def __init__(self, console):
+ self.console = console
+ self.sysfs_mem_dir = "/sys/devices/system/xen_memory/xen_memory0"
+
+ try:
+ res = self.console.runCmd("ls " + self.sysfs_mem_dir)
+ self.use_sysfs = res['return'] == 0
+ except ConsoleError, e:
+ FAIL(str(e))
+
+
+ def get_mem_from_domU_sysfs(self):
+ try:
+ run = self.console.runCmd(
+ "cat " + os.path.join(self.sysfs_mem_dir, "info/current_kb"))
+ except ConsoleError, e:
+ FAIL(str(e))
+
+ return int(run["output"]) / 1024
+
+ def get_mem_from_domU_balloon(self):
+ try:
+ run = self.console.runCmd("cat /proc/xen/balloon | grep Current");
+ except ConsoleError, e:
+ FAIL(str(e))
+
+ match = re.match("^Current allocation:\s+(\d+)\skB", run["output"])
+ if not match:
+ FAIL("Invalid domU meminfo line")
+
+ return int(match.group(1)) / 1024
+
+ # Prefer sysfs interface
+ def get_mem_from_domU(self):
+ if self.use_sysfs:
+ return self.get_mem_from_domU_sysfs()
+ else:
+ return self.get_mem_from_domU_balloon()
+
diff --git a/tools/xm-test/lib/XmTestLib/__init__.py b/tools/xm-test/lib/XmTestLib/__init__.py
index 40aacf7ecd..1aa7afe634 100644
--- a/tools/xm-test/lib/XmTestLib/__init__.py
+++ b/tools/xm-test/lib/XmTestLib/__init__.py
@@ -10,6 +10,7 @@ from XenDomain import *
from config import *
from XenDevice import *
from NetConfig import *
+from XenMemory import *
# Give this test a clean slate
destroyAllDomUs()
diff --git a/tools/xm-test/lib/XmTestLib/arch.py b/tools/xm-test/lib/XmTestLib/arch.py
index a6607d91db..d505cc0ac1 100644
--- a/tools/xm-test/lib/XmTestLib/arch.py
+++ b/tools/xm-test/lib/XmTestLib/arch.py
@@ -70,7 +70,6 @@ ia_ParavirtDefaults = {"memory" : 64,
"kernel" : ia_getDefaultKernel(),
"root" : "/dev/ram0",
"ramdisk" : getRdPath() + "/initrd.img",
- "extra" : "console=xvc0",
}
ia_HVMDefaults = {"memory" : 64,
"vcpus" : 1,
diff --git a/tools/xm-test/tests/memset/01_memset_basic_pos.py b/tools/xm-test/tests/memset/01_memset_basic_pos.py
index 1eb81b5c2f..7e769307ea 100644
--- a/tools/xm-test/tests/memset/01_memset_basic_pos.py
+++ b/tools/xm-test/tests/memset/01_memset_basic_pos.py
@@ -40,17 +40,10 @@ try:
console.runCmd("ls")
except ConsoleError, e:
FAIL(str(e))
-
-try:
- run = console.runCmd("cat /proc/xen/balloon | grep Current");
-except ConsoleError, e:
- FAIL(str(e))
-match = re.match("[^0-9]+([0-9]+)", run["output"])
-if not match:
- FAIL("Invalid domU meminfo line")
-
-origmem = int(match.group(1)) / 1024
+xen_mem = XenMemory(console)
+
+origmem = xen_mem.get_mem_from_domU()
newmem = origmem - 1
# set mem-set for less than default
@@ -76,17 +69,7 @@ elif mem != newmem:
FAIL("Dom0 failed to verify %i MB; got %i MB" % newmem,mem)
# verify memory set internally
-try:
- run = console.runCmd("cat /proc/xen/balloon | grep Current")
-except ConsoleError, e:
- FAIL(str(e))
-
-# Check the output of 'cat /proc/xen/balloon'
-m = re.match("^Current allocation:\s+(\d+)\skB", run["output"])
-if not m:
- FAIL("The DomU command 'cat /proc/xen/balloon' failed.")
-
-domUmem = int(m.group(1)) / 1024
+domUmem = xen_mem.get_mem_from_domU()
if domUmem != newmem:
FAIL("DomU reported incorrect memory amount: %i MB" % (domUmem))
diff --git a/tools/xm-test/tests/memset/03_memset_random_pos.py b/tools/xm-test/tests/memset/03_memset_random_pos.py
index f5393a4090..25937019b1 100644
--- a/tools/xm-test/tests/memset/03_memset_random_pos.py
+++ b/tools/xm-test/tests/memset/03_memset_random_pos.py
@@ -23,16 +23,9 @@ except DomainError, e:
times = random.randint(10,50)
-try:
- run = console.runCmd("cat /proc/xen/balloon | grep Current");
-except ConsoleError, e:
- FAIL(str(e))
+xen_mem = XenMemory(console)
-match = re.match("[^0-9]+([0-9]+)", run["output"])
-if not match:
- FAIL("Invalid domU meminfo line")
-
-origmem = int(match.group(1)) / 1024
+origmem = xen_mem.get_mem_from_domU()
currmem = origmem
for i in range(0,times):
@@ -57,17 +50,8 @@ for i in range(0,times):
print "mem-set failed:"
print output
FAIL("mem-set from %i to %i failed" % (currmem, target))
-
- try:
- run = console.runCmd("cat /proc/xen/balloon | grep Current");
- except ConsoleError, e:
- FAIL(str(e))
-
- match = re.match("[^0-9]+([0-9]+)", run["output"])
- if not match:
- FAIL("Invalid domU meminfo line")
-
- domUmem = int(match.group(1)) / 1024
+
+ domUmem = xen_mem.get_mem_from_domU()
currmem = target
actual = int(getDomInfo(domain.getName(), "Mem"))