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
|
|
|
|
2013-06-07 15:10:28 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
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;
|
|
|
|
|
2016-05-26 15:01:52 +00:00
|
|
|
if (virTestLoadFile(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)) {
|
2016-05-26 15:01:54 +00:00
|
|
|
virTestDifferenceFull(stderr, xmlData, xml, actual, NULL);
|
2009-07-15 17:50:34 +00:00
|
|
|
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;
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define DO_TEST(name) \
|
|
|
|
if (virTestRun("Interface XML-2-XML " name, \
|
|
|
|
testCompareXMLToXMLHelper, (name)) < 0) \
|
2009-07-15 17:50:34 +00:00
|
|
|
ret = -1
|
|
|
|
|
|
|
|
DO_TEST("ethernet-dhcp");
|
2015-05-21 15:26:52 +00:00
|
|
|
DO_TEST("ethernet-dhcp-and-multi-static");
|
2009-07-15 17:50:34 +00:00
|
|
|
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
|
|
|
|
2014-03-17 09:38:38 +00:00
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
2009-07-15 17:50:34 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 14:45:42 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|