]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: consistently name virsh tests with 'virsh-' prefix
authorCole Robinson <crobinso@redhat.com>
Thu, 21 Apr 2016 15:30:55 +0000 (11:30 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 21 Apr 2016 22:14:07 +0000 (18:14 -0400)
15 files changed:
tests/Makefile.am
tests/cpuset [deleted file]
tests/define-dev-segfault [deleted file]
tests/int-overflow [deleted file]
tests/read-bufsiz [deleted file]
tests/read-non-seekable [deleted file]
tests/start [deleted file]
tests/vcpupin [deleted file]
tests/virsh-cpuset [new file with mode: 0755]
tests/virsh-define-dev-segfault [new file with mode: 0755]
tests/virsh-int-overflow [new file with mode: 0755]
tests/virsh-read-bufsiz [new file with mode: 0755]
tests/virsh-read-non-seekable [new file with mode: 0755]
tests/virsh-start [new file with mode: 0755]
tests/virsh-vcpupin [new file with mode: 0755]

index b32435d2f344e3811cea0a67c6e17db9aee174bc..edf7b22c430d9e741968744e5b113a1c72c7b3ce 100644 (file)
@@ -368,22 +368,22 @@ test_scripts = \
        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
diff --git a/tests/cpuset b/tests/cpuset
deleted file mode 100755 (executable)
index 35803be..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/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
diff --git a/tests/define-dev-segfault b/tests/define-dev-segfault
deleted file mode 100755 (executable)
index 81a8773..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/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
diff --git a/tests/int-overflow b/tests/int-overflow
deleted file mode 100755 (executable)
index 36e5536..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/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
diff --git a/tests/read-bufsiz b/tests/read-bufsiz
deleted file mode 100755 (executable)
index 23c3b53..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/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
diff --git a/tests/read-non-seekable b/tests/read-non-seekable
deleted file mode 100755 (executable)
index 46e2831..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/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
diff --git a/tests/start b/tests/start
deleted file mode 100755 (executable)
index 5d4c0a7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/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
diff --git a/tests/vcpupin b/tests/vcpupin
deleted file mode 100755 (executable)
index 9e656c0..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/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
diff --git a/tests/virsh-cpuset b/tests/virsh-cpuset
new file mode 100755 (executable)
index 0000000..35803be
--- /dev/null
@@ -0,0 +1,50 @@
+#!/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
diff --git a/tests/virsh-define-dev-segfault b/tests/virsh-define-dev-segfault
new file mode 100755 (executable)
index 0000000..81a8773
--- /dev/null
@@ -0,0 +1,80 @@
+#!/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
diff --git a/tests/virsh-int-overflow b/tests/virsh-int-overflow
new file mode 100755 (executable)
index 0000000..36e5536
--- /dev/null
@@ -0,0 +1,22 @@
+#!/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
diff --git a/tests/virsh-read-bufsiz b/tests/virsh-read-bufsiz
new file mode 100755 (executable)
index 0000000..23c3b53
--- /dev/null
@@ -0,0 +1,53 @@
+#!/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
diff --git a/tests/virsh-read-non-seekable b/tests/virsh-read-non-seekable
new file mode 100755 (executable)
index 0000000..46e2831
--- /dev/null
@@ -0,0 +1,55 @@
+#!/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
diff --git a/tests/virsh-start b/tests/virsh-start
new file mode 100755 (executable)
index 0000000..5d4c0a7
--- /dev/null
@@ -0,0 +1,45 @@
+#!/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
diff --git a/tests/virsh-vcpupin b/tests/virsh-vcpupin
new file mode 100755 (executable)
index 0000000..9e656c0
--- /dev/null
@@ -0,0 +1,104 @@
+#!/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