2009-07-15 21:50:34 +04:00
# include <config.h>
# include <unistd.h>
# include <sys/types.h>
# include <fcntl.h>
# include "internal.h"
# include "testutils.h"
# include "interface_conf.h"
# include "testutilsqemu.h"
2013-04-03 14:36:23 +04:00
# include "virstring.h"
2009-07-15 21:50:34 +04:00
2013-06-07 19:10:28 +04:00
# define VIR_FROM_THIS VIR_FROM_NONE
2011-04-25 02:25:10 +04:00
static int
testCompareXMLToXMLFiles ( const char * xml )
{
char * xmlData = NULL ;
2009-07-15 21:50:34 +04:00
char * actual = NULL ;
int ret = - 1 ;
virInterfaceDefPtr dev = NULL ;
2016-05-26 18:01:52 +03:00
if ( virTestLoadFile ( xml , & xmlData ) < 0 )
2009-07-15 21:50:34 +04:00
goto fail ;
2010-02-10 15:28:05 +03:00
if ( ! ( dev = virInterfaceDefParseString ( xmlData ) ) )
2009-07-15 21:50:34 +04:00
goto fail ;
2010-02-10 15:28:05 +03:00
if ( ! ( actual = virInterfaceDefFormat ( dev ) ) )
2009-07-15 21:50:34 +04:00
goto fail ;
if ( STRNEQ ( xmlData , actual ) ) {
2016-05-26 18:01:54 +03:00
virTestDifferenceFull ( stderr , xmlData , xml , actual , NULL ) ;
2009-07-15 21:50:34 +04:00
goto fail ;
}
ret = 0 ;
fail :
2012-02-03 03:16:43 +04:00
VIR_FREE ( xmlData ) ;
VIR_FREE ( actual ) ;
2009-07-15 21:50:34 +04:00
virInterfaceDefFree ( dev ) ;
return ret ;
}
2011-04-25 02:25:10 +04: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-03 03:16:43 +04:00
VIR_FREE ( xml ) ;
2011-04-25 02:25:10 +04:00
return result ;
2009-07-15 21:50:34 +04:00
}
static int
2011-04-29 20:21:20 +04:00
mymain ( void )
2009-07-15 21:50:34 +04:00
{
int ret = 0 ;
2017-11-03 15:09:47 +03:00
# define DO_TEST(name) \
if ( virTestRun ( " Interface XML-2-XML " name , \
testCompareXMLToXMLHelper , ( name ) ) < 0 ) \
2009-07-15 21:50:34 +04:00
ret = - 1
DO_TEST ( " ethernet-dhcp " ) ;
2015-05-21 18:26:52 +03:00
DO_TEST ( " ethernet-dhcp-and-multi-static " ) ;
2009-07-15 21:50:34 +04:00
DO_TEST ( " ethernet-static " ) ;
DO_TEST ( " ethernet-static-no-prefix " ) ;
DO_TEST ( " bridge " ) ;
DO_TEST ( " bridge42 " ) ;
2010-01-02 04:40:26 +03:00
DO_TEST ( " bridge-bond " ) ;
DO_TEST ( " bridge-empty " ) ;
DO_TEST ( " bridge-no-address " ) ;
2009-07-15 21:50:34 +04:00
DO_TEST ( " bridge-vlan " ) ;
DO_TEST ( " bridge-no-address " ) ;
DO_TEST ( " vlan " ) ;
DO_TEST ( " bond " ) ;
DO_TEST ( " bond-arp " ) ;
2010-01-02 04:40:26 +03: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 21:50:34 +04:00
2014-03-17 13:38:38 +04:00
return ret = = 0 ? EXIT_SUCCESS : EXIT_FAILURE ;
2009-07-15 21:50:34 +04:00
}
2017-03-29 17:45:42 +03:00
VIR_TEST_MAIN ( mymain )