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>
2008-04-26 18:22:02 +04:00
# include <unistd.h>
2006-08-24 19:05:19 +04:00
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 ;
2008-04-26 18:22:02 +04:00
static char * abs_srcdir ;
2006-08-24 19:05:19 +04:00
# define MAX_FILE 4096
2008-04-26 18:22:02 +04:00
static int testCompareFiles ( const char * xml , const char * sexpr ,
2007-11-14 13:35:58 +03:00
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
2008-04-26 18:22:02 +04:00
if ( virtTestLoadFile ( xml , & xmlPtr , MAX_FILE ) < 0 ) {
printf ( " Missing %s \n " , xml ) ;
goto fail ;
}
2006-08-24 19:05:19 +04:00
2008-04-26 18:22:02 +04:00
if ( virtTestLoadFile ( sexpr , & sexprPtr , MAX_FILE ) < 0 ) {
printf ( " Missing %s \n " , sexpr ) ;
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
2008-04-26 18:22:02 +04:00
if ( STRNEQ ( xmlData , gotxml ) ) {
virtTestDifference ( stderr , xmlData , gotxml ) ;
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
}
2008-04-26 18:22:02 +04:00
struct testInfo {
const char * input ;
const char * output ;
int version ;
} ;
2007-07-19 01:08:22 +04:00
2008-04-26 18:22:02 +04:00
static int testCompareHelper ( const void * data ) {
const struct testInfo * info = data ;
char xml [ PATH_MAX ] ;
char args [ PATH_MAX ] ;
snprintf ( xml , PATH_MAX , " %s/sexpr2xmldata/sexpr2xml-%s.xml " ,
abs_srcdir , info - > input ) ;
snprintf ( args , PATH_MAX , " %s/sexpr2xmldata/sexpr2xml-%s.sexpr " ,
abs_srcdir , info - > output ) ;
return testCompareFiles ( xml , args , info - > version ) ;
2008-02-05 19:21:25 +03:00
}
2007-07-17 01:30:30 +04:00
2008-05-29 19:31:49 +04:00
static int
mymain ( int argc , char * * argv )
2006-08-24 19:05:19 +04:00
{
int ret = 0 ;
2008-04-26 18:22:02 +04:00
char cwd [ PATH_MAX ] ;
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 ) ;
2008-05-29 19:31:49 +04:00
return ( EXIT_FAILURE ) ;
2006-08-24 19:05:19 +04:00
}
2006-10-09 18:32:07 +04:00
2008-04-26 18:22:02 +04:00
abs_srcdir = getenv ( " abs_srcdir " ) ;
if ( ! abs_srcdir )
abs_srcdir = getcwd ( cwd , sizeof ( cwd ) ) ;
if ( argc > 1 ) {
fprintf ( stderr , " Usage: %s \n " , progname ) ;
2008-05-29 19:31:49 +04:00
return ( EXIT_FAILURE ) ;
2007-11-20 13:05:45 +03:00
}
2007-11-14 13:35:58 +03:00
2008-04-26 18:22:02 +04:00
# define DO_TEST(in, out, version) \
do { \
struct testInfo info = { in , out , version } ; \
if ( virtTestRun ( " Xen SEXPR-2-XML " in " -> " out , \
1 , testCompareHelper , & info ) < 0 ) \
ret = - 1 ; \
} while ( 0 )
DO_TEST ( " pv " , " pv " , 1 ) ;
DO_TEST ( " fv " , " fv " , 1 ) ;
DO_TEST ( " pv " , " pv " , 2 ) ;
DO_TEST ( " fv-v2 " , " fv-v2 " , 2 ) ;
DO_TEST ( " pv-vfb-orig " , " pv-vfb-orig " , 2 ) ;
DO_TEST ( " pv-vfb-new " , " pv-vfb-new " , 3 ) ;
DO_TEST ( " pv-bootloader " , " pv-bootloader " , 1 ) ;
DO_TEST ( " disk-file " , " disk-file " , 2 ) ;
DO_TEST ( " disk-block " , " disk-block " , 2 ) ;
DO_TEST ( " disk-block-shareable " , " disk-block-shareable " , 2 ) ;
DO_TEST ( " disk-drv-blktap-raw " , " disk-drv-blktap-raw " , 2 ) ;
DO_TEST ( " disk-drv-blktap-qcow " , " disk-drv-blktap-qcow " , 2 ) ;
2008-05-08 18:41:56 +04:00
DO_TEST ( " curmem " , " curmem " , 2 ) ;
2008-04-26 18:22:02 +04:00
DO_TEST ( " net-routed " , " net-routed " , 2 ) ;
DO_TEST ( " net-bridged " , " net-bridged " , 2 ) ;
2008-04-30 16:30:55 +04:00
DO_TEST ( " net-e1000 " , " net-e1000 " , 2 ) ;
2008-05-08 18:41:56 +04:00
DO_TEST ( " no-source-cdrom " , " no-source-cdrom " , 2 ) ;
2008-04-26 18:22:02 +04:00
DO_TEST ( " fv-utc " , " fv-utc " , 1 ) ;
DO_TEST ( " fv-localtime " , " fv-localtime " , 1 ) ;
DO_TEST ( " fv-usbmouse " , " fv-usbmouse " , 1 ) ;
DO_TEST ( " fv-usbmouse " , " fv-usbmouse " , 1 ) ;
DO_TEST ( " fv-kernel " , " fv-kernel " , 1 ) ;
DO_TEST ( " fv-serial-null " , " fv-serial-null " , 1 ) ;
DO_TEST ( " fv-serial-file " , " fv-serial-file " , 1 ) ;
DO_TEST ( " fv-serial-stdio " , " fv-serial-stdio " , 1 ) ;
DO_TEST ( " fv-serial-pty " , " fv-serial-pty " , 1 ) ;
DO_TEST ( " fv-serial-pipe " , " fv-serial-pipe " , 1 ) ;
DO_TEST ( " fv-serial-tcp " , " fv-serial-tcp " , 1 ) ;
DO_TEST ( " fv-serial-udp " , " fv-serial-udp " , 1 ) ;
DO_TEST ( " fv-serial-tcp-telnet " , " fv-serial-tcp-telnet " , 1 ) ;
DO_TEST ( " fv-serial-unix " , " fv-serial-unix " , 1 ) ;
DO_TEST ( " fv-parallel-tcp " , " fv-parallel-tcp " , 1 ) ;
2008-02-05 19:21:25 +03:00
2008-05-07 18:04:40 +04:00
DO_TEST ( " fv-sound " , " fv-sound " , 1 ) ;
DO_TEST ( " fv-sound-all " , " fv-sound-all " , 1 ) ;
2008-05-29 19:31:49 +04:00
return ( ret = = 0 ? EXIT_SUCCESS : EXIT_FAILURE ) ;
2006-08-24 19:05:19 +04:00
}
2008-05-29 19:31:49 +04:00
VIRT_TEST_MAIN ( mymain )
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 */