2014-02-14 18:44:59 +04:00
# include <config.h>
# include "internal.h"
# include "testutils.h"
# include "secret_conf.h"
# define VIR_FROM_THIS VIR_FROM_NONE
static int
testCompareXMLToXMLFiles ( const char * inxml , const char * outxml )
{
char * actual = NULL ;
int ret = - 1 ;
virSecretDefPtr secret = NULL ;
2015-04-23 18:10:15 +03:00
if ( ! ( secret = virSecretDefParseFile ( inxml ) ) )
2014-02-14 18:44:59 +04:00
goto fail ;
if ( ! ( actual = virSecretDefFormat ( secret ) ) )
goto fail ;
2016-05-26 18:01:53 +03:00
if ( virTestCompareToFile ( actual , outxml ) < 0 )
2014-02-14 18:44:59 +04:00
goto fail ;
ret = 0 ;
2014-03-25 10:53:44 +04:00
fail :
2014-02-14 18:44:59 +04:00
VIR_FREE ( actual ) ;
virSecretDefFree ( secret ) ;
return ret ;
}
struct testInfo {
const char * name ;
bool different ;
} ;
static int
testCompareXMLToXMLHelper ( const void * data )
{
int result = - 1 ;
char * inxml = NULL ;
char * outxml = NULL ;
const struct testInfo * info = data ;
if ( virAsprintf ( & inxml , " %s/secretxml2xmlin/%s.xml " ,
abs_srcdir , info - > name ) < 0 | |
virAsprintf ( & outxml , " %s/secretxml2xml%s/%s.xml " ,
abs_srcdir ,
info - > different ? " out " : " in " ,
info - > name ) < 0 ) {
goto cleanup ;
}
result = testCompareXMLToXMLFiles ( inxml , outxml ) ;
2014-03-25 10:53:44 +04:00
cleanup :
2014-02-14 18:44:59 +04:00
VIR_FREE ( inxml ) ;
VIR_FREE ( outxml ) ;
return result ;
}
static int
mymain ( void )
{
int ret = 0 ;
2017-11-03 15:09:47 +03:00
# define DO_TEST(name) \
do { \
const struct testInfo info = { name , false } ; \
if ( virTestRun ( " Secret XML->XML " name , \
testCompareXMLToXMLHelper , & info ) < 0 ) \
ret = - 1 ; \
2014-02-14 18:44:59 +04:00
} while ( 0 )
DO_TEST ( " ephemeral-usage-volume " ) ;
DO_TEST ( " usage-volume " ) ;
DO_TEST ( " usage-ceph " ) ;
DO_TEST ( " usage-iscsi " ) ;
2016-07-14 22:09:08 +03:00
DO_TEST ( " usage-tls " ) ;
2014-02-14 18:44:59 +04:00
return ret = = 0 ? EXIT_SUCCESS : EXIT_FAILURE ;
}
2017-03-29 17:45:42 +03:00
VIR_TEST_MAIN ( mymain )