]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Test the previously mishandled PCI VPD characters
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Jan 2024 15:40:34 +0000 (16:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 31 Jan 2024 16:24:07 +0000 (17:24 +0100)
Modify the test data to validate '<>' and other characters.
Unfortunately the test suite doesn't have a proper end-to-end test, thus
we just add a XML->XML variant and also add data to the binary parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/nodedevschemadata/pci_0000_42_00_0_vpd.xml
tests/virpcimock.c
tests/virpcivpdtest.c

index 8b56e4f6b41821aeae4424eb7aaf1866af9013fe..c9a2901381abb08bc3546d0b8ecb123ac03c4cd1 100644 (file)
@@ -15,7 +15,7 @@
         <change_level>B1</change_level>
         <manufacture_id>foobar</manufacture_id>
         <part_number>MBF2H332A-AEEOT</part_number>
-        <serial_number>MT2113X00000</serial_number>
+        <serial_number>MT2113X00000&gt;&lt;</serial_number>
         <vendor_field index='0'>PCIeGen4 x8</vendor_field>
         <vendor_field index='2'>MBF2H332A-AEEOT</vendor_field>
         <vendor_field index='3'>3c53d07eec484d8aab34dabd24fe575aa</vendor_field>
@@ -25,7 +25,7 @@
         <asset_tag>fooasset</asset_tag>
         <vendor_field index='0'>vendorfield0</vendor_field>
         <vendor_field index='2'>vendorfield2</vendor_field>
-        <vendor_field index='A'>vendorfieldA</vendor_field>
+        <vendor_field index='A'>!@#$./&gt;&lt;</vendor_field>
         <system_field index='B'>systemfieldB</system_field>
         <system_field index='0'>systemfield0</system_field>
       </fields>
index 13b37bb23d46adc3abcbccd0e482300930c42705..2f98b0cf13e6160823ebdaa7768eee637a158dba 100644 (file)
@@ -966,9 +966,9 @@ init_env(void)
         't', 'e', 's', 't', 'n', 'a', 'm', 'e',
         PCI_VPD_LARGE_RESOURCE_FLAG | PCI_VPD_READ_ONLY_LARGE_RESOURCE_FLAG, 0x16, 0x00,
         'P', 'N', 0x02, '4', '2',
-        'E', 'C', 0x04, '4', '2', '4', '2',
+        'E', 'C', 0x04, '4', '<', '>', '2',
         'V', 'A', 0x02, 'E', 'X',
-        'R', 'V', 0x02, 0x31, 0x00,
+        'R', 'V', 0x02, 0x1D, 0x00,
         PCI_VPD_RESOURCE_END_VAL
     };
     struct pciVPD exampleVPD = {
index b4dd68b7aa8203609e0aabfc1d22ff78d2817e4d..ae5772d3f5672c9d26819d283ad9ac9edf8ee618 100644 (file)
@@ -424,7 +424,7 @@ testPCIVPDGetFieldValueFormat(const void *data G_GNUC_UNUSED)
 
 # define VPD_W_EXAMPLE_FIELDS \
     'V', 'Z', 0x02, '4', '2', \
-    'Y', 'A', 0x04, 'I', 'D', '4', '2', \
+    'Y', 'A', 0x04, '!', '<', '>', ':', \
     'Y', 'F', 0x02, 'E', 'X', \
     'Y', 'E', 0x00, \
     'R', 'W', 0x02, 0x00, 0x00
@@ -579,7 +579,7 @@ testVirPCIVPDParseFullVPD(const void *opaque G_GNUC_UNUSED)
     if (testVirPCIVPDValidateExampleReadOnlyFields(res))
         return -1;
 
-    if (STRNEQ_NULLABLE(res->rw->asset_tag, "ID42"))
+    if (STRNEQ_NULLABLE(res->rw->asset_tag, "!<>:"))
         return -1;
 
     if (!res->rw->vendor_specific)