From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [PATCH v2 5/5] xl: test script for the cpumap parser (for vCPU pinning) Date: Fri, 06 Sep 2013 17:56:01 +0200 Message-ID: <20130906155600.10218.27695.stgit@hit-nxdomain.opendns.com> References: <20130906154725.10218.45008.stgit@hit-nxdomain.opendns.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130906154725.10218.45008.stgit@hit-nxdomain.opendns.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: George Dunlap , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org This commit introduces "check-xl-vcpupin-parse" for helping verifying and debugging the (v)CPU bitmap parsing code in xl. The script runs "xl -N vcpu-pin 0 all " repeatedly, with various input strings, and checks that the output is as expected. This is an example run (on a 2 NUMA nodes and 16 vCPUs host): # ./check-xl-vcpupin-parse WARNING: some of these tests are topology based tests. Expect failures if the topology is not detected correctly detected topology: 16 CPUs, 2 nodes, 8 CPUs per node test case foo... Testing the 'all' syntax: test case all... test case nodes:all... test case all,nodes:all... test case all,^nodes:0,all... Testing the empty cpumap case: test case ^0... A few attempts of pinning to just one random cpu: test case 15... test case 5... test case 4... test case 8... A few attempts of pinning to all but one random cpu: test case all,^5... test case all,^1... test case all,^9... test case all,^8... A few attempts of pinning to a random range of cpus: test case 12-15... test case 6-14... test case 13-14... test case 4-11... A few attempts of pinning to just one random node: test case nodes:0... test case nodes:0... test case nodes:0... test case nodes:1... A few attempts of pinning to all but one random node: test case all,^nodes:1... test case all,^nodes:0... test case all,^nodes:1... test case all,^nodes:1... A few attempts of pinning to a random range of nodes: test case nodes:0-1... test case nodes:0-1... test case nodes:0-1... test case nodes:1-1... A few attempts of pinning to a node but excluding one random cpu: test case nodes:1,^11... test case nodes:1,^15... test case nodes:1,^8... test case nodes:0,^2... all ok. Signed-off-by: Dario Faggioli --- Changes from v1: * this was not there in v1, and adding it has been requested during review. --- tools/libxl/check-xl-vcpupin-parse | 229 ++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100755 tools/libxl/check-xl-vcpupin-parse diff --git a/tools/libxl/check-xl-vcpupin-parse b/tools/libxl/check-xl-vcpupin-parse new file mode 100755 index 0000000..af9b8d8 --- /dev/null +++ b/tools/libxl/check-xl-vcpupin-parse @@ -0,0 +1,229 @@ +#!/bin/bash + +set -e + +if [ -x ./xl ] ; then + export LD_LIBRARY_PATH=.:../libxc:../xenstore:../blktap2/control + XL=./xl +else + XL=xl +fi + +fprefix=tmp.check-xl-vcpupin-parse + +expected () { + cat >$fprefix.expected +} + +failures=0 + +one () { + expected_rc=$1; shift + printf "test case %s...\n" "$*" + set +e + ${XL} -N vcpu-pin 0 all "$@" $fprefix.actual 2>/dev/null + actual_rc=$? + diff -u $fprefix.expected $fprefix.actual + diff_rc=$? + set -e + if [ $actual_rc != $expected_rc ] || [ $diff_rc != 0 ]; then + echo >&2 "test case \`$*' failed ($actual_rc $diff_rc)" + failures=$(( $failures + 1 )) + fi +} + +complete () { + if [ "$failures" = 0 ]; then + echo all ok.; exit 0 + else + echo "$failures tests failed."; exit 1 + fi +} + +e=255 + + +#---------- test data ---------- +# + +echo "WARNING: some of these tests are topology based tests." +echo "Expect failures if the topology is not detected correctly" +nr_cpus=`xl info | grep nr_cpus | cut -f2 -d':'` +nr_nodes=`xl info | grep nr_nodes | cut -f2 -d':'` +nr_cpus_per_node=`xl info -n | sed '/cpu:/,/numa_info/!d' | head -n -1 | \ + awk '{print $4}' | uniq -c | tail -1 | awk '{print $1}'` +echo "detected topology: $nr_cpus CPUs, $nr_nodes nodes, $nr_cpus_per_node CPUs per node" + +expected