WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 3 of 5] Add testcase for multi-cpumask cpus parameter

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 3 of 5] Add testcase for multi-cpumask cpus parameter
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Wed, 16 Aug 2006 15:49:37 -0500
Delivery-date: Wed, 16 Aug 2006 13:53:15 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1155761374@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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