From b3033b99f989191ed03543ca6e2a6811c64e4d64 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 18 Jul 2007 21:34:22 +0000 Subject: [PATCH] Added testsuite for QEMU XML routines --- ChangeLog | 7 + tests/.cvsignore | 2 + tests/Makefile.am | 17 +- .../qemuxml2argv-boot-cdrom.args | 1 + .../qemuxml2argv-boot-cdrom.xml | 23 +++ .../qemuxml2argv-boot-floppy.args | 1 + .../qemuxml2argv-boot-floppy.xml | 26 +++ .../qemuxml2argv-boot-network.args | 1 + .../qemuxml2argv-boot-network.xml | 22 ++ .../qemuxml2argv-clock-localtime.args | 1 + .../qemuxml2argv-clock-localtime.xml | 22 ++ .../qemuxml2argv-clock-utc.args | 1 + .../qemuxml2argv-clock-utc.xml | 22 ++ .../qemuxml2argv-disk-cdrom.args | 1 + .../qemuxml2argv-disk-cdrom.xml | 27 +++ .../qemuxml2argv-disk-floppy.args | 1 + .../qemuxml2argv-disk-floppy.xml | 30 +++ .../qemuxml2argv-disk-many.args | 1 + .../qemuxml2argv-disk-many.xml | 34 ++++ .../qemuxml2argv-graphics-sdl.args | 1 + .../qemuxml2argv-graphics-sdl.xml | 24 +++ .../qemuxml2argv-graphics-vnc.args | 1 + .../qemuxml2argv-graphics-vnc.xml | 24 +++ .../qemuxml2argv-input-usbmouse.args | 1 + .../qemuxml2argv-input-usbmouse.xml | 23 +++ .../qemuxml2argv-input-usbtablet.args | 1 + .../qemuxml2argv-input-usbtablet.xml | 23 +++ .../qemuxml2argv-minimal.args | 1 + .../qemuxml2argvdata/qemuxml2argv-minimal.xml | 22 ++ .../qemuxml2argv-misc-acpi.args | 1 + .../qemuxml2argv-misc-acpi.xml | 25 +++ .../qemuxml2argv-misc-no-reboot.args | 1 + .../qemuxml2argv-misc-no-reboot.xml | 22 ++ .../qemuxml2argv-net-user.args | 1 + .../qemuxml2argv-net-user.xml | 25 +++ tests/qemuxml2argvtest.c | 188 ++++++++++++++++++ tests/qemuxml2xmltest.c | 153 ++++++++++++++ 37 files changed, 775 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-network.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-many.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-minimal.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-minimal.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-user.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-user.xml create mode 100644 tests/qemuxml2argvtest.c create mode 100644 tests/qemuxml2xmltest.c diff --git a/ChangeLog b/ChangeLog index ca99720097..16cb90a583 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jul 18 17:15:08 EST 2007 Daniel P. Berrange + + * tests/Makefile.am: Added QEMU tests + * tests/qemuxml2argvdata/*: Data files for QEMU tests + * tests/qemuxml2argvtest.c: Test XML -> argv conversion + * tests/qemuxml2xmltest.c: Test XML -> XML roundtrip + Wed Jul 18 17:11:08 EST 2007 Daniel P. Berrange * src/xmlrpctest.c, src/xml2sexprtest.c: More void * to diff --git a/tests/.cvsignore b/tests/.cvsignore index b8ee537d5c..a254efafa1 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore @@ -10,6 +10,8 @@ conftest reconnect xmconfigtest xencapstest +qemuxml2xmltest +qemuxml2argvtest *.gcda *.gcno diff --git a/tests/Makefile.am b/tests/Makefile.am index f4f810c651..9eb5e8b5a3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,9 +32,10 @@ LDADDS = \ EXTRA_DIST = xmlrpcserver.py test_conf.sh noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \ - reconnect xmconfigtest xencapstest + reconnect xmconfigtest xencapstest qemuxml2argvtest qemuxml2xmltest -TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest xencapstest +TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest \ + xencapstest qemuxml2argvtest qemuxml2xmltest if ENABLE_XEN_TESTS TESTS += reconnect endif @@ -70,6 +71,18 @@ xmconfigtest_SOURCES = \ xmconfigtest_LDFLAGS = xmconfigtest_LDADD = $(LDADDS) +qemuxml2argvtest_SOURCES = \ + qemuxml2argvtest.c \ + testutils.c testutils.h +qemuxml2argvtest_LDFLAGS = +qemuxml2argvtest_LDADD = $(LDADDS) + +qemuxml2xmltest_SOURCES = \ + qemuxml2xmltest.c \ + testutils.c testutils.h +qemuxml2xmltest_LDFLAGS = +qemuxml2xmltest_LDADD = $(LDADDS) + virshtest_SOURCES = \ virshtest.c \ testutils.c testutils.h diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args new file mode 100644 index 0000000000..ed6a8655dc --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml new file mode 100644 index 0000000000..26eeb39330 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args new file mode 100644 index 0000000000..5e387ff805 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml new file mode 100644 index 0000000000..ed00c666dd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml @@ -0,0 +1,26 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args new file mode 100644 index 0000000000..e1d285ac3a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml new file mode 100644 index 0000000000..55d4e8a172 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args new file mode 100644 index 0000000000..555ce35400 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml new file mode 100644 index 0000000000..351779da1d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args new file mode 100644 index 0000000000..dc8e52b020 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml new file mode 100644 index 0000000000..816b16138c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args new file mode 100644 index 0000000000..298cea8cd6 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml new file mode 100644 index 0000000000..e3e5fbf51e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args new file mode 100644 index 0000000000..f6dad3da00 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml new file mode 100644 index 0000000000..37f1433416 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args new file mode 100644 index 0000000000..a6a957c4e2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml new file mode 100644 index 0000000000..1ff0aa20d4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args new file mode 100644 index 0000000000..50016c4f07 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -sdl \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml new file mode 100644 index 0000000000..8c795d9cd0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml @@ -0,0 +1,24 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args new file mode 100644 index 0000000000..42a33a47bb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -vnc 127.0.0.1:3 \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml new file mode 100644 index 0000000000..2528a0e8c1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml @@ -0,0 +1,24 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args new file mode 100644 index 0000000000..60b8bbedbc --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml new file mode 100644 index 0000000000..1bbf890078 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args new file mode 100644 index 0000000000..5f6f02cfb3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml new file mode 100644 index 0000000000..2cfc174010 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.args b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args new file mode 100644 index 0000000000..dc8e52b020 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml new file mode 100644 index 0000000000..816b16138c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args new file mode 100644 index 0000000000..600478c008 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml new file mode 100644 index 0000000000..759b6cf8f3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args new file mode 100644 index 0000000000..90ade68b72 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml new file mode 100644 index 0000000000..8d1d4b4e22 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + destroy + destroy + + /usr/bin/qemu + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args new file mode 100644 index 0000000000..bf49035d64 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args @@ -0,0 +1 @@ +/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb -nographic \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml new file mode 100644 index 0000000000..6a2d256d50 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c new file mode 100644 index 0000000000..0cb2238e6a --- /dev/null +++ b/tests/qemuxml2argvtest.c @@ -0,0 +1,188 @@ +#include +#include + +#include +#include + +#include "testutils.h" +#include "qemu_conf.h" +#include "internal.h" + +static char *progname; +struct qemud_driver driver; + +#define MAX_FILE 4096 + +static int testCompareXMLToArgvFiles(const char *xml, const char *cmd) { + char xmlData[MAX_FILE]; + char argvData[MAX_FILE]; + char *xmlPtr = &(xmlData[0]); + char *expectargv = &(argvData[0]); + char *actualargv = NULL; + char **argv = NULL; + char **tmp = NULL; + int ret = -1, len; + struct qemud_vm_def *vmdef; + struct qemud_vm vm; + + if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0) + goto fail; + + if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0) + goto fail; + + if (!(vmdef = qemudParseVMDef(NULL, &driver, xmlData, "test"))) + goto fail; + + vm.def = vmdef; + vm.pid = -1; + vm.id = -1; + vmdef->vncActivePort = vmdef->vncPort; + + if (qemudBuildCommandLine(NULL, &driver, &vm, &argv) < 0) + goto fail; + + tmp = argv; + len = 0; + while (*tmp) { + len += strlen(*tmp) + 1; + tmp++; + } + actualargv = malloc(sizeof(char)*len); + actualargv[0] = '\0'; + tmp = argv; + len = 0; + while (*tmp) { + if (actualargv[0]) + strcat(actualargv, " "); + strcat(actualargv, *tmp); + tmp++; + } + + if (strcmp(expectargv, actualargv)) { + if (getenv("DEBUG_TESTS")) { + printf("Expect %4d '%s'\n", (int)strlen(expectargv), expectargv); + printf("Actual %4d '%s'\n", (int)strlen(actualargv), actualargv); + } + goto fail; + } + + ret = 0; + + fail: + free(actualargv); + if (argv) { + tmp = argv; + while (*tmp) { + free(*tmp); + tmp++; + } + free(argv); + } + + return ret; +} + + +static int testCompareXMLToArgvHelper(const void *data) { + char xml[PATH_MAX]; + char args[PATH_MAX]; + snprintf(xml, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.xml", (const char*)data); + snprintf(args, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.args", (const char*)data); + return testCompareXMLToArgvFiles(xml, args); +} + + + +int +main(int argc, char **argv) +{ + int ret = 0; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + exit(EXIT_FAILURE); + } + + driver.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1; + driver.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON | + QEMUD_CMD_FLAG_NO_REBOOT; + + if (virtTestRun("QEMU XML-2-ARGV minimal", + 1, testCompareXMLToArgvHelper, "minimal") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Boot CDROM", + 1, testCompareXMLToArgvHelper, "boot-cdrom") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Boot Network", + 1, testCompareXMLToArgvHelper, "boot-network") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Boot Floppy", + 1, testCompareXMLToArgvHelper, "boot-floppy") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Clock UTC", + 1, testCompareXMLToArgvHelper, "clock-utc") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Clock Localtime", + 1, testCompareXMLToArgvHelper, "clock-localtime") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Disk CDROM", + 1, testCompareXMLToArgvHelper, "disk-cdrom") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Disk Floppy", + 1, testCompareXMLToArgvHelper, "disk-floppy") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Disk Many", + 1, testCompareXMLToArgvHelper, "disk-many") < 0) + ret = -1; + + if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC", + 1, testCompareXMLToArgvHelper, "graphics-vnc") < 0) + ret = -1; + + if (0 && virtTestRun("QEMU XML-2-ARGV Graphics SDL", + 1, testCompareXMLToArgvHelper, "graphics-sdl") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Input USB Mouse", + 1, testCompareXMLToArgvHelper, "input-usbmouse") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Input USB Tablet", + 1, testCompareXMLToArgvHelper, "input-usbtablet") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Misc ACPI", + 1, testCompareXMLToArgvHelper, "misc-acpi") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Misc No Reboot", + 1, testCompareXMLToArgvHelper, "misc-no-reboot") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Net User", + 1, testCompareXMLToArgvHelper, "net-user") < 0) + ret = -1; + + + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c new file mode 100644 index 0000000000..fc596b3347 --- /dev/null +++ b/tests/qemuxml2xmltest.c @@ -0,0 +1,153 @@ +#include +#include + +#include +#include + +#include "testutils.h" +#include "qemu_conf.h" +#include "internal.h" + +static char *progname; +struct qemud_driver driver; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *xml) { + char xmlData[MAX_FILE]; + char *xmlPtr = &(xmlData[0]); + char *actual = NULL; + int ret = -1; + struct qemud_vm_def *vmdef; + struct qemud_vm vm; + + if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0) + goto fail; + + if (!(vmdef = qemudParseVMDef(NULL, &driver, xmlData, "test"))) + goto fail; + + vm.def = vmdef; + vm.pid = -1; + vm.id = -1; + vmdef->vncActivePort = vmdef->vncPort; + + if (!(actual = qemudGenerateXML(NULL, &driver, &vm, vmdef, 0))) + goto fail; + + if (strcmp(xmlData, actual)) { + if (getenv("DEBUG_TESTS")) { + printf("Expect %4d '%s'\n", (int)strlen(xmlData), xmlData); + printf("Actual %4d '%s'\n", (int)strlen(actual), actual); + } + goto fail; + } + + ret = 0; + + fail: + free(actual); + + return ret; +} + +static int testCompareXMLToXMLHelper(const void *data) { + char xml[PATH_MAX]; + snprintf(xml, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.xml", (const char*)data); + return testCompareXMLToXMLFiles(xml); +} + + +int +main(int argc, char **argv) +{ + int ret = 0; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + exit(EXIT_FAILURE); + } + + driver.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1; + driver.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON | + QEMUD_CMD_FLAG_NO_REBOOT; + + if (virtTestRun("QEMU XML-2-ARGV minimal", + 1, testCompareXMLToXMLHelper, "minimal") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Boot CDROM", + 1, testCompareXMLToXMLHelper, "boot-cdrom") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Boot Network", + 1, testCompareXMLToXMLHelper, "boot-network") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Boot Floppy", + 1, testCompareXMLToXMLHelper, "boot-floppy") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Clock UTC", + 1, testCompareXMLToXMLHelper, "clock-utc") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Clock Localtime", + 1, testCompareXMLToXMLHelper, "clock-localtime") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Disk CDROM", + 1, testCompareXMLToXMLHelper, "disk-cdrom") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Disk Floppy", + 1, testCompareXMLToXMLHelper, "disk-floppy") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Disk Many", + 1, testCompareXMLToXMLHelper, "disk-many") < 0) + ret = -1; + + if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC", + 1, testCompareXMLToXMLHelper, "graphics-vnc") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Graphics SDL", + 1, testCompareXMLToXMLHelper, "graphics-sdl") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Input USB Mouse", + 1, testCompareXMLToXMLHelper, "input-usbmouse") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Input USB Tablet", + 1, testCompareXMLToXMLHelper, "input-usbtablet") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Misc ACPI", + 1, testCompareXMLToXMLHelper, "misc-acpi") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Misc No Reboot", + 1, testCompareXMLToXMLHelper, "misc-no-reboot") < 0) + ret = -1; + + if (virtTestRun("QEMU XML-2-ARGV Net User", + 1, testCompareXMLToXMLHelper, "net-user") < 0) + ret = -1; + + + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ -- GitLab