William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1 | From 6172ccd1e74bc181f5298f19e240234e12876abe Mon Sep 17 00:00:00 2001 |
| 2 | From: Tony Tascioglu <tony.tascioglu@windriver.com> |
| 3 | Date: Tue, 11 May 2021 11:57:46 -0400 |
| 4 | Subject: [PATCH] Add 'install-ptest' rule. |
| 5 | |
| 6 | Print a standard result line for each test. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 8 | The patch needs a rework according to comments in the merge request. |
| 9 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | Signed-off-by: Mihaela Sendrea <mihaela.sendrea@enea.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | Signed-off-by: Andrej Valek <andrej.valek@siemens.com> |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 12 | Upstream-Status: Inappropriate [https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/137] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 14 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 15 | Signed-off-by: Tony Tascioglu <tony.tascioglu@windriver.com> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 16 | --- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 17 | Makefile.am | 9 +++ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 18 | runsuite.c | 1 + |
| 19 | runtest.c | 2 + |
| 20 | runxmlconf.c | 1 + |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 21 | testapi.c | 122 ++++++++++++++++++++++++++------------- |
| 22 | testchar.c | 156 +++++++++++++++++++++++++++++++++++--------------- |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 23 | testdict.c | 1 + |
| 24 | testlimits.c | 1 + |
| 25 | testrecurse.c | 2 + |
| 26 | 9 files changed, 210 insertions(+), 85 deletions(-) |
| 27 | |
| 28 | diff --git a/Makefile.am b/Makefile.am |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 29 | index 05d1671f..ae622745 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 30 | --- a/Makefile.am |
| 31 | +++ b/Makefile.am |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 32 | @@ -198,6 +198,15 @@ runxmlconf_LDADD= $(LDADDS) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | #testOOM_DEPENDENCIES = $(DEPS) |
| 34 | #testOOM_LDADD= $(LDADDS) |
| 35 | |
| 36 | +install-ptest: |
| 37 | + @(if [ -d .libs ] ; then cd .libs; fi; \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 38 | + install $(check_PROGRAMS) $(DESTDIR)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | + cp -r $(srcdir)/test $(DESTDIR) |
| 40 | + cp -r $(srcdir)/result $(DESTDIR) |
| 41 | + cp -r $(srcdir)/python $(DESTDIR) |
| 42 | + cp Makefile $(DESTDIR) |
| 43 | + sed -i -e 's|^Makefile:|_Makefile:|' $(DESTDIR)/Makefile |
| 44 | + |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | runtests: runtest$(EXEEXT) testrecurse$(EXEEXT) testapi$(EXEEXT) \ |
| 46 | testchar$(EXEEXT) testdict$(EXEEXT) runxmlconf$(EXEEXT) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | [ -d test ] || $(LN_S) $(srcdir)/test . |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 48 | diff --git a/runsuite.c b/runsuite.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 49 | index d24b5ec3..f7ff2521 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 50 | --- a/runsuite.c |
| 51 | +++ b/runsuite.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 52 | @@ -1147,6 +1147,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | |
| 54 | if (logfile != NULL) |
| 55 | fclose(logfile); |
| 56 | + printf("%s: runsuite\n\n", (ret == 0) ? "PASS" : "FAIL"); |
| 57 | return(ret); |
| 58 | } |
| 59 | #else /* !SCHEMAS */ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 60 | diff --git a/runtest.c b/runtest.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 61 | index ffa98d04..470f95cb 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 62 | --- a/runtest.c |
| 63 | +++ b/runtest.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 64 | @@ -4508,6 +4508,7 @@ launchTests(testDescPtr tst) { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 65 | xmlCharEncCloseFunc(ebcdicHandler); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 66 | xmlCharEncCloseFunc(eucJpHandler); |
| 67 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | + printf("%s: %s\n", (err == 0) ? "PASS" : "FAIL", tst->desc); |
| 69 | return(err); |
| 70 | } |
| 71 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 72 | @@ -4588,6 +4589,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | xmlCleanupParser(); |
| 74 | xmlMemoryDump(); |
| 75 | |
| 76 | + printf("%s: runtest\n\n", (ret == 0) ? "PASS" : "FAIL"); |
| 77 | return(ret); |
| 78 | } |
| 79 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 80 | diff --git a/runxmlconf.c b/runxmlconf.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 81 | index 70f61017..e882b3a1 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 82 | --- a/runxmlconf.c |
| 83 | +++ b/runxmlconf.c |
| 84 | @@ -595,6 +595,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | |
| 86 | if (logfile != NULL) |
| 87 | fclose(logfile); |
| 88 | + printf("%s: runxmlconf\n", (ret == 0) ? "PASS" : "FAIL"); |
| 89 | return(ret); |
| 90 | } |
| 91 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 92 | diff --git a/testapi.c b/testapi.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 93 | index ff8b470d..52b51d78 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 94 | --- a/testapi.c |
| 95 | +++ b/testapi.c |
| 96 | @@ -1246,49 +1246,91 @@ static int |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | testlibxml2(void) |
| 98 | { |
| 99 | int test_ret = 0; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 100 | - |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | - test_ret += test_HTMLparser(); |
| 102 | - test_ret += test_HTMLtree(); |
| 103 | - test_ret += test_SAX2(); |
| 104 | - test_ret += test_c14n(); |
| 105 | - test_ret += test_catalog(); |
| 106 | - test_ret += test_chvalid(); |
| 107 | - test_ret += test_debugXML(); |
| 108 | - test_ret += test_dict(); |
| 109 | - test_ret += test_encoding(); |
| 110 | - test_ret += test_entities(); |
| 111 | - test_ret += test_hash(); |
| 112 | - test_ret += test_list(); |
| 113 | - test_ret += test_nanoftp(); |
| 114 | - test_ret += test_nanohttp(); |
| 115 | - test_ret += test_parser(); |
| 116 | - test_ret += test_parserInternals(); |
| 117 | - test_ret += test_pattern(); |
| 118 | - test_ret += test_relaxng(); |
| 119 | - test_ret += test_schemasInternals(); |
| 120 | - test_ret += test_schematron(); |
| 121 | - test_ret += test_tree(); |
| 122 | - test_ret += test_uri(); |
| 123 | - test_ret += test_valid(); |
| 124 | - test_ret += test_xinclude(); |
| 125 | - test_ret += test_xmlIO(); |
| 126 | - test_ret += test_xmlautomata(); |
| 127 | - test_ret += test_xmlerror(); |
| 128 | - test_ret += test_xmlmodule(); |
| 129 | - test_ret += test_xmlreader(); |
| 130 | - test_ret += test_xmlregexp(); |
| 131 | - test_ret += test_xmlsave(); |
| 132 | - test_ret += test_xmlschemas(); |
| 133 | - test_ret += test_xmlschemastypes(); |
| 134 | - test_ret += test_xmlstring(); |
| 135 | - test_ret += test_xmlunicode(); |
| 136 | - test_ret += test_xmlwriter(); |
| 137 | - test_ret += test_xpath(); |
| 138 | - test_ret += test_xpathInternals(); |
| 139 | - test_ret += test_xpointer(); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 140 | + int ret = 0; |
| 141 | + |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | + test_ret += (ret = test_HTMLparser()); |
| 143 | + printf("%s: HTMLparser\n", (ret == 0) ? "PASS" : "FAIL"); |
| 144 | + test_ret += (ret = test_HTMLtree()); |
| 145 | + printf("%s: HTMLtree\n", (ret == 0) ? "PASS" : "FAIL"); |
| 146 | + test_ret += (ret = test_SAX2()); |
| 147 | + printf("%s: SAX2\n", (ret == 0) ? "PASS" : "FAIL"); |
| 148 | + test_ret += (ret = test_c14n()); |
| 149 | + printf("%s: c14n\n", (ret == 0) ? "PASS" : "FAIL"); |
| 150 | + test_ret += (ret = test_catalog()); |
| 151 | + printf("%s: catalog\n", (ret == 0) ? "PASS" : "FAIL"); |
| 152 | + test_ret += (ret = test_chvalid()); |
| 153 | + printf("%s: chvalid\n", (ret == 0) ? "PASS" : "FAIL"); |
| 154 | + test_ret += (ret = test_debugXML()); |
| 155 | + printf("%s: debugXML\n", (ret == 0) ? "PASS" : "FAIL"); |
| 156 | + test_ret += (ret = test_dict()); |
| 157 | + printf("%s: dict\n", (ret == 0) ? "PASS" : "FAIL"); |
| 158 | + test_ret += (ret = test_encoding()); |
| 159 | + printf("%s: encoding\n", (ret == 0) ? "PASS" : "FAIL"); |
| 160 | + test_ret += (ret = test_entities()); |
| 161 | + printf("%s: entities\n", (ret == 0) ? "PASS" : "FAIL"); |
| 162 | + test_ret += (ret = test_hash()); |
| 163 | + printf("%s: hash\n", (ret == 0) ? "PASS" : "FAIL"); |
| 164 | + test_ret += (ret = test_list()); |
| 165 | + printf("%s: list\n", (ret == 0) ? "PASS" : "FAIL"); |
| 166 | + test_ret += (ret = test_nanoftp()); |
| 167 | + printf("%s: nanoftp\n", (ret == 0) ? "PASS" : "FAIL"); |
| 168 | + test_ret += (ret = test_nanohttp()); |
| 169 | + printf("%s: nanohttp\n", (ret == 0) ? "PASS" : "FAIL"); |
| 170 | + test_ret += (ret = test_parser()); |
| 171 | + printf("%s: parser\n", (ret == 0) ? "PASS" : "FAIL"); |
| 172 | + test_ret += (ret = test_parserInternals()); |
| 173 | + printf("%s: parserInternals\n", (ret == 0) ? "PASS" : "FAIL"); |
| 174 | + test_ret += (ret = test_pattern()); |
| 175 | + printf("%s: pattern\n", (ret == 0) ? "PASS" : "FAIL"); |
| 176 | + test_ret += (ret = test_relaxng()); |
| 177 | + printf("%s: relaxng\n", (ret == 0) ? "PASS" : "FAIL"); |
| 178 | + test_ret += (ret = test_schemasInternals()); |
| 179 | + printf("%s: schemasInternals\n", (ret == 0) ? "PASS" : "FAIL"); |
| 180 | + test_ret += (ret = test_schematron()); |
| 181 | + printf("%s: schematron\n", (ret == 0) ? "PASS" : "FAIL"); |
| 182 | + test_ret += (ret = test_tree()); |
| 183 | + printf("%s: tree\n", (ret == 0) ? "PASS" : "FAIL"); |
| 184 | + test_ret += (ret = test_uri()); |
| 185 | + printf("%s: uri\n", (ret == 0) ? "PASS" : "FAIL"); |
| 186 | + test_ret += (ret = test_valid()); |
| 187 | + printf("%s: valid\n", (ret == 0) ? "PASS" : "FAIL"); |
| 188 | + test_ret += (ret = test_xinclude()); |
| 189 | + printf("%s: xinclude\n", (ret == 0) ? "PASS" : "FAIL"); |
| 190 | + test_ret += (ret = test_xmlIO()); |
| 191 | + printf("%s: xmlIO\n", (ret == 0) ? "PASS" : "FAIL"); |
| 192 | + test_ret += (ret = test_xmlautomata()); |
| 193 | + printf("%s: xmlautomata\n", (ret == 0) ? "PASS" : "FAIL"); |
| 194 | + test_ret += (ret = test_xmlerror()); |
| 195 | + printf("%s: xmlerror\n", (ret == 0) ? "PASS" : "FAIL"); |
| 196 | + test_ret += (ret = test_xmlmodule()); |
| 197 | + printf("%s: xmlmodule\n", (ret == 0) ? "PASS" : "FAIL"); |
| 198 | + test_ret += (ret = test_xmlreader()); |
| 199 | + printf("%s: xmlreader\n", (ret == 0) ? "PASS" : "FAIL"); |
| 200 | + test_ret += (ret = test_xmlregexp()); |
| 201 | + printf("%s: xmlregexp\n", (ret == 0) ? "PASS" : "FAIL"); |
| 202 | + test_ret += (ret = test_xmlsave()); |
| 203 | + printf("%s: xmlsave\n", (ret == 0) ? "PASS" : "FAIL"); |
| 204 | + test_ret += (ret = test_xmlschemas()); |
| 205 | + printf("%s: xmlschemas\n", (ret == 0) ? "PASS" : "FAIL"); |
| 206 | + test_ret += (ret = test_xmlschemastypes()); |
| 207 | + printf("%s: xmlschemastypes\n", (ret == 0) ? "PASS" : "FAIL"); |
| 208 | + test_ret += (ret = test_xmlstring()); |
| 209 | + printf("%s: xmlstring\n", (ret == 0) ? "PASS" : "FAIL"); |
| 210 | + test_ret += (ret = test_xmlunicode()); |
| 211 | + printf("%s: xmlunicode\n", (ret == 0) ? "PASS" : "FAIL"); |
| 212 | + test_ret += (ret = test_xmlwriter()); |
| 213 | + printf("%s: xmlwriter\n", (ret == 0) ? "PASS" : "FAIL"); |
| 214 | + test_ret += (ret = test_xpath()); |
| 215 | + printf("%s: xpath\n", (ret == 0) ? "PASS" : "FAIL"); |
| 216 | + test_ret += (ret = test_xpathInternals()); |
| 217 | + printf("%s: xpathInternals\n", (ret == 0) ? "PASS" : "FAIL"); |
| 218 | + test_ret += (ret = test_xpointer()); |
| 219 | + printf("%s: xpointer\n", (ret == 0) ? "PASS" : "FAIL"); |
| 220 | |
| 221 | printf("Total: %d functions, %d tests, %d errors\n", |
| 222 | function_tests, call_tests, test_ret); |
| 223 | + |
| 224 | + printf("%s: testapi\n\n", (test_ret == 0) ? "PASS" : "FAIL"); |
| 225 | return(test_ret); |
| 226 | } |
| 227 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 228 | diff --git a/testchar.c b/testchar.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 229 | index 6866a175..7bce0132 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 230 | --- a/testchar.c |
| 231 | +++ b/testchar.c |
| 232 | @@ -23,7 +23,7 @@ static void errorHandler(void *unused, xmlErrorPtr err) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 233 | char document1[100] = "<doc>XXXX</doc>"; |
| 234 | char document2[100] = "<doc foo='XXXX'/>"; |
| 235 | |
| 236 | -static void testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document, |
| 237 | +static int testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document, |
| 238 | int len, char *data, int forbid1, int forbid2) { |
| 239 | int i; |
| 240 | xmlDocPtr res; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 241 | @@ -37,33 +37,41 @@ static void testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 242 | res = xmlReadMemory(document, len, "test", NULL, 0); |
| 243 | |
| 244 | if ((i == forbid1) || (i == forbid2)) { |
| 245 | - if ((lastError == 0) || (res != NULL)) |
| 246 | + if ((lastError == 0) || (res != NULL)) { |
| 247 | fprintf(stderr, |
| 248 | "Failed to detect invalid char for Byte 0x%02X: %c\n", |
| 249 | i, i); |
| 250 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 251 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | else if ((i == '<') || (i == '&')) { |
| 255 | - if ((lastError == 0) || (res != NULL)) |
| 256 | + if ((lastError == 0) || (res != NULL)) { |
| 257 | fprintf(stderr, |
| 258 | "Failed to detect illegal char %c for Byte 0x%02X\n", i, i); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 259 | + return(1); |
| 260 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 261 | } |
| 262 | else if (((i < 0x20) || (i >= 0x80)) && |
| 263 | (i != 0x9) && (i != 0xA) && (i != 0xD)) { |
| 264 | - if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) |
| 265 | + if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) { |
| 266 | fprintf(stderr, |
| 267 | "Failed to detect invalid char for Byte 0x%02X\n", i); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 268 | + return(1); |
| 269 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 270 | } |
| 271 | else if (res == NULL) { |
| 272 | fprintf(stderr, |
| 273 | "Failed to parse valid char for Byte 0x%02X : %c\n", i, i); |
| 274 | + return(1); |
| 275 | } |
| 276 | if (res != NULL) |
| 277 | xmlFreeDoc(res); |
| 278 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 279 | + return(0); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | -static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
| 283 | +static int testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
| 284 | int len, char *data) { |
| 285 | int i, j; |
| 286 | xmlDocPtr res; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 287 | @@ -80,10 +88,12 @@ static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 288 | |
| 289 | /* if first bit of first char is set, then second bit must too */ |
| 290 | if ((i & 0x80) && ((i & 0x40) == 0)) { |
| 291 | - if ((lastError == 0) || (res != NULL)) |
| 292 | + if ((lastError == 0) || (res != NULL)) { |
| 293 | fprintf(stderr, |
| 294 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", |
| 295 | i, j); |
| 296 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 297 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 301 | @@ -91,10 +101,12 @@ static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 302 | * bits must be 10 |
| 303 | */ |
| 304 | else if ((i & 0x80) && ((j & 0xC0) != 0x80)) { |
| 305 | - if ((lastError == 0) || (res != NULL)) |
| 306 | + if ((lastError == 0) || (res != NULL)) { |
| 307 | fprintf(stderr, |
| 308 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", |
| 309 | i, j); |
| 310 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 311 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 315 | @@ -102,10 +114,12 @@ static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 316 | * than 0x80, i.e. one of bits 5 to 1 of i must be set |
| 317 | */ |
| 318 | else if ((i & 0x80) && ((i & 0x1E) == 0)) { |
| 319 | - if ((lastError == 0) || (res != NULL)) |
| 320 | + if ((lastError == 0) || (res != NULL)) { |
| 321 | fprintf(stderr, |
| 322 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", |
| 323 | i, j); |
| 324 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 325 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 329 | @@ -113,10 +127,12 @@ static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 330 | * at least 3 bytes, but we give only 2 ! |
| 331 | */ |
| 332 | else if ((i & 0xE0) == 0xE0) { |
| 333 | - if ((lastError == 0) || (res != NULL)) |
| 334 | + if ((lastError == 0) || (res != NULL)) { |
| 335 | fprintf(stderr, |
| 336 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n", |
| 337 | i, j); |
| 338 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 339 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 343 | @@ -125,11 +141,13 @@ static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 344 | else if ((lastError != 0) || (res == NULL)) { |
| 345 | fprintf(stderr, |
| 346 | "Failed to parse document for Bytes 0x%02X 0x%02X\n", i, j); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 347 | + return(1); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 348 | } |
| 349 | if (res != NULL) |
| 350 | xmlFreeDoc(res); |
| 351 | } |
| 352 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 353 | + return(0); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | /** |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 357 | @@ -141,9 +159,10 @@ static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 358 | * CDATA in text or in attribute values. |
| 359 | */ |
| 360 | |
| 361 | -static void testDocumentRanges(void) { |
| 362 | +static int testDocumentRanges(void) { |
| 363 | xmlParserCtxtPtr ctxt; |
| 364 | char *data; |
| 365 | + int test_ret = 0; |
| 366 | |
| 367 | /* |
| 368 | * Set up a parsing context using the first document as |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 369 | @@ -152,7 +171,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 370 | ctxt = xmlNewParserCtxt(); |
| 371 | if (ctxt == NULL) { |
| 372 | fprintf(stderr, "Failed to allocate parser context\n"); |
| 373 | - return; |
| 374 | + return(1); |
| 375 | } |
| 376 | |
| 377 | printf("testing 1 byte char in document: 1"); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 378 | @@ -163,7 +182,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 379 | data[2] = ' '; |
| 380 | data[3] = ' '; |
| 381 | /* test 1 byte injection at beginning of area */ |
| 382 | - testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), |
| 383 | + test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), |
| 384 | data, -1, -1); |
| 385 | printf(" 2"); |
| 386 | fflush(stdout); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 387 | @@ -172,7 +191,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 388 | data[2] = ' '; |
| 389 | data[3] = ' '; |
| 390 | /* test 1 byte injection at end of area */ |
| 391 | - testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), |
| 392 | + test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), |
| 393 | data + 3, -1, -1); |
| 394 | |
| 395 | printf(" 3"); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 396 | @@ -183,7 +202,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 397 | data[2] = ' '; |
| 398 | data[3] = ' '; |
| 399 | /* test 1 byte injection at beginning of area */ |
| 400 | - testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), |
| 401 | + test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), |
| 402 | data, '\'', -1); |
| 403 | printf(" 4"); |
| 404 | fflush(stdout); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 405 | @@ -192,7 +211,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 406 | data[2] = ' '; |
| 407 | data[3] = ' '; |
| 408 | /* test 1 byte injection at end of area */ |
| 409 | - testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), |
| 410 | + test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), |
| 411 | data + 3, '\'', -1); |
| 412 | printf(" done\n"); |
| 413 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 414 | @@ -204,7 +223,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 415 | data[2] = ' '; |
| 416 | data[3] = ' '; |
| 417 | /* test 2 byte injection at beginning of area */ |
| 418 | - testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), |
| 419 | + test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), |
| 420 | data); |
| 421 | printf(" 2"); |
| 422 | fflush(stdout); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 423 | @@ -213,7 +232,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 424 | data[2] = ' '; |
| 425 | data[3] = ' '; |
| 426 | /* test 2 byte injection at end of area */ |
| 427 | - testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), |
| 428 | + test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), |
| 429 | data + 2); |
| 430 | |
| 431 | printf(" 3"); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 432 | @@ -224,7 +243,7 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 433 | data[2] = ' '; |
| 434 | data[3] = ' '; |
| 435 | /* test 2 byte injection at beginning of area */ |
| 436 | - testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), |
| 437 | + test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), |
| 438 | data); |
| 439 | printf(" 4"); |
| 440 | fflush(stdout); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 441 | @@ -233,14 +252,15 @@ static void testDocumentRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 442 | data[2] = ' '; |
| 443 | data[3] = ' '; |
| 444 | /* test 2 byte injection at end of area */ |
| 445 | - testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), |
| 446 | + test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), |
| 447 | data + 2); |
| 448 | printf(" done\n"); |
| 449 | |
| 450 | xmlFreeParserCtxt(ctxt); |
| 451 | + return(test_ret); |
| 452 | } |
| 453 | |
| 454 | -static void testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) { |
| 455 | +static int testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) { |
| 456 | int i = 0; |
| 457 | int len, c; |
| 458 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 459 | @@ -255,19 +275,25 @@ static void testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 460 | c = xmlCurrentChar(ctxt, &len); |
| 461 | if ((i == 0) || (i >= 0x80)) { |
| 462 | /* we must see an error there */ |
| 463 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 464 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 465 | fprintf(stderr, |
| 466 | "Failed to detect invalid char for Byte 0x%02X\n", i); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 467 | + return(1); |
| 468 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 469 | } else if (i == 0xD) { |
| 470 | - if ((c != 0xA) || (len != 1)) |
| 471 | + if ((c != 0xA) || (len != 1)) { |
| 472 | fprintf(stderr, "Failed to convert char for Byte 0x%02X\n", i); |
| 473 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 474 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 475 | } else if ((c != i) || (len != 1)) { |
| 476 | fprintf(stderr, "Failed to parse char for Byte 0x%02X\n", i); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 477 | + return(1); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 478 | } |
| 479 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 480 | + return(0); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | -static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
| 484 | +static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
| 485 | int i, j; |
| 486 | int len, c; |
| 487 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 488 | @@ -284,10 +310,12 @@ static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 489 | |
| 490 | /* if first bit of first char is set, then second bit must too */ |
| 491 | if ((i & 0x80) && ((i & 0x40) == 0)) { |
| 492 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 493 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 494 | fprintf(stderr, |
| 495 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", |
| 496 | i, j); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 497 | + return(1); |
| 498 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 502 | @@ -295,10 +323,12 @@ static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 503 | * bits must be 10 |
| 504 | */ |
| 505 | else if ((i & 0x80) && ((j & 0xC0) != 0x80)) { |
| 506 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 507 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 508 | fprintf(stderr, |
| 509 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n", |
| 510 | i, j, c); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 511 | + return(1); |
| 512 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 516 | @@ -306,10 +336,12 @@ static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 517 | * than 0x80, i.e. one of bits 5 to 1 of i must be set |
| 518 | */ |
| 519 | else if ((i & 0x80) && ((i & 0x1E) == 0)) { |
| 520 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 521 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 522 | fprintf(stderr, |
| 523 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n", |
| 524 | i, j, c); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 525 | + return(1); |
| 526 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 530 | @@ -317,10 +349,12 @@ static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 531 | * at least 3 bytes, but we give only 2 ! |
| 532 | */ |
| 533 | else if ((i & 0xE0) == 0xE0) { |
| 534 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 535 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 536 | fprintf(stderr, |
| 537 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n", |
| 538 | i, j); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 539 | + return(1); |
| 540 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 544 | @@ -329,6 +363,7 @@ static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 545 | else if ((lastError != 0) || (len != 2)) { |
| 546 | fprintf(stderr, |
| 547 | "Failed to parse char for Bytes 0x%02X 0x%02X\n", i, j); |
| 548 | + return(1); |
| 549 | } |
| 550 | |
| 551 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 552 | @@ -338,12 +373,14 @@ static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 553 | fprintf(stderr, |
| 554 | "Failed to parse char for Bytes 0x%02X 0x%02X: expect %d got %d\n", |
| 555 | i, j, ((j & 0x3F) + ((i & 0x1F) << 6)), c); |
| 556 | + return(1); |
| 557 | } |
| 558 | } |
| 559 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 560 | + return(0); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | -static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
| 564 | +static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
| 565 | int i, j, k, K; |
| 566 | int len, c; |
| 567 | unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF}; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 568 | @@ -368,20 +405,24 @@ static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 569 | * at least 4 bytes, but we give only 3 ! |
| 570 | */ |
| 571 | if ((i & 0xF0) == 0xF0) { |
| 572 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 573 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 574 | fprintf(stderr, |
| 575 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", |
| 576 | i, j, K, data[3]); |
| 577 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 578 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | /* |
| 582 | * The second and the third bytes must start with 10 |
| 583 | */ |
| 584 | else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80)) { |
| 585 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 586 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 587 | fprintf(stderr, |
| 588 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n", |
| 589 | i, j, K); |
| 590 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 591 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 595 | @@ -390,10 +431,12 @@ static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 596 | * the 6th byte of data[1] must be set |
| 597 | */ |
| 598 | else if (((i & 0xF) == 0) && ((j & 0x20) == 0)) { |
| 599 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 600 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 601 | fprintf(stderr, |
| 602 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n", |
| 603 | i, j, K); |
| 604 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 605 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 609 | @@ -401,10 +444,12 @@ static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 610 | */ |
| 611 | else if (((value > 0xD7FF) && (value <0xE000)) || |
| 612 | ((value > 0xFFFD) && (value <0x10000))) { |
| 613 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 614 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 615 | fprintf(stderr, |
| 616 | "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n", |
| 617 | value, i, j, K); |
| 618 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 619 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 623 | @@ -414,6 +459,7 @@ static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 624 | fprintf(stderr, |
| 625 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n", |
| 626 | i, j, K); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 627 | + return(1); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 631 | @@ -423,13 +469,15 @@ static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 632 | fprintf(stderr, |
| 633 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n", |
| 634 | i, j, data[2], value, c); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 635 | + return(1); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 636 | } |
| 637 | } |
| 638 | } |
| 639 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 640 | + return(0); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | -static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
| 644 | +static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
| 645 | int i, j, k, K, l, L; |
| 646 | int len, c; |
| 647 | unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF}; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 648 | @@ -458,10 +506,12 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 649 | * at least 5 bytes, but we give only 4 ! |
| 650 | */ |
| 651 | if ((i & 0xF8) == 0xF8) { |
| 652 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 653 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 654 | fprintf(stderr, |
| 655 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", |
| 656 | i, j, K, data[3]); |
| 657 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 658 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 662 | @@ -469,10 +519,12 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 663 | */ |
| 664 | else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) || |
| 665 | ((L & 0xC0) != 0x80)) { |
| 666 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 667 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 668 | fprintf(stderr, |
| 669 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", |
| 670 | i, j, K, L); |
| 671 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 672 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 676 | @@ -481,10 +533,12 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 677 | * the 6 or 5th byte of j must be set |
| 678 | */ |
| 679 | else if (((i & 0x7) == 0) && ((j & 0x30) == 0)) { |
| 680 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 681 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 682 | fprintf(stderr, |
| 683 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", |
| 684 | i, j, K, L); |
| 685 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 686 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 690 | @@ -493,10 +547,12 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 691 | else if (((value > 0xD7FF) && (value <0xE000)) || |
| 692 | ((value > 0xFFFD) && (value <0x10000)) || |
| 693 | (value > 0x10FFFF)) { |
| 694 | - if (lastError != XML_ERR_INVALID_CHAR) |
| 695 | + if (lastError != XML_ERR_INVALID_CHAR) { |
| 696 | fprintf(stderr, |
| 697 | "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", |
| 698 | value, i, j, K, L); |
| 699 | + return(1); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 700 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 704 | @@ -506,6 +562,7 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 705 | fprintf(stderr, |
| 706 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n", |
| 707 | i, j, K); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 708 | + return(1); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | /* |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 712 | @@ -515,11 +572,13 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 713 | fprintf(stderr, |
| 714 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n", |
| 715 | i, j, data[2], value, c); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 716 | + return(1); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 717 | } |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 722 | + return(0); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | /** |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 726 | @@ -530,11 +589,12 @@ static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 727 | * cover the full range of UTF-8 chars accepted by XML-1.0 |
| 728 | */ |
| 729 | |
| 730 | -static void testCharRanges(void) { |
| 731 | +static int testCharRanges(void) { |
| 732 | char data[5]; |
| 733 | xmlParserCtxtPtr ctxt; |
| 734 | xmlParserInputBufferPtr buf; |
| 735 | xmlParserInputPtr input; |
| 736 | + int test_ret = 0; |
| 737 | |
| 738 | memset(data, 0, 5); |
| 739 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 740 | @@ -545,17 +605,19 @@ static void testCharRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 741 | ctxt = xmlNewParserCtxt(); |
| 742 | if (ctxt == NULL) { |
| 743 | fprintf(stderr, "Failed to allocate parser context\n"); |
| 744 | - return; |
| 745 | + return(1); |
| 746 | } |
| 747 | buf = xmlParserInputBufferCreateStatic(data, sizeof(data), |
| 748 | XML_CHAR_ENCODING_NONE); |
| 749 | if (buf == NULL) { |
| 750 | fprintf(stderr, "Failed to allocate input buffer\n"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 751 | + test_ret = 1; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 752 | goto error; |
| 753 | } |
| 754 | input = xmlNewInputStream(ctxt); |
| 755 | if (input == NULL) { |
| 756 | xmlFreeParserInputBuffer(buf); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 757 | + test_ret = 1; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 758 | goto error; |
| 759 | } |
| 760 | input->filename = NULL; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 761 | @@ -567,25 +629,28 @@ static void testCharRanges(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 762 | |
| 763 | printf("testing char range: 1"); |
| 764 | fflush(stdout); |
| 765 | - testCharRangeByte1(ctxt, data); |
| 766 | + test_ret += testCharRangeByte1(ctxt, data); |
| 767 | printf(" 2"); |
| 768 | fflush(stdout); |
| 769 | - testCharRangeByte2(ctxt, data); |
| 770 | + test_ret += testCharRangeByte2(ctxt, data); |
| 771 | printf(" 3"); |
| 772 | fflush(stdout); |
| 773 | - testCharRangeByte3(ctxt, data); |
| 774 | + test_ret += testCharRangeByte3(ctxt, data); |
| 775 | printf(" 4"); |
| 776 | fflush(stdout); |
| 777 | - testCharRangeByte4(ctxt, data); |
| 778 | + test_ret += testCharRangeByte4(ctxt, data); |
| 779 | printf(" done\n"); |
| 780 | fflush(stdout); |
| 781 | |
| 782 | error: |
| 783 | xmlFreeParserCtxt(ctxt); |
| 784 | + return(test_ret); |
| 785 | } |
| 786 | |
| 787 | int main(void) { |
| 788 | |
| 789 | + int ret = 0; |
| 790 | + |
| 791 | /* |
| 792 | * this initialize the library and check potential ABI mismatches |
| 793 | * between the version it was compiled for and the actual shared |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 794 | @@ -602,8 +667,9 @@ int main(void) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 795 | /* |
| 796 | * Run the tests |
| 797 | */ |
| 798 | - testCharRanges(); |
| 799 | - testDocumentRanges(); |
| 800 | + ret += testCharRanges(); |
| 801 | + ret += testDocumentRanges(); |
| 802 | + printf("%s: testchar\n\n", (ret == 0) ? "PASS" : "FAIL"); |
| 803 | |
| 804 | /* |
| 805 | * Cleanup function for the XML library. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 806 | diff --git a/testdict.c b/testdict.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 807 | index 40bebd05..114b9347 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 808 | --- a/testdict.c |
| 809 | +++ b/testdict.c |
| 810 | @@ -440,5 +440,6 @@ int main(void) |
| 811 | clean_strings(); |
| 812 | xmlCleanupParser(); |
| 813 | xmlMemoryDump(); |
| 814 | + printf("%s: testdict\n\n", (ret == 0) ? "PASS" : "FAIL"); |
| 815 | return(ret); |
| 816 | } |
| 817 | diff --git a/testlimits.c b/testlimits.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 818 | index 059116a6..f0bee68d 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 819 | --- a/testlimits.c |
| 820 | +++ b/testlimits.c |
| 821 | @@ -1634,5 +1634,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 822 | xmlCleanupParser(); |
| 823 | xmlMemoryDump(); |
| 824 | |
| 825 | + printf("%s: testlimits\n", (ret == 0) ? "PASS" : "FAIL"); |
| 826 | return(ret); |
| 827 | } |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 828 | diff --git a/testrecurse.c b/testrecurse.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 829 | index 0cbe25a6..3ecadb40 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 830 | --- a/testrecurse.c |
| 831 | +++ b/testrecurse.c |
| 832 | @@ -892,6 +892,7 @@ launchTests(testDescPtr tst) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 833 | err++; |
| 834 | } |
| 835 | } |
| 836 | + printf("%s: %s\n", (err == 0) ? "PASS" : "FAIL", tst->desc); |
| 837 | return(err); |
| 838 | } |
| 839 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 840 | @@ -961,5 +962,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 841 | xmlCleanupParser(); |
| 842 | xmlMemoryDump(); |
| 843 | |
| 844 | + printf("%s: testrecurse\n\n", (ret == 0) ? "PASS" : "FAIL"); |
| 845 | return(ret); |
| 846 | } |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 847 | -- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 848 | 2.25.1 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 849 | |