2009-02-24 15:53:31 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "node_device_conf.h"
|
|
|
|
|
2013-06-07 15:10:28 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2024-02-22 13:02:01 +00:00
|
|
|
struct TestData {
|
|
|
|
const char *filename;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
static int
|
2024-02-22 13:02:01 +00:00
|
|
|
testCompareXMLToXMLFiles(const char *xml, const char *outfile, unsigned int flags)
|
2011-04-24 22:25:10 +00:00
|
|
|
{
|
2021-09-04 20:37:44 +00:00
|
|
|
g_autofree char *xmlData = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
2009-02-24 15:53:31 +00:00
|
|
|
int ret = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virNodeDeviceDef *dev = NULL;
|
|
|
|
virNodeDevCapsDef *caps;
|
2024-02-22 13:02:01 +00:00
|
|
|
size_t i;
|
2009-02-24 15:53:31 +00:00
|
|
|
|
2016-05-26 15:01:52 +00:00
|
|
|
if (virTestLoadFile(xml, &xmlData) < 0)
|
2009-02-24 15:53:31 +00:00
|
|
|
goto fail;
|
|
|
|
|
2022-10-18 10:34:07 +00:00
|
|
|
if (!(dev = virNodeDeviceDefParse(xmlData, NULL, EXISTING_DEVICE, NULL,
|
|
|
|
NULL, NULL, false)))
|
2009-02-24 15:53:31 +00:00
|
|
|
goto fail;
|
|
|
|
|
2018-05-19 12:00:58 +00:00
|
|
|
/* Calculate some things that are not read in */
|
|
|
|
for (caps = dev->caps; caps; caps = caps->next) {
|
2021-03-11 07:16:13 +00:00
|
|
|
virNodeDevCapData *data = &caps->data;
|
2018-05-19 12:00:58 +00:00
|
|
|
|
|
|
|
if (caps->data.type == VIR_NODE_DEV_CAP_STORAGE) {
|
|
|
|
if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) {
|
|
|
|
if (data->storage.flags &
|
|
|
|
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE) {
|
|
|
|
data->storage.logical_block_size = 2048;
|
|
|
|
data->storage.num_blocks =
|
|
|
|
data->storage.removable_media_size /
|
|
|
|
data->storage.logical_block_size;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
data->storage.logical_block_size = 512;
|
|
|
|
data->storage.num_blocks = data->storage.size /
|
|
|
|
data->storage.logical_block_size;
|
|
|
|
}
|
|
|
|
}
|
2024-02-22 13:02:01 +00:00
|
|
|
|
|
|
|
if (caps->data.type == VIR_NODE_DEV_CAP_MDEV &&
|
|
|
|
!(flags & VIR_NODE_DEVICE_XML_INACTIVE)) {
|
|
|
|
data->mdev.active_config.type = g_strdup(data->mdev.defined_config.type);
|
|
|
|
for (i = 0; i < data->mdev.defined_config.nattributes; i++) {
|
|
|
|
g_autoptr(virMediatedDeviceAttr) attr = g_new0(virMediatedDeviceAttr, 1);
|
|
|
|
|
|
|
|
attr->name = g_strdup(data->mdev.defined_config.attributes[i]->name);
|
|
|
|
attr->value = g_strdup(data->mdev.defined_config.attributes[i]->value);
|
|
|
|
VIR_APPEND_ELEMENT(data->mdev.active_config.attributes,
|
|
|
|
data->mdev.active_config.nattributes,
|
|
|
|
attr);
|
|
|
|
}
|
|
|
|
}
|
2018-05-19 12:00:58 +00:00
|
|
|
}
|
|
|
|
|
2024-02-22 13:02:01 +00:00
|
|
|
if (!(actual = virNodeDeviceDefFormat(dev, flags)))
|
2009-02-24 15:53:31 +00:00
|
|
|
goto fail;
|
|
|
|
|
2021-05-14 21:28:58 +00:00
|
|
|
if (virTestCompareToFile(actual, outfile) < 0)
|
2009-02-24 15:53:31 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
virNodeDeviceDefFree(dev);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
static int
|
|
|
|
testCompareXMLToXMLHelper(const void *data)
|
|
|
|
{
|
|
|
|
int result = -1;
|
2024-02-22 13:02:01 +00:00
|
|
|
const struct TestData *tdata = data;
|
2021-09-04 20:37:44 +00:00
|
|
|
g_autofree char *xml = NULL;
|
2021-05-14 21:28:58 +00:00
|
|
|
g_autofree char *outfile = NULL;
|
2011-04-24 22:25:10 +00:00
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
xml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
|
2024-02-22 13:02:01 +00:00
|
|
|
tdata->filename);
|
2011-04-24 22:25:10 +00:00
|
|
|
|
2024-02-22 13:02:01 +00:00
|
|
|
if (tdata->flags & VIR_NODE_DEVICE_XML_INACTIVE)
|
|
|
|
outfile = g_strdup_printf("%s/nodedevxml2xmlout/%s_inactive.xml", abs_srcdir,
|
|
|
|
tdata->filename);
|
|
|
|
else
|
|
|
|
outfile = g_strdup_printf("%s/nodedevxml2xmlout/%s.xml", abs_srcdir,
|
|
|
|
tdata->filename);
|
2021-05-14 21:28:58 +00:00
|
|
|
|
2024-02-22 13:02:01 +00:00
|
|
|
result = testCompareXMLToXMLFiles(xml, outfile, tdata->flags);
|
2011-04-24 22:25:10 +00:00
|
|
|
|
|
|
|
return result;
|
2009-02-24 15:53:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-04-29 16:21:20 +00:00
|
|
|
mymain(void)
|
2009-02-24 15:53:31 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2024-02-22 13:02:01 +00:00
|
|
|
#define DO_TEST_FLAGS(desc, filename, flags) \
|
|
|
|
do { \
|
|
|
|
struct TestData data = { filename, flags }; \
|
|
|
|
if (virTestRun(desc, testCompareXMLToXMLHelper, &data) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define DO_TEST(name) \
|
2024-02-22 13:02:01 +00:00
|
|
|
DO_TEST_FLAGS("Node device XML-2-XML " name, name, 0)
|
|
|
|
|
|
|
|
#define DO_TEST_INACTIVE(name) \
|
|
|
|
DO_TEST_FLAGS("Node device XML-2-XML INACTIVE " name, \
|
|
|
|
name, VIR_NODE_DEVICE_XML_INACTIVE)
|
2009-02-24 15:53:31 +00:00
|
|
|
|
|
|
|
DO_TEST("computer");
|
|
|
|
DO_TEST("DVD_GCC_4247N");
|
2009-12-14 13:58:23 +00: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 18:01:00 +00: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 17:17:05 +00: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");
|
2017-02-14 21:04:10 +00:00
|
|
|
DO_TEST("storage_serial_3600c0ff000d7a2a5d463ff4902000000");
|
2009-02-24 15:53:31 +00:00
|
|
|
DO_TEST("usb_device_1d6b_1_0000_00_1d_0_if0");
|
|
|
|
DO_TEST("usb_device_1d6b_1_0000_00_1d_0");
|
2014-05-15 08:13:45 +00:00
|
|
|
DO_TEST("pci_8086_4238_pcie_wireless");
|
|
|
|
DO_TEST("pci_8086_0c0c_snd_hda_intel");
|
2016-04-03 19:01:06 +00:00
|
|
|
DO_TEST("pci_0000_00_02_0_header_type");
|
|
|
|
DO_TEST("pci_0000_00_1c_0_header_type");
|
2016-03-21 14:49:30 +00:00
|
|
|
DO_TEST("scsi_target0_0_0");
|
2017-05-22 06:38:25 +00:00
|
|
|
DO_TEST("scsi_target1_0_0");
|
2016-04-03 19:01:06 +00: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");
|
2017-02-14 21:04:12 +00:00
|
|
|
DO_TEST("drm_renderD129");
|
2017-03-06 16:17:34 +00:00
|
|
|
DO_TEST("pci_0000_02_10_7_mdev_types");
|
2021-10-20 08:30:33 +00:00
|
|
|
DO_TEST("pci_0000_42_00_0_vpd");
|
2017-03-06 16:18:48 +00:00
|
|
|
DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b");
|
2024-02-22 13:02:01 +00:00
|
|
|
DO_TEST_INACTIVE("mdev_3627463d_b7f0_4fea_b468_f1da537d301b");
|
2017-05-22 06:38:22 +00:00
|
|
|
DO_TEST("ccw_0_0_ffff");
|
2020-09-14 19:11:44 +00:00
|
|
|
DO_TEST("css_0_0_ffff");
|
2022-05-13 10:31:16 +00:00
|
|
|
DO_TEST("css_0_0_ffff_channel_dev_addr");
|
2020-11-11 12:45:22 +00:00
|
|
|
DO_TEST("css_0_0_fffe_mdev_types");
|
2022-05-13 10:31:16 +00:00
|
|
|
DO_TEST("css_0_0_fffe_mdev_types_channel_dev_addr");
|
2020-12-03 17:59:34 +00:00
|
|
|
DO_TEST("ap_card07");
|
2020-12-03 17:59:36 +00:00
|
|
|
DO_TEST("ap_07_0038");
|
2020-12-03 17:59:39 +00:00
|
|
|
DO_TEST("ap_matrix");
|
2020-12-03 17:59:43 +00:00
|
|
|
DO_TEST("ap_matrix_mdev_types");
|
2020-12-03 17:59:39 +00:00
|
|
|
DO_TEST("mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad");
|
2021-05-14 21:29:00 +00:00
|
|
|
DO_TEST("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
|
|
|
|
DO_TEST("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
|
|
|
|
DO_TEST("mdev_fedc4916_1ca8_49ac_b176_871d16c13076");
|
2024-02-22 13:02:01 +00:00
|
|
|
DO_TEST_INACTIVE("mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad");
|
|
|
|
DO_TEST_INACTIVE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
|
|
|
|
DO_TEST_INACTIVE("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
|
|
|
|
DO_TEST_INACTIVE("mdev_fedc4916_1ca8_49ac_b176_871d16c13076");
|
2022-08-25 08:39:11 +00:00
|
|
|
DO_TEST("hba_vport_ops");
|
2024-02-22 13:02:01 +00:00
|
|
|
DO_TEST("mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c");
|
|
|
|
DO_TEST_INACTIVE("mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c");
|
2009-02-24 15:53:31 +00:00
|
|
|
|
2014-03-17 09:38:38 +00:00
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
2009-02-24 15:53:31 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 14:45:42 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|