secretschematest
libvirtd_test_scripts = \
- test_conf.sh \
- cpuset \
- define-dev-segfault \
- int-overflow \
libvirtd-fail \
libvirtd-pool \
- read-bufsiz \
- read-non-seekable \
- start \
- virsh-uriprecedence \
- vcpupin \
+ test_conf.sh \
virsh-all \
+ virsh-cpuset \
+ virsh-define-dev-segfault \
+ virsh-int-overflow \
virsh-optparse \
+ virsh-read-bufsiz \
+ virsh-read-non-seekable \
virsh-schedinfo \
+ virsh-start \
virsh-synopsis \
virsh-undefine \
+ virsh-uriprecedence \
+ virsh-vcpupin \
$(NULL)
if WITH_LIBVIRTD
+++ /dev/null
-#!/bin/sh
-# ensure that defining with an invalid vCPU cpuset elicits a diagnostic
-
-# Copyright (C) 2008-2009 Red Hat, Inc.
-
-# 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, either version 2 of the License, or
-# (at your option) any later version.
-
-# 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, see
-# <http://www.gnu.org/licenses/>.
-
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
-test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-fail=0
-
-# generate input
-$abs_top_builddir/tools/virsh --connect test:///default dumpxml 1 > xml || fail=1
-
-# require the presence of the string we'll transform
-grep '<vcpu placement' xml > /dev/null || fail=1
-
-sed "s/vcpu placement='static'>/vcpu cpuset='aaa'>/" xml > xml-invalid || fail=1
-
-# Require failure and a diagnostic.
-$abs_top_builddir/tools/virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1
-cat <<\EOF > exp || fail=1
-error: Failed to define domain from xml-invalid
-error: invalid argument: Failed to parse bitmap 'aaa'
-
-EOF
-compare exp out || fail=1
-
-(exit $fail); exit $fail
+++ /dev/null
-#!/bin/sh
-# Exercise a bug whereby defining a valid domain could kill libvirtd.
-# The bug can also be exercised with a simple define/dumpxml pair to virsh.
-
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
-test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-fail=0
-
-# Domain definition from Cole Robinson.
-cat <<\EOF > D.xml || fail=1
-<domain type='test'>
- <name>D</name>
- <uuid>aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82</uuid>
- <memory unit='KiB'>262144</memory>
- <currentMemory unit='KiB'>262144</currentMemory>
- <vcpu placement='static'>1</vcpu>
- <os>
- <type arch='i686' machine='pc'>hvm</type>
- <boot dev='cdrom'/>
- </os>
- <features>
- <acpi/>
- </features>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-kvm</emulator>
- <controller type='usb' index='0'/>
- <serial type='pty'>
- <target port='0'/>
- </serial>
- <serial type='pty'>
- <target port='1'/>
- </serial>
- <serial type='pty'>
- <target port='2'/>
- </serial>
- <parallel type='pty'>
- <target port='0'/>
- </parallel>
- <parallel type='pty'>
- <target port='1'/>
- </parallel>
- <parallel type='pty'>
- <target port='2'/>
- </parallel>
- <console type='pty'>
- <target type='serial' port='0'/>
- </console>
- <sound model='pcspk'/>
- <sound model='es1370'/>
- <memballoon model='virtio'/>
- </devices>
-</domain>
-EOF
-
-url=test:///default
-$abs_top_builddir/tools/virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1
-
-cat > exp <<EOF || fail=1
-Domain D defined from D.xml
-
-$(cat D.xml)
-
-EOF
-
-compare exp out || fail=1
-
-exit $fail
+++ /dev/null
-#!/bin/sh
-# Ensure that an invalid domain ID isn't interpreted as a valid one.
-# Before, an ID of 2^32+2 would be treated just like an ID of 2.
-
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
-test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-echo "error: failed to get domain '4294967298'" > exp || fail=1
-$abs_top_builddir/tools/virsh --quiet \
- --connect test://$abs_top_srcdir/examples/xml/test/testnode.xml \
- 'domname 4294967298; quit' > /dev/null 2> err || fail=1
-diff -u err exp || fail=1
-
-exit $fail
+++ /dev/null
-#!/bin/sh
-# ensure that reading a file larger than BUFSIZ works
-
-# Copyright (C) 2008, 2010 Red Hat, Inc.
-
-# 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, either version 2 of the License, or
-# (at your option) any later version.
-
-# 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, see
-# <http://www.gnu.org/licenses/>.
-
-test -z "$srcdir" && srcdir=`pwd`
-test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
-test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-fail=0
-
-# Output a valid definition, to be used as input.
-$abs_top_builddir/tools/virsh -c test:///default dumpxml 1 > xml.t || fail=1
-
-# Change the VM name and UUID
-sed -e "s|<name>test</name>|<name>newtest</name>|g" \
- -e "\|<uuid>.*</uuid>|d" \
- xml.t > xml
-
-for i in before after; do
- # The largest BUFSIZ I've seen is 128K. This is slightly larger.
- printf %132000s ' ' > sp || fail=1
- in=in-$i
- # Append or prepend enough spaces to push the size over the limit:
- ( test $i = before && cat sp xml || cat xml sp ) > $in || fail=1
-
- $abs_top_builddir/tools/virsh --connect test:///default define $in > out || fail=1
- printf "Domain newtest defined from $in\n\n" > exp || fail=1
- compare exp out || fail=1
-done
-
-(exit $fail); exit $fail
+++ /dev/null
-#!/bin/sh
-# ensure that certain file-reading commands can handle non-seekable files
-
-# Copyright (C) 2008 Red Hat, Inc.
-
-# 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, either version 2 of the License, or
-# (at your option) any later version.
-
-# 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, see
-# <http://www.gnu.org/licenses/>.
-
-test -z "$srcdir" && srcdir=`pwd`
-test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
-test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-fail=0
-
-cat <<\EOF > dom
-<domain type='test' id='2'>
- <name>t2</name>
- <uuid>004b96e1-2d78-c30f-5aa5-000000000000</uuid>
- <memory>8388608</memory>
- <vcpu>2</vcpu>
- <os>
- <type>xen</type>
- </os>
- <on_reboot>restart</on_reboot>
- <on_poweroff>destroy</on_poweroff>
- <on_crash>restart</on_crash>
-</domain>
-EOF
-
-$abs_top_builddir/tools/virsh -c test:///default define dom > /dev/null || fail=1
-
-mkfifo_or_skip_ fifo
-cat dom > fifo &
-
-$abs_top_builddir/tools/virsh -c test:///default define fifo > /dev/null || fail=1
-
-(exit $fail); exit $fail
+++ /dev/null
-#!/bin/sh
-# ensure that virsh start works properly
-
-# Copyright (C) 2008 Red Hat, Inc.
-
-# 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, either version 2 of the License, or
-# (at your option) any later version.
-
-# 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, see
-# <http://www.gnu.org/licenses/>.
-
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
-test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-fail=0
-
-test_url=test:///default
-
-# expect this to fail
-$abs_top_builddir/tools/virsh -c $test_url start test > out 2> err && fail=1
-
-# stdout gets a newline
-echo > exp || fail=1
-compare exp out || fail=1
-
-echo 'error: Domain is already active' > exp || fail=1
-compare exp err || fail=1
-
-(exit $fail); exit $fail
+++ /dev/null
-#!/bin/sh
-# ensure that an invalid CPU spec elicits a diagnostic
-
-# Copyright (C) 2008 Red Hat, Inc.
-
-# 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, either version 2 of the License, or
-# (at your option) any later version.
-
-# 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, see
-# <http://www.gnu.org/licenses/>.
-
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
-test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
-
-if test "$VERBOSE" = yes; then
- set -x
- $abs_top_builddir/tools/virsh --version
-fi
-
-. "$srcdir/test-lib.sh"
-
-fail=0
-
-# Invalid syntax.
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: Numeric value 'a' for <vcpu> option is malformed or out of range
-
-EOF
-compare exp out || fail=1
-
-# An out-of-range vCPU number deserves a diagnostic, too.
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: invalid argument: requested vcpu '100' is not present in the domain
-
-EOF
-compare exp out || fail=1
-
-# Negative number
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test -100 0,1 > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: Numeric value '-100' for <vcpu> option is malformed or out of range
-
-EOF
-compare exp out || fail=1
-
-# missing argument
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test --cpulist 0,1 > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: vcpupin: Missing vCPU number in pin mode.
-
-EOF
-compare exp out || fail=1
-
-# An out-of-range vCPU number when get information with live flag
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --live > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: vcpu 100 is out of range of live cpu count 2
-
-EOF
-compare exp out || fail=1
-
-# An out-of-range vCPU number when get information without flag
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: vcpu 100 is out of range of live cpu count 2
-
-EOF
-compare exp out || fail=1
-
-# An out-of-range vCPU number when get information with config flag
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --config > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: vcpu 100 is out of range of persistent cpu count 2
-
-EOF
-compare exp out || fail=1
-
-# An out-of-range vCPU number when get information with current flag
-$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --current > out 2>&1
-test $? = 1 || fail=1
-cat <<\EOF > exp || fail=1
-error: vcpu 100 is out of range of live cpu count 2
-
-EOF
-compare exp out || fail=1
-(exit $fail); exit $fail
--- /dev/null
+#!/bin/sh
+# ensure that defining with an invalid vCPU cpuset elicits a diagnostic
+
+# Copyright (C) 2008-2009 Red Hat, Inc.
+
+# 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, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+# generate input
+$abs_top_builddir/tools/virsh --connect test:///default dumpxml 1 > xml || fail=1
+
+# require the presence of the string we'll transform
+grep '<vcpu placement' xml > /dev/null || fail=1
+
+sed "s/vcpu placement='static'>/vcpu cpuset='aaa'>/" xml > xml-invalid || fail=1
+
+# Require failure and a diagnostic.
+$abs_top_builddir/tools/virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1
+cat <<\EOF > exp || fail=1
+error: Failed to define domain from xml-invalid
+error: invalid argument: Failed to parse bitmap 'aaa'
+
+EOF
+compare exp out || fail=1
+
+(exit $fail); exit $fail
--- /dev/null
+#!/bin/sh
+# Exercise a bug whereby defining a valid domain could kill libvirtd.
+# The bug can also be exercised with a simple define/dumpxml pair to virsh.
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+# Domain definition from Cole Robinson.
+cat <<\EOF > D.xml || fail=1
+<domain type='test'>
+ <name>D</name>
+ <uuid>aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82</uuid>
+ <memory unit='KiB'>262144</memory>
+ <currentMemory unit='KiB'>262144</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-kvm</emulator>
+ <controller type='usb' index='0'/>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <serial type='pty'>
+ <target port='1'/>
+ </serial>
+ <serial type='pty'>
+ <target port='2'/>
+ </serial>
+ <parallel type='pty'>
+ <target port='0'/>
+ </parallel>
+ <parallel type='pty'>
+ <target port='1'/>
+ </parallel>
+ <parallel type='pty'>
+ <target port='2'/>
+ </parallel>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <sound model='pcspk'/>
+ <sound model='es1370'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
+EOF
+
+url=test:///default
+$abs_top_builddir/tools/virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1
+
+cat > exp <<EOF || fail=1
+Domain D defined from D.xml
+
+$(cat D.xml)
+
+EOF
+
+compare exp out || fail=1
+
+exit $fail
--- /dev/null
+#!/bin/sh
+# Ensure that an invalid domain ID isn't interpreted as a valid one.
+# Before, an ID of 2^32+2 would be treated just like an ID of 2.
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+echo "error: failed to get domain '4294967298'" > exp || fail=1
+$abs_top_builddir/tools/virsh --quiet \
+ --connect test://$abs_top_srcdir/examples/xml/test/testnode.xml \
+ 'domname 4294967298; quit' > /dev/null 2> err || fail=1
+diff -u err exp || fail=1
+
+exit $fail
--- /dev/null
+#!/bin/sh
+# ensure that reading a file larger than BUFSIZ works
+
+# Copyright (C) 2008, 2010 Red Hat, Inc.
+
+# 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, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+# Output a valid definition, to be used as input.
+$abs_top_builddir/tools/virsh -c test:///default dumpxml 1 > xml.t || fail=1
+
+# Change the VM name and UUID
+sed -e "s|<name>test</name>|<name>newtest</name>|g" \
+ -e "\|<uuid>.*</uuid>|d" \
+ xml.t > xml
+
+for i in before after; do
+ # The largest BUFSIZ I've seen is 128K. This is slightly larger.
+ printf %132000s ' ' > sp || fail=1
+ in=in-$i
+ # Append or prepend enough spaces to push the size over the limit:
+ ( test $i = before && cat sp xml || cat xml sp ) > $in || fail=1
+
+ $abs_top_builddir/tools/virsh --connect test:///default define $in > out || fail=1
+ printf "Domain newtest defined from $in\n\n" > exp || fail=1
+ compare exp out || fail=1
+done
+
+(exit $fail); exit $fail
--- /dev/null
+#!/bin/sh
+# ensure that certain file-reading commands can handle non-seekable files
+
+# Copyright (C) 2008 Red Hat, Inc.
+
+# 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, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+cat <<\EOF > dom
+<domain type='test' id='2'>
+ <name>t2</name>
+ <uuid>004b96e1-2d78-c30f-5aa5-000000000000</uuid>
+ <memory>8388608</memory>
+ <vcpu>2</vcpu>
+ <os>
+ <type>xen</type>
+ </os>
+ <on_reboot>restart</on_reboot>
+ <on_poweroff>destroy</on_poweroff>
+ <on_crash>restart</on_crash>
+</domain>
+EOF
+
+$abs_top_builddir/tools/virsh -c test:///default define dom > /dev/null || fail=1
+
+mkfifo_or_skip_ fifo
+cat dom > fifo &
+
+$abs_top_builddir/tools/virsh -c test:///default define fifo > /dev/null || fail=1
+
+(exit $fail); exit $fail
--- /dev/null
+#!/bin/sh
+# ensure that virsh start works properly
+
+# Copyright (C) 2008 Red Hat, Inc.
+
+# 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, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+test_url=test:///default
+
+# expect this to fail
+$abs_top_builddir/tools/virsh -c $test_url start test > out 2> err && fail=1
+
+# stdout gets a newline
+echo > exp || fail=1
+compare exp out || fail=1
+
+echo 'error: Domain is already active' > exp || fail=1
+compare exp err || fail=1
+
+(exit $fail); exit $fail
--- /dev/null
+#!/bin/sh
+# ensure that an invalid CPU spec elicits a diagnostic
+
+# Copyright (C) 2008 Red Hat, Inc.
+
+# 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, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+# Invalid syntax.
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: Numeric value 'a' for <vcpu> option is malformed or out of range
+
+EOF
+compare exp out || fail=1
+
+# An out-of-range vCPU number deserves a diagnostic, too.
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: invalid argument: requested vcpu '100' is not present in the domain
+
+EOF
+compare exp out || fail=1
+
+# Negative number
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test -100 0,1 > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: Numeric value '-100' for <vcpu> option is malformed or out of range
+
+EOF
+compare exp out || fail=1
+
+# missing argument
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test --cpulist 0,1 > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: vcpupin: Missing vCPU number in pin mode.
+
+EOF
+compare exp out || fail=1
+
+# An out-of-range vCPU number when get information with live flag
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --live > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: vcpu 100 is out of range of live cpu count 2
+
+EOF
+compare exp out || fail=1
+
+# An out-of-range vCPU number when get information without flag
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: vcpu 100 is out of range of live cpu count 2
+
+EOF
+compare exp out || fail=1
+
+# An out-of-range vCPU number when get information with config flag
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --config > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: vcpu 100 is out of range of persistent cpu count 2
+
+EOF
+compare exp out || fail=1
+
+# An out-of-range vCPU number when get information with current flag
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --current > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > exp || fail=1
+error: vcpu 100 is out of range of live cpu count 2
+
+EOF
+compare exp out || fail=1
+(exit $fail); exit $fail