2009-07-15 17:50:34 +00:00
|
|
|
#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"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2009-07-15 17:50:34 +00:00
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
static int
|
|
|
|
testCompareXMLToXMLFiles(const char *xml)
|
|
|
|
{
|
|
|
|
char *xmlData = NULL;
|
2009-07-15 17:50:34 +00:00
|
|
|
char *actual = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
virInterfaceDefPtr dev = NULL;
|
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
if (virtTestLoadFile(xml, &xmlData) < 0)
|
2009-07-15 17:50:34 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-02-10 12:28:05 +00:00
|
|
|
if (!(dev = virInterfaceDefParseString(xmlData)))
|
2009-07-15 17:50:34 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-02-10 12:28:05 +00:00
|
|
|
if (!(actual = virInterfaceDefFormat(dev)))
|
2009-07-15 17:50:34 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (STRNEQ(xmlData, actual)) {
|
|
|
|
virtTestDifference(stderr, xmlData, actual);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
fail:
|
2012-02-02 23:16:43 +00:00
|
|
|
VIR_FREE(xmlData);
|
|
|
|
VIR_FREE(actual);
|
2009-07-15 17:50:34 +00:00
|
|
|
virInterfaceDefFree(dev);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
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);
|
|
|
|
|
2012-02-02 23:16:43 +00:00
|
|
|
VIR_FREE(xml);
|
2011-04-24 22:25:10 +00:00
|
|
|
return result;
|
2009-07-15 17:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-04-29 16:21:20 +00:00
|
|
|
mymain(void)
|
2009-07-15 17:50:34 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
#define DO_TEST(name) \
|
2009-10-08 21:23:54 +00:00
|
|
|
if (virtTestRun("Interface XML-2-XML " name, \
|
2009-07-15 17:50:34 +00:00
|
|
|
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");
|
2010-01-02 01:40:26 +00:00
|
|
|
DO_TEST("bridge-bond");
|
|
|
|
DO_TEST("bridge-empty");
|
|
|
|
DO_TEST("bridge-no-address");
|
2009-07-15 17:50:34 +00:00
|
|
|
DO_TEST("bridge-vlan");
|
|
|
|
DO_TEST("bridge-no-address");
|
|
|
|
DO_TEST("vlan");
|
|
|
|
DO_TEST("bond");
|
|
|
|
DO_TEST("bond-arp");
|
2010-01-02 01:40:26 +00:00
|
|
|
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");
|
2009-07-15 17:50:34 +00:00
|
|
|
|
2012-03-22 11:33:35 +00:00
|
|
|
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
2009-07-15 17:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VIRT_TEST_MAIN(mymain)
|