2008-01-29 21:15:54 +03:00
# include <config.h>
2007-11-26 15:03:34 +03:00
2006-08-24 19:05:19 +04:00
# include <stdio.h>
# include <string.h>
2007-03-15 10:43:16 +03:00
# ifdef WITH_XEN
Wed Dec 5 13:48:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* python/libvir.c, python/libvirt_wrap.h, qemud/qemud.c,
qemud/remote.c, src/internal.h, src/openvz_conf.c,
src/openvz_driver.c, src/proxy_internal.h, src/qemu_conf.c,
src/qemu_driver.c, src/remote_internal.h, src/test.h, src/util.c,
src/xen_unified.c, src/xen_unified.h, tests/nodeinfotest.c,
tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c, tests/reconnect.c,
tests/sexpr2xmltest.c, tests/virshtest.c, tests/xencapstest.c,
tests/xmconfigtest.c, tests/xml2sexprtest.c:
Change #include <> to #include "" for local includes.
Removed many includes from src/internal.h and put them in
the C files which actually use them.
Removed <ansidecl.h> - unused.
Added a comment around __func__.
Removed a clashing redefinition of VERSION symbol.
All limits (PATH_MAX etc) now done in src/internal.h, so we
don't need to include those headers in other files.
2007-12-05 16:56:22 +03:00
# include "internal.h"
2006-08-24 19:05:19 +04:00
# include "xml.h"
# include "xend_internal.h"
# include "testutils.h"
static char * progname ;
2007-11-14 13:35:58 +03:00
static char * abs_top_srcdir ;
2006-08-24 19:05:19 +04:00
# define MAX_FILE 4096
2007-11-14 13:35:58 +03:00
static int testCompareFiles ( const char * xml_rel , const char * sexpr_rel ,
int xendConfigVersion ) {
2006-08-24 19:05:19 +04:00
char xmlData [ MAX_FILE ] ;
char sexprData [ MAX_FILE ] ;
char * gotxml = NULL ;
char * xmlPtr = & ( xmlData [ 0 ] ) ;
char * sexprPtr = & ( sexprData [ 0 ] ) ;
2006-10-06 19:32:48 +04:00
int ret = - 1 ;
2007-11-14 13:35:58 +03:00
char xml [ PATH_MAX ] ;
char sexpr [ PATH_MAX ] ;
snprintf ( xml , sizeof xml - 1 , " %s/tests/%s " , abs_top_srcdir , xml_rel ) ;
snprintf ( sexpr , sizeof sexpr - 1 , " %s/tests/%s " , abs_top_srcdir , sexpr_rel ) ;
2006-08-24 19:05:19 +04:00
if ( virtTestLoadFile ( xml , & xmlPtr , MAX_FILE ) < 0 )
2006-10-06 19:32:48 +04:00
goto fail ;
2006-08-24 19:05:19 +04:00
if ( virtTestLoadFile ( sexpr , & sexprPtr , MAX_FILE ) < 0 )
2006-10-06 19:32:48 +04:00
goto fail ;
2006-08-24 19:05:19 +04:00
2006-09-12 05:16:22 +04:00
if ( ! ( gotxml = xend_parse_domain_sexp ( NULL , sexprData , xendConfigVersion ) ) )
2006-10-06 19:32:48 +04:00
goto fail ;
2006-08-24 19:05:19 +04:00
2007-07-17 01:30:30 +04:00
if ( strcmp ( xmlData , gotxml ) ) {
if ( getenv ( " DEBUG_TESTS " ) ) {
2007-08-21 13:38:00 +04:00
printf ( " In test file %s -> %s: \n " , sexpr , xml ) ;
2007-07-17 01:30:30 +04:00
printf ( " Expect %d '%s' \n " , ( int ) strlen ( xmlData ) , xmlData ) ;
printf ( " Actual %d '%s' \n " , ( int ) strlen ( gotxml ) , gotxml ) ;
}
2006-10-06 19:32:48 +04:00
goto fail ;
2007-07-17 01:30:30 +04:00
}
2006-08-24 19:05:19 +04:00
2006-10-06 19:32:48 +04:00
ret = 0 ;
fail :
free ( gotxml ) ;
return ret ;
2006-08-24 19:05:19 +04:00
}
2007-07-19 01:08:22 +04:00
static int testComparePVversion1 ( const void * data ATTRIBUTE_UNUSED ) {
2006-09-12 05:16:22 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-pv.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-pv.sexpr " ,
1 ) ;
2006-08-24 19:05:19 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareFVversion1 ( const void * data ATTRIBUTE_UNUSED ) {
2006-09-12 05:16:22 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv.sexpr " ,
1 ) ;
2006-09-12 05:16:22 +04:00
}
2007-07-19 01:08:22 +04:00
static int testComparePVversion2 ( const void * data ATTRIBUTE_UNUSED ) {
2006-09-12 05:16:22 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-pv.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-pv.sexpr " ,
2 ) ;
2006-09-12 05:16:22 +04:00
}
2007-07-19 01:08:22 +04:00
static int testComparePVOrigVFB ( const void * data ATTRIBUTE_UNUSED ) {
2006-12-07 02:44:17 +03:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml " ,
" sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr " ,
2 ) ;
2006-12-13 17:08:51 +03:00
}
2006-12-07 02:44:17 +03:00
2007-07-19 01:08:22 +04:00
static int testComparePVNewVFB ( const void * data ATTRIBUTE_UNUSED ) {
2006-12-07 02:44:17 +03:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-pv-vfb-new.xml " ,
" sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr " ,
3 ) ;
2006-12-13 17:08:51 +03:00
}
2006-12-07 02:44:17 +03:00
2007-07-19 01:08:22 +04:00
static int testCompareFVversion2 ( const void * data ATTRIBUTE_UNUSED ) {
2006-09-12 05:16:22 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-v2.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-v2.sexpr " ,
2 ) ;
2006-08-24 19:05:19 +04:00
}
2007-07-19 01:08:22 +04:00
static int testComparePVBootloader ( const void * data ATTRIBUTE_UNUSED ) {
2007-06-07 17:50:18 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-pv-bootloader.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr " ,
2 ) ;
2007-06-07 17:50:18 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareDiskFile ( const void * data ATTRIBUTE_UNUSED ) {
2006-10-09 18:32:07 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-disk-file.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-disk-file.sexpr " ,
1 ) ;
2006-10-09 18:32:07 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareDiskBlock ( const void * data ATTRIBUTE_UNUSED ) {
2006-10-09 18:32:07 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-disk-block.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-disk-block.sexpr " ,
1 ) ;
2006-10-09 18:32:07 +04:00
}
2007-11-20 13:05:45 +03:00
static int testCompareDiskShareable ( const void * data ATTRIBUTE_UNUSED ) {
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-disk-block-shareable.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-disk-block-shareable.sexpr " ,
1 ) ;
2007-11-20 13:05:45 +03:00
}
2007-07-19 01:08:22 +04:00
static int testCompareDiskDrvBlktapQcow ( const void * data ATTRIBUTE_UNUSED ) {
2006-10-09 18:32:07 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.sexpr " ,
1 ) ;
2006-10-09 18:32:07 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareDiskDrvBlktapRaw ( const void * data ATTRIBUTE_UNUSED ) {
2006-10-09 18:32:07 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.sexpr " ,
1 ) ;
2006-10-09 18:32:07 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareResizedMemory ( const void * data ATTRIBUTE_UNUSED ) {
2006-11-10 14:13:01 +03:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-curmem.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-curmem.sexpr " ,
1 ) ;
2006-11-10 14:13:01 +03:00
}
2006-10-09 18:32:07 +04:00
2007-07-19 01:08:22 +04:00
static int testCompareNetRouted ( const void * data ATTRIBUTE_UNUSED ) {
2006-11-15 03:38:13 +03:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-net-routed.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-net-routed.sexpr " ,
1 ) ;
2006-11-15 03:38:13 +03:00
}
2007-07-19 01:08:22 +04:00
static int testCompareNetBridged ( const void * data ATTRIBUTE_UNUSED ) {
2006-11-15 03:38:13 +03:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-net-bridged.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-net-bridged.sexpr " ,
1 ) ;
2006-11-15 03:38:13 +03:00
}
2007-07-19 01:08:22 +04:00
static int testCompareNoSourceCDRom ( const void * data ATTRIBUTE_UNUSED ) {
2007-04-11 20:06:30 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-no-source-cdrom.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr " ,
1 ) ;
2007-04-11 20:06:30 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareFVInputUSBMouse ( const void * data ATTRIBUTE_UNUSED ) {
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-usbmouse.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-usbmouse.sexpr " ,
1 ) ;
2007-07-19 01:08:22 +04:00
}
static int testCompareFVInputUSBTablet ( const void * data ATTRIBUTE_UNUSED ) {
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-usbtablet.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-usbtablet.sexpr " ,
1 ) ;
2007-07-19 01:08:22 +04:00
}
static int testCompareFVclockUTC ( const void * data ATTRIBUTE_UNUSED ) {
2007-07-17 01:30:30 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-utc.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-utc.sexpr " ,
1 ) ;
2007-07-17 01:30:30 +04:00
}
2007-07-19 01:08:22 +04:00
static int testCompareFVclockLocaltime ( const void * data ATTRIBUTE_UNUSED ) {
2007-07-17 01:30:30 +04:00
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-localtime.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-localtime.sexpr " ,
1 ) ;
2007-07-17 01:30:30 +04:00
}
2008-02-05 19:21:25 +03:00
static int testCompareFVKernel ( const void * data ATTRIBUTE_UNUSED ) {
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-kernel.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-kernel.sexpr " ,
1 ) ;
2008-02-05 19:21:25 +03:00
}
static int testCompareFVLegacyVFB ( const void * data ATTRIBUTE_UNUSED ) {
return testCompareFiles ( " sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml " ,
2008-04-10 20:54:54 +04:00
" sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr " ,
4 ) ;
2008-02-05 19:21:25 +03:00
}
2007-07-17 01:30:30 +04:00
2006-08-24 19:05:19 +04:00
int
main ( int argc , char * * argv )
{
int ret = 0 ;
2006-10-09 18:32:07 +04:00
2006-08-24 19:05:19 +04:00
progname = argv [ 0 ] ;
2006-10-09 18:32:07 +04:00
2006-08-24 19:05:19 +04:00
if ( argc > 1 ) {
2008-04-10 20:54:54 +04:00
fprintf ( stderr , " Usage: %s \n " , progname ) ;
exit ( EXIT_FAILURE ) ;
2006-08-24 19:05:19 +04:00
}
2006-10-09 18:32:07 +04:00
2007-11-14 13:35:58 +03:00
abs_top_srcdir = getenv ( " abs_top_srcdir " ) ;
2007-11-20 13:05:45 +03:00
if ( ! abs_top_srcdir ) {
fprintf ( stderr , " missing enviroment variable abs_top_srcdir \n " ) ;
2008-04-10 20:54:54 +04:00
exit ( EXIT_FAILURE ) ;
2007-11-20 13:05:45 +03:00
}
2007-11-14 13:35:58 +03:00
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML PV config (version 1) " ,
2008-04-10 20:54:54 +04:00
1 , testComparePVversion1 , NULL ) ! = 0 )
ret = - 1 ;
2006-09-12 05:16:22 +04:00
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML FV config (version 1) " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVversion1 , NULL ) ! = 0 )
ret = - 1 ;
2006-09-12 05:16:22 +04:00
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML PV config (version 2) " ,
2008-04-10 20:54:54 +04:00
1 , testComparePVversion2 , NULL ) ! = 0 )
ret = - 1 ;
2006-12-13 17:08:51 +03:00
2006-12-07 02:44:17 +03:00
if ( virtTestRun ( " SEXPR-2-XML PV config (Orig VFB) " ,
1 , testComparePVOrigVFB , NULL ) ! = 0 )
ret = - 1 ;
if ( virtTestRun ( " SEXPR-2-XML PV config (New VFB) " ,
1 , testComparePVNewVFB , NULL ) ! = 0 )
ret = - 1 ;
2006-08-24 19:05:19 +04:00
2006-12-07 02:44:17 +03:00
if ( virtTestRun ( " SEXPR-2-XML FV config (version 2) " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVversion2 , NULL ) ! = 0 )
ret = - 1 ;
2006-10-09 18:32:07 +04:00
2007-06-07 17:50:18 +04:00
if ( virtTestRun ( " SEXPR-2-XML PV config bootloader " ,
2008-04-10 20:54:54 +04:00
1 , testComparePVBootloader , NULL ) ! = 0 )
ret = - 1 ;
2007-06-07 17:50:18 +04:00
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML Disk File config " ,
2008-04-10 20:54:54 +04:00
1 , testCompareDiskFile , NULL ) ! = 0 )
ret = - 1 ;
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML Disk Block config " ,
2008-04-10 20:54:54 +04:00
1 , testCompareDiskBlock , NULL ) ! = 0 )
ret = - 1 ;
2006-10-09 18:32:07 +04:00
2007-11-20 13:05:45 +03:00
if ( virtTestRun ( " SEXPR-2-XML Disk Block shareable " ,
2008-04-10 20:54:54 +04:00
1 , testCompareDiskShareable , NULL ) ! = 0 )
ret = - 1 ;
2007-11-20 13:05:45 +03:00
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML Disk Driver blktap qcow config " ,
2008-04-10 20:54:54 +04:00
1 , testCompareDiskDrvBlktapQcow , NULL ) ! = 0 )
ret = - 1 ;
2006-10-09 18:32:07 +04:00
if ( virtTestRun ( " SEXPR-2-XML Disk Driver blktap raw config " ,
2008-04-10 20:54:54 +04:00
1 , testCompareDiskDrvBlktapRaw , NULL ) ! = 0 )
ret = - 1 ;
2006-08-24 19:05:19 +04:00
2006-11-10 14:13:01 +03:00
if ( virtTestRun ( " SEXPR-2-XML Resized memory config " ,
2008-04-10 20:54:54 +04:00
1 , testCompareResizedMemory , NULL ) ! = 0 )
ret = - 1 ;
2006-11-10 14:13:01 +03:00
2006-11-15 03:38:13 +03:00
if ( virtTestRun ( " SEXPR-2-XML net routed " ,
2008-04-10 20:54:54 +04:00
1 , testCompareNetRouted , NULL ) ! = 0 )
ret = - 1 ;
2006-11-15 03:38:13 +03:00
if ( virtTestRun ( " SEXPR-2-XML net bridged " ,
2008-04-10 20:54:54 +04:00
1 , testCompareNetBridged , NULL ) ! = 0 )
ret = - 1 ;
2006-11-15 03:38:13 +03:00
2007-04-11 20:06:30 +04:00
if ( virtTestRun ( " SEXPR-2-XML no source CDRom " ,
2008-04-10 20:54:54 +04:00
1 , testCompareNoSourceCDRom , NULL ) ! = 0 )
ret = - 1 ;
2007-04-11 20:06:30 +04:00
2007-07-19 01:08:22 +04:00
if ( virtTestRun ( " SEXPR-2-XML USB Mouse " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVInputUSBMouse , NULL ) ! = 0 )
ret = - 1 ;
2007-07-19 01:08:22 +04:00
if ( virtTestRun ( " SEXPR-2-XML USB Tablet " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVInputUSBTablet , NULL ) ! = 0 )
ret = - 1 ;
2007-07-19 01:08:22 +04:00
2007-07-17 01:30:30 +04:00
if ( virtTestRun ( " SEXPR-2-XML clock UTC " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVclockUTC , NULL ) ! = 0 )
ret = - 1 ;
2007-07-17 01:30:30 +04:00
if ( virtTestRun ( " SEXPR-2-XML clock Localtime " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVclockLocaltime , NULL ) ! = 0 )
ret = - 1 ;
2007-07-17 01:30:30 +04:00
2008-02-05 19:21:25 +03:00
if ( virtTestRun ( " SEXPR-2-XML FV kernel " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVKernel , NULL ) ! = 0 )
ret = - 1 ;
2008-02-05 19:21:25 +03:00
if ( virtTestRun ( " SEXPR-2-XML FV legacy VFB " ,
2008-04-10 20:54:54 +04:00
1 , testCompareFVLegacyVFB , NULL ) ! = 0 )
ret = - 1 ;
2008-02-05 19:21:25 +03:00
2006-08-24 19:05:19 +04:00
exit ( ret = = 0 ? EXIT_SUCCESS : EXIT_FAILURE ) ;
}
2007-03-15 10:43:16 +03:00
# else /* WITHOUT_XEN */
int
main ( void )
{
fprintf ( stderr , " libvirt compiled without Xen support \n " ) ;
2007-03-16 17:55:51 +03:00
return ( 0 ) ;
2007-03-15 10:43:16 +03:00
}
# endif /* WITH_XEN */