2 files changed, 83 insertions(+), 1 deletion(-)
tools/xm-test/tests/create/17_create_cpusparm_pos.py | 81 ++++++++++++++++++
tools/xm-test/tests/create/Makefile.am | 3
# HG changeset patch
# User Ryan Harper <ryanh@xxxxxxxxxx>
# Date 1155579423 18000
# Node ID 734570be7e0592f20e6f97089c89541feed03abc
# Parent 7281c7aa89220b5bb20c9275a65dee37be6da298
Add testcase for multi-cpumask cpus parameter
diff -r 7281c7aa8922 -r 734570be7e05 tools/xm-test/tests/create/Makefile.am
--- a/tools/xm-test/tests/create/Makefile.am Mon Aug 14 13:16:30 2006 -0500
+++ b/tools/xm-test/tests/create/Makefile.am Mon Aug 14 13:17:03 2006 -0500
@@ -14,7 +14,8 @@ TESTS = 01_create_basic_pos.test \
13_create_multinic_pos.test \
14_create_blockroot_pos.test \
15_create_smallmem_pos.test \
- 16_create_smallmem_neg.test
+ 16_create_smallmem_neg.test \
+ 17_create_cpusparm_pos.py
EXTRA_DIST = $(TESTS)
diff -r 7281c7aa8922 -r 734570be7e05
tools/xm-test/tests/create/17_create_cpusparm_pos.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/create/17_create_cpusparm_pos.py Mon Aug 14
13:17:03 2006 -0500
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Authors: Dan Smith <danms@xxxxxxxxxx>
+# : Ryan Harper <ryanh@xxxxxxxxxx>
+#
+# This test will examine Xend's cpu/cpus parameter parsing ability. The cpus
+# parameter controls which physical cpus the domain's vcpus run upon. We can
+# set a single cpumask for all vcpus, or we can build up lists of cpumasks
+# to be applied individually. The test covers the following cases:
+#
+# single vcpu tests
+# multi-vcpu tests using same values
+# multi-vcpu tests using differing values per-vcpu
+# multi-vcpu tests as above, list notation
+#
+# format: (#vcpus, cpus= value, list of resulting affinity values)
+cpu_strings=[ (2, '0', ["0", "0"]),
+ (2, '1', ["1", "1"]),
+ (2, '0|1', ["0", "1"]),
+ (2, '1|0', ["1", "0"]),
+ (2, '0-1', ["0-1", "0-1"]),
+ (2, '[0]', ["0", "0"]),
+ (2, '[1]', ["1", "1"]),
+ (2, '[0, 1]', ["0", "1"]),
+ (2, '[1, 0]', ["1", "0"]),
+ (2, '["0-1"]', ["0-1", "0-1"]),
+ (2, '["0-1,^1"]', ["0", "0"]),
+ (4, '0', ["0", "0", "0", "0"]),
+ (4, '1', ["1", "1", "1", "1"]),
+ (4, '0|1|2|3', ["0", "1", "2", "3"]),
+ (4, '1,3|0,2|0|0-3', ["1,3", "0,2", "0", "0-3"]),
+ (4, '[0]', ["0", "0", "0", "0"]),
+ (4, '[1]', ["1", "1", "1", "1"]),
+ (4, '[0, 1, 2, 3]', ["0", "1", "2", "3"]),
+ (4, '["1,3", "0,2", "0", "0-3"]', ["1,3", "0,2", "0", "0-3"]) ]
+
+
+
+from XmTestLib import *
+
+
+# Verify that we can run this test on this host
+min_smplevel = min(map(lambda (x,y,z): x, cpu_strings))
+cpus = smpConcurrencyLevel()
+if len(filter(lambda (x,y,z): x<=cpus, cpu_strings)) < 1:
+ print "*** NOTE: This machine does not have enough logical processors"
+ print " to run this test properly. Retry on a machine that"
+ print " has at least %s logical processors." %(min_smplevel)
+ SKIP("Host not capable of running test")
+
+
+# for each test string, start up the domain and then examine vcpuinfo to
+# determine whether the affinity value for a particular vcpu was correct.
+# filter out tests that the host can't run
+for (x,y,z) in filter(lambda (x,y,z): x<=cpus, cpu_strings):
+ # we have to work around extraConfig adding leading double quotes
+ y = y.replace("\"", "'")
+ domain = XmTestDomain(extraConfig={"vcpus": x, "cpus": y})
+
+ #kick off domain
+ try:
+ console = domain.start()
+ except DomainError, e:
+ FAIL("Unable to start a domain with vcpus=%s cpus=%s"%(x, y))
+
+ # get vcpuinfo on the domain's vcpus.
+ vcpuinfo = getVcpuInfo(domain.getName())
+
+ # for each vcpu, check the affinity value
+ for a in range(0,x):
+
+ # if the host smp level is equal to required level, then the resulting
+ # affinity value is truncated to 'any cpu' by xend, if we fail to match
+ # we also check if we can match with 'any cpu'
+ if vcpuinfo[a]['affinity'] != z[a] and \
+ (cpus == x and vcpuinfo[a]['affinity'] != "any cpu"):
+ FAIL("Failed to set VCPU affinity for cpus=%s ([%s] != [%s])"%(
+ y, vcpuinfo[a]['affinity'], z[a]))
+
+ domain.destroy()
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|