diff options
| author | Ross Burton <ross.burton@arm.com> | 2022-12-08 12:10:39 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-09 13:18:41 +0000 |
| commit | 4ea8874a957aab419adea4291ed3e75c04f3ddec (patch) | |
| tree | e588b98e6aaedef0f515fc5e30837eba01d64228 /meta/recipes-core/libxml | |
| parent | 7458ad340f6bc05a2e12e85f3a09feef4d1bf4d2 (diff) | |
| download | poky-4ea8874a957aab419adea4291ed3e75c04f3ddec.tar.gz | |
libxml2: add more testing
Backport more test cases fixes from upstream, and add runsuite to the
ptests.
(From OE-Core rev: a6de5fa28fc90e0184d3d86822d06de5d93bbc44)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/libxml')
| -rw-r--r-- | meta/recipes-core/libxml/libxml2/fix-tests.patch | 222 | ||||
| -rwxr-xr-x | meta/recipes-core/libxml/libxml2/run-ptest | 2 | ||||
| -rw-r--r-- | meta/recipes-core/libxml/libxml2_2.10.3.bb | 1 |
3 files changed, 224 insertions, 1 deletions
diff --git a/meta/recipes-core/libxml/libxml2/fix-tests.patch b/meta/recipes-core/libxml/libxml2/fix-tests.patch new file mode 100644 index 0000000000..80678efcfe --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/fix-tests.patch | |||
| @@ -0,0 +1,222 @@ | |||
| 1 | Backport the following patches to fix the reader2 and runsuite test cases: | ||
| 2 | |||
| 3 | b92768cd tests: Enable "runsuite" test | ||
| 4 | 0ac8c15e python/tests/reader2: use absolute paths everywhere | ||
| 5 | b9ba5e1d python/tests/reader2: always exit(1) if a test fails | ||
| 6 | |||
| 7 | Upstream-Status: Backport | ||
| 8 | Signed-off-by: Ross Burton <ross.burton@arm.com> | ||
| 9 | |||
| 10 | diff --git a/python/tests/reader2.py b/python/tests/reader2.py | ||
| 11 | index 65cecd47..6e6353b4 100755 | ||
| 12 | --- a/python/tests/reader2.py | ||
| 13 | +++ b/python/tests/reader2.py | ||
| 14 | @@ -6,7 +6,6 @@ | ||
| 15 | import sys | ||
| 16 | import glob | ||
| 17 | import os | ||
| 18 | -import string | ||
| 19 | import libxml2 | ||
| 20 | try: | ||
| 21 | import StringIO | ||
| 22 | @@ -20,103 +19,104 @@ libxml2.debugMemory(1) | ||
| 23 | |||
| 24 | err = "" | ||
| 25 | basedir = os.path.dirname(os.path.realpath(__file__)) | ||
| 26 | -dir_prefix = os.path.join(basedir, "../../test/valid/") | ||
| 27 | +dir_prefix = os.path.realpath(os.path.join(basedir, "..", "..", "test", "valid")) | ||
| 28 | + | ||
| 29 | # This dictionary reflects the contents of the files | ||
| 30 | # ../../test/valid/*.xml.err that are not empty, except that | ||
| 31 | # the file paths in the messages start with ../../test/ | ||
| 32 | |||
| 33 | expect = { | ||
| 34 | '766956': | ||
| 35 | -"""../../test/valid/dtds/766956.dtd:2: parser error : PEReference: expecting ';' | ||
| 36 | +"""{0}/dtds/766956.dtd:2: parser error : PEReference: expecting ';' | ||
| 37 | %ä%ent; | ||
| 38 | ^ | ||
| 39 | -../../test/valid/dtds/766956.dtd:2: parser error : Content error in the external subset | ||
| 40 | +{0}/dtds/766956.dtd:2: parser error : Content error in the external subset | ||
| 41 | %ä%ent; | ||
| 42 | ^ | ||
| 43 | Entity: line 1: | ||
| 44 | value | ||
| 45 | ^ | ||
| 46 | -""", | ||
| 47 | +""".format(dir_prefix), | ||
| 48 | '781333': | ||
| 49 | -"""../../test/valid/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got | ||
| 50 | +"""{0}/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got | ||
| 51 | <a/> | ||
| 52 | ^ | ||
| 53 | -../../test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more child | ||
| 54 | +{0}/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more child | ||
| 55 | |||
| 56 | ^ | ||
| 57 | -""", | ||
| 58 | +""".format(dir_prefix), | ||
| 59 | 'cond_sect2': | ||
| 60 | -"""../../test/valid/dtds/cond_sect2.dtd:15: parser error : All markup of the conditional section is not in the same entity | ||
| 61 | +"""{0}/dtds/cond_sect2.dtd:15: parser error : All markup of the conditional section is not in the same entity | ||
| 62 | %ent; | ||
| 63 | ^ | ||
| 64 | Entity: line 1: | ||
| 65 | ]]> | ||
| 66 | ^ | ||
| 67 | -../../test/valid/dtds/cond_sect2.dtd:17: parser error : Content error in the external subset | ||
| 68 | +{0}/dtds/cond_sect2.dtd:17: parser error : Content error in the external subset | ||
| 69 | |||
| 70 | ^ | ||
| 71 | -""", | ||
| 72 | +""".format(dir_prefix), | ||
| 73 | 'rss': | ||
| 74 | -"""../../test/valid/rss.xml:177: element rss: validity error : Element rss does not carry attribute version | ||
| 75 | +"""{0}/rss.xml:177: element rss: validity error : Element rss does not carry attribute version | ||
| 76 | </rss> | ||
| 77 | ^ | ||
| 78 | -""", | ||
| 79 | +""".format(dir_prefix), | ||
| 80 | 't8': | ||
| 81 | -"""../../test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 82 | +"""{0}/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 83 | |||
| 84 | %defroot; %defmiddle; %deftest; | ||
| 85 | ^ | ||
| 86 | Entity: line 1: | ||
| 87 | <!ELEMENT root (middle) > | ||
| 88 | ^ | ||
| 89 | -../../test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 90 | +{0}/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 91 | |||
| 92 | %defroot; %defmiddle; %deftest; | ||
| 93 | ^ | ||
| 94 | Entity: line 1: | ||
| 95 | <!ELEMENT middle (test) > | ||
| 96 | ^ | ||
| 97 | -../../test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 98 | +{0}/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 99 | |||
| 100 | %defroot; %defmiddle; %deftest; | ||
| 101 | ^ | ||
| 102 | Entity: line 1: | ||
| 103 | <!ELEMENT test (#PCDATA) > | ||
| 104 | ^ | ||
| 105 | -""", | ||
| 106 | +""".format(dir_prefix), | ||
| 107 | 't8a': | ||
| 108 | -"""../../test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 109 | +"""{0}/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 110 | |||
| 111 | %defroot;%defmiddle;%deftest; | ||
| 112 | ^ | ||
| 113 | Entity: line 1: | ||
| 114 | <!ELEMENT root (middle) > | ||
| 115 | ^ | ||
| 116 | -../../test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 117 | +{0}/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 118 | |||
| 119 | %defroot;%defmiddle;%deftest; | ||
| 120 | ^ | ||
| 121 | Entity: line 1: | ||
| 122 | <!ELEMENT middle (test) > | ||
| 123 | ^ | ||
| 124 | -../../test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 125 | +{0}/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration | ||
| 126 | |||
| 127 | %defroot;%defmiddle;%deftest; | ||
| 128 | ^ | ||
| 129 | Entity: line 1: | ||
| 130 | <!ELEMENT test (#PCDATA) > | ||
| 131 | ^ | ||
| 132 | -""", | ||
| 133 | +""".format(dir_prefix), | ||
| 134 | 'xlink': | ||
| 135 | -"""../../test/valid/xlink.xml:450: element termdef: validity error : ID dt-arc already defined | ||
| 136 | +"""{0}/xlink.xml:450: element termdef: validity error : ID dt-arc already defined | ||
| 137 | <p><termdef id="dt-arc" term="Arc">An <ter | ||
| 138 | ^ | ||
| 139 | validity error : attribute def line 199 references an unknown ID "dt-xlg" | ||
| 140 | -""", | ||
| 141 | +""".format(dir_prefix), | ||
| 142 | } | ||
| 143 | |||
| 144 | # Add prefix_dir and extension to the keys | ||
| 145 | -expect = {"{}{}.xml".format(dir_prefix, key): val for key, val in expect.items()} | ||
| 146 | +expect = {os.path.join(dir_prefix, key + ".xml"): val for key, val in expect.items()} | ||
| 147 | |||
| 148 | def callback(ctx, str): | ||
| 149 | global err | ||
| 150 | @@ -124,11 +124,12 @@ def callback(ctx, str): | ||
| 151 | libxml2.registerErrorHandler(callback, "") | ||
| 152 | |||
| 153 | parsing_error_files = ["766956", "cond_sect2", "t8", "t8a"] | ||
| 154 | -expect_parsing_error = ["{}{}.xml".format(dir_prefix, f) for f in parsing_error_files] | ||
| 155 | +expect_parsing_error = [os.path.join(dir_prefix, f + ".xml") for f in parsing_error_files] | ||
| 156 | |||
| 157 | -valid_files = glob.glob(dir_prefix + "*.x*") | ||
| 158 | +valid_files = glob.glob(os.path.join(dir_prefix, "*.x*")) | ||
| 159 | assert valid_files, "found no valid files in '{}'".format(dir_prefix) | ||
| 160 | valid_files.sort() | ||
| 161 | +failures = 0 | ||
| 162 | for file in valid_files: | ||
| 163 | err = "" | ||
| 164 | reader = libxml2.newTextReaderFilename(file) | ||
| 165 | @@ -142,9 +143,15 @@ for file in valid_files: | ||
| 166 | #sys.exit(1) | ||
| 167 | if (err): | ||
| 168 | if not(file in expect and err == expect[file]): | ||
| 169 | + failures += 1 | ||
| 170 | print("Error: ", err) | ||
| 171 | if file in expect: | ||
| 172 | print("Expected: ", expect[file]) | ||
| 173 | + | ||
| 174 | +if failures: | ||
| 175 | + print("Failed %d tests" % failures) | ||
| 176 | + sys.exit(1) | ||
| 177 | + | ||
| 178 | # | ||
| 179 | # another separate test based on Stephane Bidoul one | ||
| 180 | # | ||
| 181 | @@ -337,9 +344,11 @@ while reader.Read() == 1: | ||
| 182 | if res != expect: | ||
| 183 | print("test5 failed: unexpected output") | ||
| 184 | print(res) | ||
| 185 | + sys.exit(1) | ||
| 186 | if err != "": | ||
| 187 | print("test5 failed: validation error found") | ||
| 188 | print(err) | ||
| 189 | + sys.exit(1) | ||
| 190 | |||
| 191 | # | ||
| 192 | # cleanup | ||
| 193 | diff --git a/runsuite.c b/runsuite.c | ||
| 194 | index 483490a2..a522d24b 100644 | ||
| 195 | --- a/runsuite.c | ||
| 196 | +++ b/runsuite.c | ||
| 197 | @@ -1054,13 +1054,18 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { | ||
| 198 | old_tests = nb_tests; | ||
| 199 | old_leaks = nb_leaks; | ||
| 200 | xsdTest(); | ||
| 201 | - if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) | ||
| 202 | - printf("Ran %d tests, no errors\n", nb_tests - old_tests); | ||
| 203 | - else | ||
| 204 | - printf("Ran %d tests, %d errors, %d leaks\n", | ||
| 205 | - nb_tests - old_tests, | ||
| 206 | - nb_errors - old_errors, | ||
| 207 | - nb_leaks - old_leaks); | ||
| 208 | + printf("Ran %d tests, %d errors, %d leaks\n", | ||
| 209 | + nb_tests - old_tests, | ||
| 210 | + nb_errors - old_errors, | ||
| 211 | + nb_leaks - old_leaks); | ||
| 212 | + if (nb_errors - old_errors == 10) { | ||
| 213 | + printf("10 errors were expected\n"); | ||
| 214 | + nb_errors = old_errors; | ||
| 215 | + } else { | ||
| 216 | + printf("10 errors were expected, got %d errors\n", | ||
| 217 | + nb_errors - old_errors); | ||
| 218 | + nb_errors = old_errors + 1; | ||
| 219 | + } | ||
| 220 | old_errors = nb_errors; | ||
| 221 | old_tests = nb_tests; | ||
| 222 | old_leaks = nb_leaks; | ||
diff --git a/meta/recipes-core/libxml/libxml2/run-ptest b/meta/recipes-core/libxml/libxml2/run-ptest index d5c7bb5b02..f252a78f17 100755 --- a/meta/recipes-core/libxml/libxml2/run-ptest +++ b/meta/recipes-core/libxml/libxml2/run-ptest | |||
| @@ -5,7 +5,7 @@ set -e | |||
| 5 | export LC_ALL=en_US.UTF-8 | 5 | export LC_ALL=en_US.UTF-8 |
| 6 | 6 | ||
| 7 | # testModule isn't that useful and hard-codes buildtree, so we don't run that | 7 | # testModule isn't that useful and hard-codes buildtree, so we don't run that |
| 8 | TESTS="runtest testrecurse testchar testdict testThreads runxmlconf testapi" | 8 | TESTS="runtest runsuite testrecurse testchar testdict testThreads runxmlconf testapi" |
| 9 | 9 | ||
| 10 | for T in $TESTS; do | 10 | for T in $TESTS; do |
| 11 | echo Running $T | 11 | echo Running $T |
diff --git a/meta/recipes-core/libxml/libxml2_2.10.3.bb b/meta/recipes-core/libxml/libxml2_2.10.3.bb index 32b37aacdb..645d102e78 100644 --- a/meta/recipes-core/libxml/libxml2_2.10.3.bb +++ b/meta/recipes-core/libxml/libxml2_2.10.3.bb | |||
| @@ -16,6 +16,7 @@ inherit gnomebase | |||
| 16 | SRC_URI += "http://www.w3.org/XML/Test/xmlts20080827.tar.gz;subdir=${BP};name=testtar \ | 16 | SRC_URI += "http://www.w3.org/XML/Test/xmlts20080827.tar.gz;subdir=${BP};name=testtar \ |
| 17 | file://run-ptest \ | 17 | file://run-ptest \ |
| 18 | file://libxml-64bit.patch \ | 18 | file://libxml-64bit.patch \ |
| 19 | file://fix-tests.patch \ | ||
| 19 | file://install-tests.patch \ | 20 | file://install-tests.patch \ |
| 20 | file://libxml-m4-use-pkgconfig.patch \ | 21 | file://libxml-m4-use-pkgconfig.patch \ |
| 21 | " | 22 | " |
