Rather than using 'virsh define' for the tests use the XML (or idea what the XML is testing) and use them as 'qemuxmlconftest' cases. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- tests/meson.build | 2 - .../console-compat-crash.x86_64-latest.args | 46 +++++++++++++ .../console-compat-crash.x86_64-latest.xml | 65 +++++++++++++++++++ .../console-compat-crash.xml} | 36 +--------- .../cpuset-invalid.x86_64-latest.err | 1 + tests/qemuxmlconfdata/cpuset-invalid.xml | 12 ++++ tests/qemuxmlconftest.c | 2 + tests/virsh-cpuset | 46 ------------- 8 files changed, 129 insertions(+), 81 deletions(-) create mode 100644 tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml rename tests/{virsh-define-dev-segfault => qemuxmlconfdata/console-compat-crash.xml} (59%) mode change 100755 => 100644 create mode 100644 tests/qemuxmlconfdata/cpuset-invalid.x86_64-latest.err create mode 100644 tests/qemuxmlconfdata/cpuset-invalid.xml delete mode 100755 tests/virsh-cpuset diff --git a/tests/meson.build b/tests/meson.build index b70fe7732e..35e8bd53bb 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -692,8 +692,6 @@ if conf.has('WITH_LIBVIRTD') 'libvirtd-pool', 'virsh-auth', 'virsh-checkpoint', - 'virsh-cpuset', - 'virsh-define-dev-segfault', 'virsh-int-overflow', 'virsh-read-bufsiz', 'virsh-read-non-seekable', diff --git a/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args new file mode 100644 index 0000000000..3738d252a4 --- /dev/null +++ b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args @@ -0,0 +1,46 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-D \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-D/.local/share \ +XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-D/.cache \ +XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-D/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=D,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-D/master-key.aes"}' \ +-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,pcspk-audiodev=audio1,acpi=on \ +-accel kvm \ +-cpu qemu64 \ +-m size=262144k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":268435456}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-boot strict=on \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \ +-chardev pty,id=charserial0 \ +-device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \ +-chardev pty,id=charserial1 \ +-device '{"driver":"isa-serial","chardev":"charserial1","id":"serial1","index":1}' \ +-chardev pty,id=charserial2 \ +-device '{"driver":"isa-serial","chardev":"charserial2","id":"serial2","index":2}' \ +-chardev pty,id=charparallel0 \ +-device '{"driver":"isa-parallel","chardev":"charparallel0","id":"parallel0"}' \ +-chardev pty,id=charparallel1 \ +-device '{"driver":"isa-parallel","chardev":"charparallel1","id":"parallel1"}' \ +-chardev pty,id=charparallel2 \ +-device '{"driver":"isa-parallel","chardev":"charparallel2","id":"parallel2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"ES1370","id":"sound1","audiodev":"audio1","bus":"pci.0","addr":"0x2"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x3"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml new file mode 100644 index 0000000000..106d97b62f --- /dev/null +++ b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml @@ -0,0 +1,65 @@ +<domain type='kvm'> + <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='x86_64' machine='pc'>hvm</type> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + </features> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>qemu64</model> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0' model='piix3-uhci'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <serial type='pty'> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> + </serial> + <serial type='pty'> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> + </serial> + <serial type='pty'> + <target type='isa-serial' port='2'> + <model name='isa-serial'/> + </target> + </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> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <sound model='pcspk'/> + <sound model='es1370'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </sound> + <audio id='1' type='none'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/virsh-define-dev-segfault b/tests/qemuxmlconfdata/console-compat-crash.xml old mode 100755 new mode 100644 similarity index 59% rename from tests/virsh-define-dev-segfault rename to tests/qemuxmlconfdata/console-compat-crash.xml index cc5b461932..d8795c580e --- a/tests/virsh-define-dev-segfault +++ b/tests/qemuxmlconfdata/console-compat-crash.xml @@ -1,26 +1,11 @@ -#!/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. - -. "$(dirname $0)/test-lib.sh" - -if test "$VERBOSE" = yes; then - set -x - $abs_top_builddir/tools/virsh --version -fi - -fail=0 - -# Domain definition from Cole Robinson. -cat <<\EOF > D.xml || fail=1 -<domain type='test'> +<domain type='kvm'> <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> + <type arch='x86_64' machine='pc'>hvm</type> <boot dev='cdrom'/> </os> <features> @@ -31,7 +16,7 @@ cat <<\EOF > D.xml || fail=1 <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <controller type='usb' index='0'/> <serial type='pty'> <target port='0'/> @@ -59,18 +44,3 @@ cat <<\EOF > D.xml || fail=1 <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/qemuxmlconfdata/cpuset-invalid.x86_64-latest.err b/tests/qemuxmlconfdata/cpuset-invalid.x86_64-latest.err new file mode 100644 index 0000000000..be11724ab1 --- /dev/null +++ b/tests/qemuxmlconfdata/cpuset-invalid.x86_64-latest.err @@ -0,0 +1 @@ +invalid argument: Failed to parse bitmap 'aaa' diff --git a/tests/qemuxmlconfdata/cpuset-invalid.xml b/tests/qemuxmlconfdata/cpuset-invalid.xml new file mode 100644 index 0000000000..89a6540fb9 --- /dev/null +++ b/tests/qemuxmlconfdata/cpuset-invalid.xml @@ -0,0 +1,12 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <vcpu cpuset='aaa'>2</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + </devices> +</domain> diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 9e2c7da15a..42530555f3 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -1799,6 +1799,7 @@ mymain(void) DO_TEST_CAPS_LATEST("console-compat"); DO_TEST_CAPS_LATEST("console-compat-auto"); + DO_TEST_CAPS_LATEST("console-compat-crash"); DO_TEST_CAPS_LATEST("serial-vc-chardev"); DO_TEST_CAPS_LATEST("serial-pty-chardev"); @@ -2287,6 +2288,7 @@ mymain(void) DO_TEST_CAPS_LATEST("cputune-numatune"); DO_TEST_CAPS_LATEST("vcpu-placement-static"); DO_TEST_CAPS_LATEST("cputune-cpuset-big-id"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("cpuset-invalid"); DO_TEST_CAPS_LATEST_PARSE_ERROR("numatune-memory-invalid-nodeset"); DO_TEST_CAPS_VER("numatune-memnode", "5.2.0"); diff --git a/tests/virsh-cpuset b/tests/virsh-cpuset deleted file mode 100755 index 66163013c2..0000000000 --- a/tests/virsh-cpuset +++ /dev/null @@ -1,46 +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/>. - -. "$(dirname $0)/test-lib.sh" - -if test "$VERBOSE" = yes; then - set -x - $abs_top_builddir/tools/virsh --version -fi - -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 -- 2.44.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx