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"
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 :
2011-04-25 02:25:10 +04:00
free ( xmlData ) ;
2009-07-15 21:50:34 +04:00
free ( actual ) ;
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 ) ;
free ( xml ) ;
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 ;
# define DO_TEST(name) \
2009-10-09 01:23:54 +04:00
if ( virtTestRun ( " Interface XML-2-XML " name , \
2009-07-15 21:50:34 +04: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 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
return ( ret = = 0 ? EXIT_SUCCESS : EXIT_FAILURE ) ;
}
VIRT_TEST_MAIN ( mymain )