qemu: Validate spapr-vio addresses
[libvirt/ericb.git] / tests / nodedevxml2xmltest.c
blob9248a60fbf54bb1a126cb2384f3f3659a6d65b75
1 #include <config.h>
3 #include <unistd.h>
5 #include <sys/types.h>
6 #include <fcntl.h>
8 #include "internal.h"
9 #include "testutils.h"
10 #include "node_device_conf.h"
11 #include "testutilsqemu.h"
12 #include "virstring.h"
14 #define VIR_FROM_THIS VIR_FROM_NONE
16 static int
17 testCompareXMLToXMLFiles(const char *xml)
19 char *xmlData = NULL;
20 char *actual = NULL;
21 int ret = -1;
22 virNodeDeviceDefPtr dev = NULL;
23 virNodeDevCapsDefPtr caps;
25 if (virTestLoadFile(xml, &xmlData) < 0)
26 goto fail;
28 if (!(dev = virNodeDeviceDefParseString(xmlData, EXISTING_DEVICE, NULL)))
29 goto fail;
31 /* Calculate some things that are not read in */
32 for (caps = dev->caps; caps; caps = caps->next) {
33 virNodeDevCapDataPtr data = &caps->data;
35 if (caps->data.type == VIR_NODE_DEV_CAP_STORAGE) {
36 if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) {
37 if (data->storage.flags &
38 VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE) {
39 data->storage.logical_block_size = 2048;
40 data->storage.num_blocks =
41 data->storage.removable_media_size /
42 data->storage.logical_block_size;
44 } else {
45 data->storage.logical_block_size = 512;
46 data->storage.num_blocks = data->storage.size /
47 data->storage.logical_block_size;
52 if (!(actual = virNodeDeviceDefFormat(dev)))
53 goto fail;
55 if (STRNEQ(xmlData, actual)) {
56 virTestDifferenceFull(stderr, xmlData, xml, actual, NULL);
57 goto fail;
60 ret = 0;
62 fail:
63 VIR_FREE(xmlData);
64 VIR_FREE(actual);
65 virNodeDeviceDefFree(dev);
66 return ret;
69 static int
70 testCompareXMLToXMLHelper(const void *data)
72 int result = -1;
73 char *xml = NULL;
75 if (virAsprintf(&xml, "%s/nodedevschemadata/%s.xml",
76 abs_srcdir, (const char*)data) < 0)
77 return -1;
79 result = testCompareXMLToXMLFiles(xml);
81 VIR_FREE(xml);
82 return result;
86 static int
87 mymain(void)
89 int ret = 0;
91 #define DO_TEST(name) \
92 if (virTestRun("Node device XML-2-XML " name, \
93 testCompareXMLToXMLHelper, (name)) < 0) \
94 ret = -1
96 DO_TEST("computer");
97 DO_TEST("DVD_GCC_4247N");
98 DO_TEST("DVD_with_media");
99 DO_TEST("net_00_13_02_b9_f9_d3");
100 DO_TEST("net_00_15_58_2f_e9_55");
101 DO_TEST("pci_1002_71c4");
102 DO_TEST("pci_8086_10c9_sriov_pf");
103 DO_TEST("pci_8086_27c5_scsi_host_0");
104 DO_TEST("pci_8086_27c5_scsi_host_0_unique_id");
105 DO_TEST("pci_8086_27c5_scsi_host_scsi_device_lun0");
106 DO_TEST("pci_8086_27c5_scsi_host_scsi_host");
107 DO_TEST("pci_8086_27c5_scsi_host");
108 DO_TEST("storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE");
109 DO_TEST("storage_serial_3600c0ff000d7a2a5d463ff4902000000");
110 DO_TEST("usb_device_1d6b_1_0000_00_1d_0_if0");
111 DO_TEST("usb_device_1d6b_1_0000_00_1d_0");
112 DO_TEST("pci_8086_4238_pcie_wireless");
113 DO_TEST("pci_8086_0c0c_snd_hda_intel");
114 DO_TEST("pci_0000_00_02_0_header_type");
115 DO_TEST("pci_0000_00_1c_0_header_type");
116 DO_TEST("scsi_target0_0_0");
117 DO_TEST("scsi_target1_0_0");
118 DO_TEST("pci_0000_02_10_7_sriov");
119 DO_TEST("pci_0000_02_10_7_sriov_vfs");
120 DO_TEST("pci_0000_02_10_7_sriov_zero_vfs_max_count");
121 DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all");
122 DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type");
123 DO_TEST("drm_renderD129");
124 DO_TEST("pci_0000_02_10_7_mdev_types");
125 DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b");
126 DO_TEST("ccw_0_0_ffff");
128 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
131 VIR_TEST_MAIN(mymain)