
On Fri, May 14, 2021 at 04:28:58PM -0500, Jonathon Jongsma wrote:
Currently, we're loading and parsing the xml from the input file, and then formatting it and then comparing it directly back to the input file. This works for now, but is severely limiting as it relies on the input file being fully-specified and in the exact order as the output xml format.
If optional elements are ommitted in the input XML, the output xml may include default values for the ommitted elements and thus the output will not match the input.
In order to allow more flexibility in testing, save the expected output to a seprate 'out' directory similar to what most of the other xml2xml tests are already doing.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- tests/nodedevxml2xmlout/DVD_GCC_4247N.xml | 15 +++++++++ tests/nodedevxml2xmlout/DVD_with_media.xml | 18 ++++++++++ tests/nodedevxml2xmlout/ap_07_0038.xml | 9 +++++ tests/nodedevxml2xmlout/ap_card07.xml | 8 +++++ tests/nodedevxml2xmlout/ap_matrix.xml | 7 ++++ .../ap_matrix_mdev_types.xml | 14 ++++++++ tests/nodedevxml2xmlout/ccw_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/computer.xml | 16 +++++++++ .../css_0_0_fffe_mdev_types.xml | 17 ++++++++++ tests/nodedevxml2xmlout/css_0_0_ffff.xml | 10 ++++++ tests/nodedevxml2xmlout/drm_renderD129.xml | 10 ++++++ ...v_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 8 +++++ ...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 9 +++++ .../net_00_13_02_b9_f9_d3.xml | 21 ++++++++++++ .../net_00_15_58_2f_e9_55.xml | 21 ++++++++++++ .../pci_0000_00_02_0_header_type.xml | 16 +++++++++ .../pci_0000_00_1c_0_header_type.xml | 21 ++++++++++++ .../pci_0000_02_10_7_mdev_types.xml | 33 +++++++++++++++++++ .../pci_0000_02_10_7_sriov.xml | 24 ++++++++++++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 ++++++++++++++++ ...0_02_10_7_sriov_pf_vfs_all_header_type.xml | 31 +++++++++++++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 27 +++++++++++++++ ..._0000_02_10_7_sriov_zero_vfs_max_count.xml | 22 +++++++++++++ tests/nodedevxml2xmlout/pci_1002_71c4.xml | 14 ++++++++ .../pci_8086_0c0c_snd_hda_intel.xml | 17 ++++++++++ .../pci_8086_10c9_sriov_pf.xml | 18 ++++++++++ .../pci_8086_27c5_scsi_host.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0.xml | 7 ++++ .../pci_8086_27c5_scsi_host_0_unique_id.xml | 8 +++++ ...i_8086_27c5_scsi_host_scsi_device_lun0.xml | 11 +++++++ .../pci_8086_27c5_scsi_host_scsi_host.xml | 7 ++++ .../pci_8086_4238_pcie_wireless.xml | 27 +++++++++++++++ tests/nodedevxml2xmlout/scsi_target0_0_0.xml | 7 ++++ tests/nodedevxml2xmlout/scsi_target1_0_0.xml | 12 +++++++ ...rial_3600c0ff000d7a2a5d463ff4902000000.xml | 19 +++++++++++ ...al_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml | 14 ++++++++ .../usb_device_1d6b_1_0000_00_1d_0.xml | 10 ++++++ .../usb_device_1d6b_1_0000_00_1d_0_if0.xml | 10 ++++++ tests/nodedevxml2xmltest.c | 12 ++++--- 39 files changed, 591 insertions(+), 5 deletions(-) create mode 100644 tests/nodedevxml2xmlout/DVD_GCC_4247N.xml create mode 100644 tests/nodedevxml2xmlout/DVD_with_media.xml create mode 100644 tests/nodedevxml2xmlout/ap_07_0038.xml create mode 100644 tests/nodedevxml2xmlout/ap_card07.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix.xml create mode 100644 tests/nodedevxml2xmlout/ap_matrix_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/ccw_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/computer.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_fffe_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/css_0_0_ffff.xml create mode 100644 tests/nodedevxml2xmlout/drm_renderD129.xml create mode 100644 tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml create mode 100644 tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml create mode 100644 tests/nodedevxml2xmlout/net_00_13_02_b9_f9_d3.xml create mode 100644 tests/nodedevxml2xmlout/net_00_15_58_2f_e9_55.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_02_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_00_1c_0_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_mdev_types.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevxml2xmlout/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml create mode 100644 tests/nodedevxml2xmlout/pci_1002_71c4.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_0c0c_snd_hda_intel.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_10c9_sriov_pf.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_0_unique_id.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_device_lun0.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_27c5_scsi_host_scsi_host.xml create mode 100644 tests/nodedevxml2xmlout/pci_8086_4238_pcie_wireless.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target0_0_0.xml create mode 100644 tests/nodedevxml2xmlout/scsi_target1_0_0.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml create mode 100644 tests/nodedevxml2xmlout/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0.xml create mode 100644 tests/nodedevxml2xmlout/usb_device_1d6b_1_0000_00_1d_0_if0.xml
[...]
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 4ebd578ccc..04d238bbca 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -14,7 +14,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE
static int -testCompareXMLToXMLFiles(const char *xml) +testCompareXMLToXMLFiles(const char *xml, const char *outfile) { char *xmlData = NULL; char *actual = NULL; @@ -52,10 +52,8 @@ testCompareXMLToXMLFiles(const char *xml) if (!(actual = virNodeDeviceDefFormat(dev))) goto fail;
- if (STRNEQ(xmlData, actual)) { - virTestDifferenceFull(stderr, xmlData, xml, actual, NULL); + if (virTestCompareToFile(actual, outfile) < 0) goto fail; - }
ret = 0;
@@ -71,11 +69,15 @@ testCompareXMLToXMLHelper(const void *data) { int result = -1; char *xml = NULL; + char *outfile = NULL;
xml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, (const char *)data);
- result = testCompareXMLToXMLFiles(xml); + outfile = g_strdup_printf("%s/nodedevxml2xmlout/%s.xml", abs_srcdir, + (const char *)data); + + result = testCompareXMLToXMLFiles(xml, outfile);
VIR_FREE(xml);
VIR_FREE(outfile);
return result;
Pavel