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