2009-02-24 15:53:31 +00: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 "node_device_conf.h"
# include "testutilsqemu.h"
2013-04-03 12:36:23 +02:00
# include "virstring.h"
2009-02-24 15:53:31 +00:00
2013-06-07 17:10:28 +02:00
# define VIR_FROM_THIS VIR_FROM_NONE
2011-04-25 00:25:10 +02:00
static int
testCompareXMLToXMLFiles ( const char * xml )
{
char * xmlData = NULL ;
2009-02-24 15:53:31 +00:00
char * actual = NULL ;
int ret = - 1 ;
virNodeDeviceDefPtr dev = NULL ;
2016-05-26 17:01:52 +02:00
if ( virTestLoadFile ( xml , & xmlData ) < 0 )
2009-02-24 15:53:31 +00:00
goto fail ;
2012-02-10 12:51:47 +08:00
if ( ! ( dev = virNodeDeviceDefParseString ( xmlData , EXISTING_DEVICE , NULL ) ) )
2009-02-24 15:53:31 +00:00
goto fail ;
2010-02-10 10:40:18 +00:00
if ( ! ( actual = virNodeDeviceDefFormat ( dev ) ) )
2009-02-24 15:53:31 +00:00
goto fail ;
if ( STRNEQ ( xmlData , actual ) ) {
2016-05-26 17:01:54 +02:00
virTestDifferenceFull ( stderr , xmlData , xml , actual , NULL ) ;
2009-02-24 15:53:31 +00:00
goto fail ;
}
ret = 0 ;
fail :
2012-02-02 16:16:43 -07:00
VIR_FREE ( xmlData ) ;
VIR_FREE ( actual ) ;
2009-02-24 15:53:31 +00:00
virNodeDeviceDefFree ( dev ) ;
return ret ;
}
2011-04-25 00:25:10 +02:00
static int
testCompareXMLToXMLHelper ( const void * data )
{
int result = - 1 ;
char * xml = NULL ;
if ( virAsprintf ( & xml , " %s/nodedevschemadata/%s.xml " ,
abs_srcdir , ( const char * ) data ) < 0 )
return - 1 ;
result = testCompareXMLToXMLFiles ( xml ) ;
2012-02-02 16:16:43 -07:00
VIR_FREE ( xml ) ;
2011-04-25 00:25:10 +02:00
return result ;
2009-02-24 15:53:31 +00:00
}
static int
2011-04-29 10:21:20 -06:00
mymain ( void )
2009-02-24 15:53:31 +00:00
{
int ret = 0 ;
2013-09-20 19:13:35 +01:00
# define DO_TEST(name) \
2016-05-26 17:01:50 +02:00
if ( virTestRun ( " Node device XML-2-XML " name , \
testCompareXMLToXMLHelper , ( name ) ) < 0 ) \
2009-02-24 15:53:31 +00:00
ret = - 1
DO_TEST ( " computer " ) ;
DO_TEST ( " DVD_GCC_4247N " ) ;
2009-12-14 14:58:23 +01:00
DO_TEST ( " DVD_with_media " ) ;
2009-02-24 15:53:31 +00:00
DO_TEST ( " net_00_13_02_b9_f9_d3 " ) ;
DO_TEST ( " net_00_15_58_2f_e9_55 " ) ;
DO_TEST ( " pci_1002_71c4 " ) ;
2013-06-23 14:01:00 -04:00
DO_TEST ( " pci_8086_10c9_sriov_pf " ) ;
2009-02-24 15:53:31 +00:00
DO_TEST ( " pci_8086_27c5_scsi_host_0 " ) ;
2014-06-05 13:17:05 -04:00
DO_TEST ( " pci_8086_27c5_scsi_host_0_unique_id " ) ;
2009-02-24 15:53:31 +00:00
DO_TEST ( " pci_8086_27c5_scsi_host_scsi_device_lun0 " ) ;
DO_TEST ( " pci_8086_27c5_scsi_host_scsi_host " ) ;
DO_TEST ( " pci_8086_27c5_scsi_host " ) ;
DO_TEST ( " storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE " ) ;
DO_TEST ( " usb_device_1d6b_1_0000_00_1d_0_if0 " ) ;
DO_TEST ( " usb_device_1d6b_1_0000_00_1d_0 " ) ;
2014-05-15 10:13:45 +02:00
DO_TEST ( " pci_8086_4238_pcie_wireless " ) ;
DO_TEST ( " pci_8086_0c0c_snd_hda_intel " ) ;
2016-04-03 21:01:06 +02:00
DO_TEST ( " pci_0000_00_02_0_header_type " ) ;
DO_TEST ( " pci_0000_00_1c_0_header_type " ) ;
2016-03-21 15:49:30 +01:00
DO_TEST ( " scsi_target0_0_0 " ) ;
2016-04-03 21:01:06 +02:00
DO_TEST ( " pci_0000_02_10_7_sriov " ) ;
DO_TEST ( " pci_0000_02_10_7_sriov_vfs " ) ;
DO_TEST ( " pci_0000_02_10_7_sriov_zero_vfs_max_count " ) ;
DO_TEST ( " pci_0000_02_10_7_sriov_pf_vfs_all " ) ;
DO_TEST ( " pci_0000_02_10_7_sriov_pf_vfs_all_header_type " ) ;
2009-02-24 15:53:31 +00:00
2014-03-17 10:38:38 +01:00
return ret = = 0 ? EXIT_SUCCESS : EXIT_FAILURE ;
2009-02-24 15:53:31 +00:00
}
VIRT_TEST_MAIN ( mymain )