mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Added test suite for the XML <-> XM config file conversion
This commit is contained in:
parent
1b0f541704
commit
bc073b5a4d
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Fri Jan 19 15:28:13 EST 2007 Daniel Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* tests/xmconfigtest.c: Test suite to check conversion from
|
||||||
|
XML to XM config files, and the reverse
|
||||||
|
* tests/xmconfigdata/*.xml: Source XML files for the test
|
||||||
|
suite
|
||||||
|
* tests/xmconfigdata/*.cfg: Source XM config files for the
|
||||||
|
test suite
|
||||||
|
* configure.ac, tests/Makefile.am: Added xmconfigdata subdir
|
||||||
|
* tests/xmconfigdata/Makefile.am: Include config files when
|
||||||
|
doing a make dist.
|
||||||
|
|
||||||
Fri Jan 19 15:23:13 EST 2007 Daniel Berrange <berrange@redhat.com>
|
Fri Jan 19 15:23:13 EST 2007 Daniel Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* src/xm_internal.c: Finished off the conversion from XML
|
* src/xm_internal.c: Finished off the conversion from XML
|
||||||
|
@ -269,4 +269,5 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
|
|||||||
tests/Makefile proxy/Makefile \
|
tests/Makefile proxy/Makefile \
|
||||||
tests/xml2sexprdata/Makefile \
|
tests/xml2sexprdata/Makefile \
|
||||||
tests/sexpr2xmldata/Makefile \
|
tests/sexpr2xmldata/Makefile \
|
||||||
|
tests/xmconfigdata/Makefile \
|
||||||
tests/virshdata/Makefile tests/confdata/Makefile)
|
tests/virshdata/Makefile tests/confdata/Makefile)
|
||||||
|
@ -8,3 +8,4 @@ xml2sexprtest
|
|||||||
virshtest
|
virshtest
|
||||||
conftest
|
conftest
|
||||||
reconnect
|
reconnect
|
||||||
|
xmconfigtest
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
SUBDIRS = virshdata confdata sexpr2xmldata xml2sexprdata
|
SUBDIRS = virshdata confdata sexpr2xmldata xml2sexprdata xmconfigdata
|
||||||
|
|
||||||
LIBVIRT = $(top_builddir)/src/.libs/libvirt.a
|
LIBVIRT = $(top_builddir)/src/.libs/libvirt.a
|
||||||
|
|
||||||
@ -20,9 +20,9 @@ LDADDS = \
|
|||||||
EXTRA_DIST = xmlrpcserver.py test_conf.sh
|
EXTRA_DIST = xmlrpcserver.py test_conf.sh
|
||||||
|
|
||||||
noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
|
noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
|
||||||
reconnect
|
reconnect xmconfigtest
|
||||||
|
|
||||||
TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh reconnect
|
TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh reconnect xmconfigtest
|
||||||
|
|
||||||
valgrind:
|
valgrind:
|
||||||
$(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet --leak-check=full"
|
$(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet --leak-check=full"
|
||||||
@ -49,6 +49,12 @@ sexpr2xmltest_SOURCES = \
|
|||||||
sexpr2xmltest_LDFLAGS =
|
sexpr2xmltest_LDFLAGS =
|
||||||
sexpr2xmltest_LDADD = $(LDADDS)
|
sexpr2xmltest_LDADD = $(LDADDS)
|
||||||
|
|
||||||
|
xmconfigtest_SOURCES = \
|
||||||
|
xmconfigtest.c \
|
||||||
|
testutils.c testutils.h
|
||||||
|
xmconfigtest_LDFLAGS =
|
||||||
|
xmconfigtest_LDADD = $(LDADDS)
|
||||||
|
|
||||||
virshtest_SOURCES = \
|
virshtest_SOURCES = \
|
||||||
virshtest.c \
|
virshtest.c \
|
||||||
testutils.c testutils.h
|
testutils.c testutils.h
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* utils.c: basic test utils
|
* testutils.c: basic test utils
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 Red Hat, Inc.
|
* Copyright (C) 2005-2007 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* See COPYING.LIB for the License of this software
|
* See COPYING.LIB for the License of this software
|
||||||
*
|
*
|
||||||
@ -98,10 +98,12 @@ int virtTestLoadFile(const char *name,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (st.st_size) {
|
||||||
if (fread(*buf, st.st_size, 1, fp) != 1) {
|
if (fread(*buf, st.st_size, 1, fp) != 1) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
(*buf)[st.st_size] = '\0';
|
(*buf)[st.st_size] = '\0';
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -196,3 +198,13 @@ int virtTestCaptureProgramOutput(const char *const argv[],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* c-indent-level: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* tab-width: 4
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
2
tests/xmconfigdata/.cvsignore
Normal file
2
tests/xmconfigdata/.cvsignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
2
tests/xmconfigdata/Makefile.am
Normal file
2
tests/xmconfigdata/Makefile.am
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
EXTRA_DIST = $(wildcard *.xml) $(wildcard *.cfg)
|
22
tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
Executable file
22
tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
name = "XenGuest2"
|
||||||
|
uuid = "c7a5fdb2cdaf9455926ad65c16db1809"
|
||||||
|
maxmem = 579
|
||||||
|
memory = 394
|
||||||
|
vcpus = 1
|
||||||
|
builder = "hvm"
|
||||||
|
kernel = "/usr/lib/xen/boot/hvmloader"
|
||||||
|
boot = "d"
|
||||||
|
pae = 1
|
||||||
|
acpi = 1
|
||||||
|
apic = 1
|
||||||
|
on_poweroff = "destroy"
|
||||||
|
on_reboot = "restart"
|
||||||
|
on_crash = "restart"
|
||||||
|
device_model = "/usr/lib/xen/bin/qemu-dm"
|
||||||
|
sdl = 0
|
||||||
|
vnc = 1
|
||||||
|
vncunused = 1
|
||||||
|
vnclisten = "127.0.0.1"
|
||||||
|
vncpasswd = "123poi"
|
||||||
|
disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
|
||||||
|
vif = [ "mac=00:16:3E:66:92:9C,type=ioemu" ]
|
38
tests/xmconfigdata/test-fullvirt-new-cdrom.xml
Normal file
38
tests/xmconfigdata/test-fullvirt-new-cdrom.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<domain type='xen'>
|
||||||
|
<name>XenGuest2</name>
|
||||||
|
<uuid>c7a5fdb2cdaf9455926ad65c16db1809</uuid>
|
||||||
|
<os>
|
||||||
|
<type>hvm</type>
|
||||||
|
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||||
|
<boot>cdrom</boot>
|
||||||
|
</os>
|
||||||
|
<currentMemory>403456</currentMemory>
|
||||||
|
<memory>592896</memory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<features>
|
||||||
|
<pae/>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
</features>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='phy'/>
|
||||||
|
<source dev='/dev/HostVG/XenGuest2'/>
|
||||||
|
<target dev='hda'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='file'/>
|
||||||
|
<source file='/root/boot.iso'/>
|
||||||
|
<target dev='hdc'/>
|
||||||
|
<readonly/>
|
||||||
|
</disk>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='00:16:3E:66:92:9C'/>
|
||||||
|
</interface>
|
||||||
|
<graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
23
tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
Executable file
23
tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
name = "XenGuest2"
|
||||||
|
uuid = "c7a5fdb2cdaf9455926ad65c16db1809"
|
||||||
|
maxmem = 579
|
||||||
|
memory = 394
|
||||||
|
vcpus = 1
|
||||||
|
builder = "hvm"
|
||||||
|
kernel = "/usr/lib/xen/boot/hvmloader"
|
||||||
|
boot = "d"
|
||||||
|
pae = 1
|
||||||
|
acpi = 1
|
||||||
|
apic = 1
|
||||||
|
cdrom = "/root/boot.iso"
|
||||||
|
on_poweroff = "destroy"
|
||||||
|
on_reboot = "restart"
|
||||||
|
on_crash = "restart"
|
||||||
|
device_model = "/usr/lib/xen/bin/qemu-dm"
|
||||||
|
sdl = 0
|
||||||
|
vnc = 1
|
||||||
|
vncunused = 1
|
||||||
|
vnclisten = "127.0.0.1"
|
||||||
|
vncpasswd = "123poi"
|
||||||
|
disk = [ "phy:/dev/HostVG/XenGuest2,ioemu:hda,w" ]
|
||||||
|
vif = [ "mac=00:16:3E:66:92:9C,type=ioemu" ]
|
38
tests/xmconfigdata/test-fullvirt-old-cdrom.xml
Normal file
38
tests/xmconfigdata/test-fullvirt-old-cdrom.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<domain type='xen'>
|
||||||
|
<name>XenGuest2</name>
|
||||||
|
<uuid>c7a5fdb2cdaf9455926ad65c16db1809</uuid>
|
||||||
|
<os>
|
||||||
|
<type>hvm</type>
|
||||||
|
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||||
|
<boot>cdrom</boot>
|
||||||
|
</os>
|
||||||
|
<currentMemory>403456</currentMemory>
|
||||||
|
<memory>592896</memory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<features>
|
||||||
|
<pae/>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
</features>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='phy'/>
|
||||||
|
<source dev='/dev/HostVG/XenGuest2'/>
|
||||||
|
<target dev='hda'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='file'/>
|
||||||
|
<source file='/root/boot.iso'/>
|
||||||
|
<target dev='hdc'/>
|
||||||
|
<readonly/>
|
||||||
|
</disk>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='00:16:3E:66:92:9C'/>
|
||||||
|
</interface>
|
||||||
|
<graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
12
tests/xmconfigdata/test-paravirt-new-pvfb.cfg
Executable file
12
tests/xmconfigdata/test-paravirt-new-pvfb.cfg
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
name = "XenGuest1"
|
||||||
|
uuid = "c7a5fdb0cdaf9455926ad65c16db1809"
|
||||||
|
maxmem = 579
|
||||||
|
memory = 394
|
||||||
|
vcpus = 1
|
||||||
|
bootloader = "/usr/bin/pygrub"
|
||||||
|
on_poweroff = "destroy"
|
||||||
|
on_reboot = "restart"
|
||||||
|
on_crash = "restart"
|
||||||
|
vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ]
|
||||||
|
disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
|
||||||
|
vif = [ "mac=00:16:3E:66:94:9C,ip=192.168.0.9" ]
|
24
tests/xmconfigdata/test-paravirt-new-pvfb.xml
Normal file
24
tests/xmconfigdata/test-paravirt-new-pvfb.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<domain type='xen'>
|
||||||
|
<name>XenGuest1</name>
|
||||||
|
<uuid>c7a5fdb0cdaf9455926ad65c16db1809</uuid>
|
||||||
|
<bootloader>/usr/bin/pygrub</bootloader>
|
||||||
|
<currentMemory>403456</currentMemory>
|
||||||
|
<memory>592896</memory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='phy'/>
|
||||||
|
<source dev='/dev/HostVG/XenGuest1'/>
|
||||||
|
<target dev='xvda'/>
|
||||||
|
</disk>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='00:16:3E:66:94:9C'/>
|
||||||
|
<ip address='192.168.0.9'/>
|
||||||
|
</interface>
|
||||||
|
<graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
|
||||||
|
<console/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
16
tests/xmconfigdata/test-paravirt-old-pvfb.cfg
Executable file
16
tests/xmconfigdata/test-paravirt-old-pvfb.cfg
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
name = "XenGuest1"
|
||||||
|
uuid = "c7a5fdb0cdaf9455926ad65c16db1809"
|
||||||
|
maxmem = 579
|
||||||
|
memory = 394
|
||||||
|
vcpus = 1
|
||||||
|
bootloader = "/usr/bin/pygrub"
|
||||||
|
on_poweroff = "destroy"
|
||||||
|
on_reboot = "restart"
|
||||||
|
on_crash = "restart"
|
||||||
|
sdl = 0
|
||||||
|
vnc = 1
|
||||||
|
vncunused = 1
|
||||||
|
vnclisten = "127.0.0.1"
|
||||||
|
vncpasswd = "123poi"
|
||||||
|
disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
|
||||||
|
vif = [ "mac=00:16:3E:66:94:9C,ip=192.168.0.9" ]
|
24
tests/xmconfigdata/test-paravirt-old-pvfb.xml
Normal file
24
tests/xmconfigdata/test-paravirt-old-pvfb.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<domain type='xen'>
|
||||||
|
<name>XenGuest1</name>
|
||||||
|
<uuid>c7a5fdb0cdaf9455926ad65c16db1809</uuid>
|
||||||
|
<bootloader>/usr/bin/pygrub</bootloader>
|
||||||
|
<currentMemory>403456</currentMemory>
|
||||||
|
<memory>592896</memory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='phy'/>
|
||||||
|
<source dev='/dev/HostVG/XenGuest1'/>
|
||||||
|
<target dev='xvda'/>
|
||||||
|
</disk>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='00:16:3E:66:94:9C'/>
|
||||||
|
<ip address='192.168.0.9'/>
|
||||||
|
</interface>
|
||||||
|
<graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
|
||||||
|
<console/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
226
tests/xmconfigtest.c
Normal file
226
tests/xmconfigtest.c
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
/*
|
||||||
|
* xmconfigtest.c: Test backend for xm_internal config file handling
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Red Hat
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "xm_internal.h"
|
||||||
|
#include "testutils.h"
|
||||||
|
#include "internal.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
|
static char *progname;
|
||||||
|
|
||||||
|
#define MAX_FILE 4096
|
||||||
|
|
||||||
|
static int testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) {
|
||||||
|
char xmlData[MAX_FILE];
|
||||||
|
char xmcfgData[MAX_FILE];
|
||||||
|
char gotxmcfgData[MAX_FILE];
|
||||||
|
char *xmlPtr = &(xmlData[0]);
|
||||||
|
char *xmcfgPtr = &(xmcfgData[0]);
|
||||||
|
char *gotxmcfgPtr = &(gotxmcfgData[0]);
|
||||||
|
virConfPtr conf = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
virConnectPtr conn;
|
||||||
|
int wrote = MAX_FILE;
|
||||||
|
|
||||||
|
conn = virConnectOpen("test:///default");
|
||||||
|
|
||||||
|
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (virtTestLoadFile(xmcfg, &xmcfgPtr, MAX_FILE) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* Yes, a nasty hack, but this is only a test suite */
|
||||||
|
conn->xendConfigVersion = xendConfigVersion;
|
||||||
|
|
||||||
|
if (!(conf = xenXMParseXMLToConfig(conn, xmlPtr)))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (virConfWriteMem(gotxmcfgPtr, &wrote, conf) < 0)
|
||||||
|
goto fail;
|
||||||
|
gotxmcfgPtr[wrote] = '\0';
|
||||||
|
|
||||||
|
if (getenv("DEBUG_TESTS")) {
|
||||||
|
printf("Expect %d '%s'\n", (int)strlen(xmcfgData), xmcfgData);
|
||||||
|
printf("Actual %d '%s'\n", (int)strlen(gotxmcfgData), gotxmcfgData);
|
||||||
|
}
|
||||||
|
if (strcmp(xmcfgData, gotxmcfgData))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (conf)
|
||||||
|
virConfFree(conf);
|
||||||
|
|
||||||
|
virConnectClose(conn);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int testCompareFormatXML(const char *xmcfg, const char *xml, int xendConfigVersion) {
|
||||||
|
char xmlData[MAX_FILE];
|
||||||
|
char xmcfgData[MAX_FILE];
|
||||||
|
char *xmlPtr = &(xmlData[0]);
|
||||||
|
char *xmcfgPtr = &(xmcfgData[0]);
|
||||||
|
char *gotxml = NULL;
|
||||||
|
virConfPtr conf = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
virConnectPtr conn;
|
||||||
|
|
||||||
|
conn = virConnectOpen("test:///default");
|
||||||
|
|
||||||
|
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (virtTestLoadFile(xmcfg, &xmcfgPtr, MAX_FILE) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* Yes, a nasty hack, but this is only a test suite */
|
||||||
|
conn->xendConfigVersion = xendConfigVersion;
|
||||||
|
|
||||||
|
if (!(conf = virConfReadMem(xmcfgPtr, strlen(xmcfgPtr))))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (!(gotxml = xenXMDomainFormatXML(conn, conf)))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (getenv("DEBUG_TESTS")) {
|
||||||
|
printf("Expect %d '%s'\n", (int)strlen(xmlData), xmlData);
|
||||||
|
printf("Actual %d '%s'\n", (int)strlen(gotxml), gotxml);
|
||||||
|
}
|
||||||
|
if (strcmp(xmlData, gotxml))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (conf)
|
||||||
|
virConfFree(conf);
|
||||||
|
if (gotxml)
|
||||||
|
free(gotxml);
|
||||||
|
|
||||||
|
virConnectClose(conn);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int testCompareParavirtOldPVFBFormat(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareFormatXML("xmconfigdata/test-paravirt-old-pvfb.cfg",
|
||||||
|
"xmconfigdata/test-paravirt-old-pvfb.xml",
|
||||||
|
2);
|
||||||
|
}
|
||||||
|
static int testCompareParavirtOldPVFBParse(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareParseXML("xmconfigdata/test-paravirt-old-pvfb.cfg",
|
||||||
|
"xmconfigdata/test-paravirt-old-pvfb.xml",
|
||||||
|
2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int testCompareParavirtNewPVFBFormat(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareFormatXML("xmconfigdata/test-paravirt-new-pvfb.cfg",
|
||||||
|
"xmconfigdata/test-paravirt-new-pvfb.xml",
|
||||||
|
3);
|
||||||
|
}
|
||||||
|
static int testCompareParavirtNewPVFBParse(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareParseXML("xmconfigdata/test-paravirt-new-pvfb.cfg",
|
||||||
|
"xmconfigdata/test-paravirt-new-pvfb.xml",
|
||||||
|
3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int testCompareFullvirtOldCDROMFormat(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareFormatXML("xmconfigdata/test-fullvirt-old-cdrom.cfg",
|
||||||
|
"xmconfigdata/test-fullvirt-old-cdrom.xml",
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
static int testCompareFullvirtOldCDROMParse(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareParseXML("xmconfigdata/test-fullvirt-old-cdrom.cfg",
|
||||||
|
"xmconfigdata/test-fullvirt-old-cdrom.xml",
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int testCompareFullvirtNewCDROMFormat(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareFormatXML("xmconfigdata/test-fullvirt-new-cdrom.cfg",
|
||||||
|
"xmconfigdata/test-fullvirt-new-cdrom.xml",
|
||||||
|
2);
|
||||||
|
}
|
||||||
|
static int testCompareFullvirtNewCDROMParse(void *data ATTRIBUTE_UNUSED) {
|
||||||
|
return testCompareParseXML("xmconfigdata/test-fullvirt-new-cdrom.cfg",
|
||||||
|
"xmconfigdata/test-fullvirt-new-cdrom.xml",
|
||||||
|
2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
progname = argv[0];
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
fprintf(stderr, "Usage: %s\n", progname);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virtTestRun("Paravirt old PVFB (Format)",
|
||||||
|
1, testCompareParavirtOldPVFBFormat, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
if (virtTestRun("Paravirt new PVFB (Format)",
|
||||||
|
1, testCompareParavirtNewPVFBFormat, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
if (virtTestRun("Fullvirt old PVFB (Format)",
|
||||||
|
1, testCompareFullvirtOldCDROMFormat, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
if (virtTestRun("Fullvirt new PVFB (Format)",
|
||||||
|
1, testCompareFullvirtNewCDROMFormat, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
if (virtTestRun("Paravirt old PVFB (Parse)",
|
||||||
|
1, testCompareParavirtOldPVFBParse, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
if (virtTestRun("Paravirt new PVFB (Parse)",
|
||||||
|
1, testCompareParavirtNewPVFBParse, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
if (virtTestRun("Fullvirt old PVFB (Parse)",
|
||||||
|
1, testCompareFullvirtOldCDROMParse, NULL) != 0)
|
||||||
|
ret = -1;
|
||||||
|
if (virtTestRun("Fullvirt new PVFB (Parse)",
|
||||||
|
1, testCompareFullvirtNewCDROMParse, NULL) != 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:
|
||||||
|
*/
|
Loading…
x
Reference in New Issue
Block a user