2009-07-15 21:50:34 +04: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 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 ;
2011-04-25 02:25:10 +04:00
if ( virtTestLoadFile ( 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 ) ) {
virtTestDifference ( stderr , xmlData , actual ) ;
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 ;
2013-09-20 22:13:35 +04:00
# define DO_TEST(name) \
if ( virtTestRun ( " Interface XML-2-XML " name , \
testCompareXMLToXMLHelper , ( name ) ) < 0 ) \
2009-07-15 21:50:34 +04:00
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 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
}
VIRT_TEST_MAIN ( mymain )