libvirt/tests/interfacexml2xmltest.c
Eric Blake 8fe454ce90 build: expand rule to cover testsuite
The bulk of this patch was done with:

sed -i 's/\(\bfree *(/VIR_FREE(/g' tests/*.c

followed by fixing the few compile errors that resulted.

* cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation):
Remove tests from exemption.
* tests/testutils.h: Add common header.
* tests/commandhelper.c: Fix offenders.
* tests/cputest.c: Likewise.
* tests/domainsnapshotxml2xmltest.c: Likewise.
* tests/interfacexml2xmltest.c: Likewise.
* tests/networkxml2argvtest.c: Likewise.
* tests/networkxml2xmltest.c: Likewise.
* tests/nodedevxml2xmltest.c: Likewise.
* tests/nodeinfotest.c: Likewise.
* tests/nwfilterxml2xmltest.c: Likewise.
* tests/qemuargv2xmltest.c: Likewise.
* tests/qemuxml2argvtest.c: Likewise.
* tests/qemuxml2xmltest.c: Likewise.
* tests/qemuxmlnstest.c: Likewise.
* tests/qparamtest.c: Likewise.
* tests/sexpr2xmltest.c: Likewise.
* tests/storagepoolxml2xmltest.c: Likewise.
* tests/storagevolxml2xmltest.c: Likewise.
* tests/testutils.c: Likewise.
* tests/virshtest.c: Likewise.
* tests/xencapstest.c: Likewise.
* tests/xmconfigtest.c: Likewise.
* tests/xml2sexprtest.c: Likewise.
2012-02-03 10:41:46 -07:00

99 lines
2.0 KiB
C

#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include "internal.h"
#include "testutils.h"
#include "interface_conf.h"
#include "testutilsqemu.h"
static int
testCompareXMLToXMLFiles(const char *xml)
{
char *xmlData = NULL;
char *actual = NULL;
int ret = -1;
virInterfaceDefPtr dev = NULL;
if (virtTestLoadFile(xml, &xmlData) < 0)
goto fail;
if (!(dev = virInterfaceDefParseString(xmlData)))
goto fail;
if (!(actual = virInterfaceDefFormat(dev)))
goto fail;
if (STRNEQ(xmlData, actual)) {
virtTestDifference(stderr, xmlData, actual);
goto fail;
}
ret = 0;
fail:
VIR_FREE(xmlData);
VIR_FREE(actual);
virInterfaceDefFree(dev);
return ret;
}
static int
testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
char *xml = NULL;
if (virAsprintf(&xml, "%s/interfaceschemadata/%s.xml",
abs_srcdir, (const char*)data) < 0)
return -1;
result = testCompareXMLToXMLFiles(xml);
VIR_FREE(xml);
return result;
}
static int
mymain(void)
{
int ret = 0;
#define DO_TEST(name) \
if (virtTestRun("Interface XML-2-XML " name, \
1, testCompareXMLToXMLHelper, (name)) < 0) \
ret = -1
DO_TEST("ethernet-dhcp");
DO_TEST("ethernet-static");
DO_TEST("ethernet-static-no-prefix");
DO_TEST("bridge");
DO_TEST("bridge42");
DO_TEST("bridge-bond");
DO_TEST("bridge-empty");
DO_TEST("bridge-no-address");
DO_TEST("bridge-vlan");
DO_TEST("bridge-no-address");
DO_TEST("vlan");
DO_TEST("bond");
DO_TEST("bond-arp");
DO_TEST("ipv6-autoconf-dhcp");
DO_TEST("ipv6-autoconf");
DO_TEST("ipv6-dhcp");
DO_TEST("ipv6-local");
DO_TEST("ipv6-static-multi");
DO_TEST("ipv6-static");
return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
VIRT_TEST_MAIN(mymain)