blob: 544dc05834b560e204f489a01e0b15e5dd3d384c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Add 'install-ptest' rule.
2Print a standard result line for each test.
3
4Signed-off-by: Mihaela Sendrea <mihaela.sendrea@enea.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -04005Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006Upstream-Status: Backport
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
8diff -uNr a/Makefile.am b/Makefile.am
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08009--- a/Makefile.am 2017-12-02 09:58:10.000000000 +0100
10+++ b/Makefile.am 2018-03-20 08:27:34.360505864 +0100
Brad Bishop316dfdd2018-06-25 12:45:53 -040011@@ -202,6 +202,15 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012 #testOOM_DEPENDENCIES = $(DEPS)
13 #testOOM_LDADD= $(LDADDS)
14
15+install-ptest:
16+ @(if [ -d .libs ] ; then cd .libs; fi; \
Brad Bishop316dfdd2018-06-25 12:45:53 -040017+ install $(check_PROGRAMS) $(DESTDIR))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018+ cp -r $(srcdir)/test $(DESTDIR)
19+ cp -r $(srcdir)/result $(DESTDIR)
20+ cp -r $(srcdir)/python $(DESTDIR)
21+ cp Makefile $(DESTDIR)
22+ sed -i -e 's|^Makefile:|_Makefile:|' $(DESTDIR)/Makefile
23+
Brad Bishop316dfdd2018-06-25 12:45:53 -040024 runtests: runtest$(EXEEXT) testrecurse$(EXEEXT) testapi$(EXEEXT) \
25 testchar$(EXEEXT) testdict$(EXEEXT) runxmlconf$(EXEEXT)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 [ -d test ] || $(LN_S) $(srcdir)/test .
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027diff -uNr a/runsuite.c b/runsuite.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028--- a/runsuite.c 2016-06-07 12:04:14.000000000 +0200
29+++ b/runsuite.c 2018-03-20 08:27:57.478817247 +0100
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030@@ -1162,6 +1162,7 @@
31
32 if (logfile != NULL)
33 fclose(logfile);
34+ printf("%s: runsuite\n\n", (ret == 0) ? "PASS" : "FAIL");
35 return(ret);
36 }
37 #else /* !SCHEMAS */
38diff -uNr a/runtest.c b/runtest.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080039--- a/runtest.c 2017-11-13 22:00:17.000000000 +0100
40+++ b/runtest.c 2018-03-20 08:28:50.859047551 +0100
41@@ -4496,7 +4496,8 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043
44 xmlCharEncCloseFunc(ebcdicHandler);
45-
46+
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047+ printf("%s: %s\n", (err == 0) ? "PASS" : "FAIL", tst->desc);
48 return(err);
49 }
50
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080051@@ -4573,6 +4574,7 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 xmlCleanupParser();
53 xmlMemoryDump();
54
55+ printf("%s: runtest\n\n", (ret == 0) ? "PASS" : "FAIL");
56 return(ret);
57 }
58
59diff -uNr a/runxmlconf.c b/runxmlconf.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080060--- a/runxmlconf.c 2016-06-07 12:04:14.000000000 +0200
61+++ b/runxmlconf.c 2018-03-20 08:29:17.944862893 +0100
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062@@ -595,6 +595,7 @@
63
64 if (logfile != NULL)
65 fclose(logfile);
66+ printf("%s: runxmlconf\n", (ret == 0) ? "PASS" : "FAIL");
67 return(ret);
68 }
69
70diff -uNr a/testapi.c b/testapi.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080071--- a/testapi.c 2018-01-25 07:39:15.000000000 +0100
72+++ b/testapi.c 2018-03-20 09:08:35.323980145 +0100
73@@ -1246,49 +1246,91 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 testlibxml2(void)
75 {
76 int test_ret = 0;
77+ int ret = 0;
78
79- test_ret += test_HTMLparser();
80- test_ret += test_HTMLtree();
81- test_ret += test_SAX2();
82- test_ret += test_c14n();
83- test_ret += test_catalog();
84- test_ret += test_chvalid();
85- test_ret += test_debugXML();
86- test_ret += test_dict();
87- test_ret += test_encoding();
88- test_ret += test_entities();
89- test_ret += test_hash();
90- test_ret += test_list();
91- test_ret += test_nanoftp();
92- test_ret += test_nanohttp();
93- test_ret += test_parser();
94- test_ret += test_parserInternals();
95- test_ret += test_pattern();
96- test_ret += test_relaxng();
97- test_ret += test_schemasInternals();
98- test_ret += test_schematron();
99- test_ret += test_tree();
100- test_ret += test_uri();
101- test_ret += test_valid();
102- test_ret += test_xinclude();
103- test_ret += test_xmlIO();
104- test_ret += test_xmlautomata();
105- test_ret += test_xmlerror();
106- test_ret += test_xmlmodule();
107- test_ret += test_xmlreader();
108- test_ret += test_xmlregexp();
109- test_ret += test_xmlsave();
110- test_ret += test_xmlschemas();
111- test_ret += test_xmlschemastypes();
112- test_ret += test_xmlstring();
113- test_ret += test_xmlunicode();
114- test_ret += test_xmlwriter();
115- test_ret += test_xpath();
116- test_ret += test_xpathInternals();
117- test_ret += test_xpointer();
118+ test_ret += (ret = test_HTMLparser());
119+ printf("%s: HTMLparser\n", (ret == 0) ? "PASS" : "FAIL");
120+ test_ret += (ret = test_HTMLtree());
121+ printf("%s: HTMLtree\n", (ret == 0) ? "PASS" : "FAIL");
122+ test_ret += (ret = test_SAX2());
123+ printf("%s: SAX2\n", (ret == 0) ? "PASS" : "FAIL");
124+ test_ret += (ret = test_c14n());
125+ printf("%s: c14n\n", (ret == 0) ? "PASS" : "FAIL");
126+ test_ret += (ret = test_catalog());
127+ printf("%s: catalog\n", (ret == 0) ? "PASS" : "FAIL");
128+ test_ret += (ret = test_chvalid());
129+ printf("%s: chvalid\n", (ret == 0) ? "PASS" : "FAIL");
130+ test_ret += (ret = test_debugXML());
131+ printf("%s: debugXML\n", (ret == 0) ? "PASS" : "FAIL");
132+ test_ret += (ret = test_dict());
133+ printf("%s: dict\n", (ret == 0) ? "PASS" : "FAIL");
134+ test_ret += (ret = test_encoding());
135+ printf("%s: encoding\n", (ret == 0) ? "PASS" : "FAIL");
136+ test_ret += (ret = test_entities());
137+ printf("%s: entities\n", (ret == 0) ? "PASS" : "FAIL");
138+ test_ret += (ret = test_hash());
139+ printf("%s: hash\n", (ret == 0) ? "PASS" : "FAIL");
140+ test_ret += (ret = test_list());
141+ printf("%s: list\n", (ret == 0) ? "PASS" : "FAIL");
142+ test_ret += (ret = test_nanoftp());
143+ printf("%s: nanoftp\n", (ret == 0) ? "PASS" : "FAIL");
144+ test_ret += (ret = test_nanohttp());
145+ printf("%s: nanohttp\n", (ret == 0) ? "PASS" : "FAIL");
146+ test_ret += (ret = test_parser());
147+ printf("%s: parser\n", (ret == 0) ? "PASS" : "FAIL");
148+ test_ret += (ret = test_parserInternals());
149+ printf("%s: parserInternals\n", (ret == 0) ? "PASS" : "FAIL");
150+ test_ret += (ret = test_pattern());
151+ printf("%s: pattern\n", (ret == 0) ? "PASS" : "FAIL");
152+ test_ret += (ret = test_relaxng());
153+ printf("%s: relaxng\n", (ret == 0) ? "PASS" : "FAIL");
154+ test_ret += (ret = test_schemasInternals());
155+ printf("%s: schemasInternals\n", (ret == 0) ? "PASS" : "FAIL");
156+ test_ret += (ret = test_schematron());
157+ printf("%s: schematron\n", (ret == 0) ? "PASS" : "FAIL");
158+ test_ret += (ret = test_tree());
159+ printf("%s: tree\n", (ret == 0) ? "PASS" : "FAIL");
160+ test_ret += (ret = test_uri());
161+ printf("%s: uri\n", (ret == 0) ? "PASS" : "FAIL");
162+ test_ret += (ret = test_valid());
163+ printf("%s: valid\n", (ret == 0) ? "PASS" : "FAIL");
164+ test_ret += (ret = test_xinclude());
165+ printf("%s: xinclude\n", (ret == 0) ? "PASS" : "FAIL");
166+ test_ret += (ret = test_xmlIO());
167+ printf("%s: xmlIO\n", (ret == 0) ? "PASS" : "FAIL");
168+ test_ret += (ret = test_xmlautomata());
169+ printf("%s: xmlautomata\n", (ret == 0) ? "PASS" : "FAIL");
170+ test_ret += (ret = test_xmlerror());
171+ printf("%s: xmlerror\n", (ret == 0) ? "PASS" : "FAIL");
172+ test_ret += (ret = test_xmlmodule());
173+ printf("%s: xmlmodule\n", (ret == 0) ? "PASS" : "FAIL");
174+ test_ret += (ret = test_xmlreader());
175+ printf("%s: xmlreader\n", (ret == 0) ? "PASS" : "FAIL");
176+ test_ret += (ret = test_xmlregexp());
177+ printf("%s: xmlregexp\n", (ret == 0) ? "PASS" : "FAIL");
178+ test_ret += (ret = test_xmlsave());
179+ printf("%s: xmlsave\n", (ret == 0) ? "PASS" : "FAIL");
180+ test_ret += (ret = test_xmlschemas());
181+ printf("%s: xmlschemas\n", (ret == 0) ? "PASS" : "FAIL");
182+ test_ret += (ret = test_xmlschemastypes());
183+ printf("%s: xmlschemastypes\n", (ret == 0) ? "PASS" : "FAIL");
184+ test_ret += (ret = test_xmlstring());
185+ printf("%s: xmlstring\n", (ret == 0) ? "PASS" : "FAIL");
186+ test_ret += (ret = test_xmlunicode());
187+ printf("%s: xmlunicode\n", (ret == 0) ? "PASS" : "FAIL");
188+ test_ret += (ret = test_xmlwriter());
189+ printf("%s: xmlwriter\n", (ret == 0) ? "PASS" : "FAIL");
190+ test_ret += (ret = test_xpath());
191+ printf("%s: xpath\n", (ret == 0) ? "PASS" : "FAIL");
192+ test_ret += (ret = test_xpathInternals());
193+ printf("%s: xpathInternals\n", (ret == 0) ? "PASS" : "FAIL");
194+ test_ret += (ret = test_xpointer());
195+ printf("%s: xpointer\n", (ret == 0) ? "PASS" : "FAIL");
196
197 printf("Total: %d functions, %d tests, %d errors\n",
198 function_tests, call_tests, test_ret);
199+
200+ printf("%s: testapi\n\n", (test_ret == 0) ? "PASS" : "FAIL");
201 return(test_ret);
202 }
203
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800204diff -uNr a/testdict.c b/testdict.c
205--- a/testdict.c 2016-06-07 12:04:14.000000000 +0200
206+++ b/testdict.c 2018-03-20 08:59:16.864275812 +0100
207@@ -440,5 +440,6 @@
208 clean_strings();
209 xmlCleanupParser();
210 xmlMemoryDump();
211+ printf("%s: testdict\n\n", (ret == 0) ? "PASS" : "FAIL");
212 return(ret);
213 }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214diff -uNr a/testchar.c b/testchar.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800215--- a/testchar.c 2016-06-07 12:04:14.000000000 +0200
216+++ b/testchar.c 2018-03-20 09:11:20.383573912 +0100
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217@@ -23,7 +23,7 @@
218 char document1[100] = "<doc>XXXX</doc>";
219 char document2[100] = "<doc foo='XXXX'/>";
220
221-static void testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document,
222+static int testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document,
223 int len, char *data, int forbid1, int forbid2) {
224 int i;
225 xmlDocPtr res;
226@@ -37,33 +37,41 @@
227 res = xmlReadMemory(document, len, "test", NULL, 0);
228
229 if ((i == forbid1) || (i == forbid2)) {
230- if ((lastError == 0) || (res != NULL))
231+ if ((lastError == 0) || (res != NULL)) {
232 fprintf(stderr,
233 "Failed to detect invalid char for Byte 0x%02X: %c\n",
234 i, i);
235+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800236+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500237 }
238
239 else if ((i == '<') || (i == '&')) {
240- if ((lastError == 0) || (res != NULL))
241+ if ((lastError == 0) || (res != NULL)) {
242 fprintf(stderr,
243 "Failed to detect illegal char %c for Byte 0x%02X\n", i, i);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800244+ return(1);
245+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500246 }
247 else if (((i < 0x20) || (i >= 0x80)) &&
248 (i != 0x9) && (i != 0xA) && (i != 0xD)) {
249- if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL))
250+ if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) {
251 fprintf(stderr,
252 "Failed to detect invalid char for Byte 0x%02X\n", i);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800253+ return(1);
254+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500255 }
256 else if (res == NULL) {
257 fprintf(stderr,
258 "Failed to parse valid char for Byte 0x%02X : %c\n", i, i);
259+ return(1);
260 }
261 if (res != NULL)
262 xmlFreeDoc(res);
263 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800264+ return(0);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500265 }
266
267-static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document,
268+static int testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document,
269 int len, char *data) {
270 int i, j;
271 xmlDocPtr res;
272@@ -80,10 +88,12 @@
273
274 /* if first bit of first char is set, then second bit must too */
275 if ((i & 0x80) && ((i & 0x40) == 0)) {
276- if ((lastError == 0) || (res != NULL))
277+ if ((lastError == 0) || (res != NULL)) {
278 fprintf(stderr,
279 "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
280 i, j);
281+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800282+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500283 }
284
285 /*
286@@ -91,10 +101,12 @@
287 * bits must be 10
288 */
289 else if ((i & 0x80) && ((j & 0xC0) != 0x80)) {
290- if ((lastError == 0) || (res != NULL))
291+ if ((lastError == 0) || (res != NULL)) {
292 fprintf(stderr,
293 "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
294 i, j);
295+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800296+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297 }
298
299 /*
300@@ -102,10 +114,12 @@
301 * than 0x80, i.e. one of bits 5 to 1 of i must be set
302 */
303 else if ((i & 0x80) && ((i & 0x1E) == 0)) {
304- if ((lastError == 0) || (res != NULL))
305+ if ((lastError == 0) || (res != NULL)) {
306 fprintf(stderr,
307 "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
308 i, j);
309+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800310+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500311 }
312
313 /*
314@@ -113,10 +127,12 @@
315 * at least 3 bytes, but we give only 2 !
316 */
317 else if ((i & 0xE0) == 0xE0) {
318- if ((lastError == 0) || (res != NULL))
319+ if ((lastError == 0) || (res != NULL)) {
320 fprintf(stderr,
321 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n",
322 i, j);
323+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800324+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500325 }
326
327 /*
328@@ -125,11 +141,13 @@
329 else if ((lastError != 0) || (res == NULL)) {
330 fprintf(stderr,
331 "Failed to parse document for Bytes 0x%02X 0x%02X\n", i, j);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800332+ return(1);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500333 }
334 if (res != NULL)
335 xmlFreeDoc(res);
336 }
337 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800338+ return(0);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500339 }
340
341 /**
342@@ -141,9 +159,10 @@
343 * CDATA in text or in attribute values.
344 */
345
346-static void testDocumentRanges(void) {
347+static int testDocumentRanges(void) {
348 xmlParserCtxtPtr ctxt;
349 char *data;
350+ int test_ret = 0;
351
352 /*
353 * Set up a parsing context using the first document as
354@@ -152,7 +171,7 @@
355 ctxt = xmlNewParserCtxt();
356 if (ctxt == NULL) {
357 fprintf(stderr, "Failed to allocate parser context\n");
358- return;
359+ return(1);
360 }
361
362 printf("testing 1 byte char in document: 1");
363@@ -163,7 +182,7 @@
364 data[2] = ' ';
365 data[3] = ' ';
366 /* test 1 byte injection at beginning of area */
367- testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
368+ test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
369 data, -1, -1);
370 printf(" 2");
371 fflush(stdout);
372@@ -172,7 +191,7 @@
373 data[2] = ' ';
374 data[3] = ' ';
375 /* test 1 byte injection at end of area */
376- testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
377+ test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1),
378 data + 3, -1, -1);
379
380 printf(" 3");
381@@ -183,7 +202,7 @@
382 data[2] = ' ';
383 data[3] = ' ';
384 /* test 1 byte injection at beginning of area */
385- testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
386+ test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
387 data, '\'', -1);
388 printf(" 4");
389 fflush(stdout);
390@@ -192,7 +211,7 @@
391 data[2] = ' ';
392 data[3] = ' ';
393 /* test 1 byte injection at end of area */
394- testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
395+ test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2),
396 data + 3, '\'', -1);
397 printf(" done\n");
398
399@@ -204,7 +223,7 @@
400 data[2] = ' ';
401 data[3] = ' ';
402 /* test 2 byte injection at beginning of area */
403- testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
404+ test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
405 data);
406 printf(" 2");
407 fflush(stdout);
408@@ -213,7 +232,7 @@
409 data[2] = ' ';
410 data[3] = ' ';
411 /* test 2 byte injection at end of area */
412- testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
413+ test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1),
414 data + 2);
415
416 printf(" 3");
417@@ -224,7 +243,7 @@
418 data[2] = ' ';
419 data[3] = ' ';
420 /* test 2 byte injection at beginning of area */
421- testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
422+ test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
423 data);
424 printf(" 4");
425 fflush(stdout);
426@@ -233,14 +252,15 @@
427 data[2] = ' ';
428 data[3] = ' ';
429 /* test 2 byte injection at end of area */
430- testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
431+ test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2),
432 data + 2);
433 printf(" done\n");
434
435 xmlFreeParserCtxt(ctxt);
436+ return(test_ret);
437 }
438
439-static void testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) {
440+static int testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) {
441 int i = 0;
442 int len, c;
443
444@@ -255,19 +275,25 @@
445 c = xmlCurrentChar(ctxt, &len);
446 if ((i == 0) || (i >= 0x80)) {
447 /* we must see an error there */
448- if (lastError != XML_ERR_INVALID_CHAR)
449+ if (lastError != XML_ERR_INVALID_CHAR) {
450 fprintf(stderr,
451 "Failed to detect invalid char for Byte 0x%02X\n", i);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800452+ return(1);
453+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500454 } else if (i == 0xD) {
455- if ((c != 0xA) || (len != 1))
456+ if ((c != 0xA) || (len != 1)) {
457 fprintf(stderr, "Failed to convert char for Byte 0x%02X\n", i);
458+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800459+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500460 } else if ((c != i) || (len != 1)) {
461 fprintf(stderr, "Failed to parse char for Byte 0x%02X\n", i);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800462+ return(1);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500463 }
464 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800465+ return(0);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500466 }
467
468-static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
469+static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) {
470 int i, j;
471 int len, c;
472
473@@ -284,10 +310,12 @@
474
475 /* if first bit of first char is set, then second bit must too */
476 if ((i & 0x80) && ((i & 0x40) == 0)) {
477- if (lastError != XML_ERR_INVALID_CHAR)
478+ if (lastError != XML_ERR_INVALID_CHAR) {
479 fprintf(stderr,
480 "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n",
481 i, j);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800482+ return(1);
483+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500484 }
485
486 /*
487@@ -295,10 +323,12 @@
488 * bits must be 10
489 */
490 else if ((i & 0x80) && ((j & 0xC0) != 0x80)) {
491- if (lastError != XML_ERR_INVALID_CHAR)
492+ if (lastError != XML_ERR_INVALID_CHAR) {
493 fprintf(stderr,
494 "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n",
495 i, j, c);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800496+ return(1);
497+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500498 }
499
500 /*
501@@ -306,10 +336,12 @@
502 * than 0x80, i.e. one of bits 5 to 1 of i must be set
503 */
504 else if ((i & 0x80) && ((i & 0x1E) == 0)) {
505- if (lastError != XML_ERR_INVALID_CHAR)
506+ if (lastError != XML_ERR_INVALID_CHAR) {
507 fprintf(stderr,
508 "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n",
509 i, j, c);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800510+ return(1);
511+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500512 }
513
514 /*
515@@ -317,10 +349,12 @@
516 * at least 3 bytes, but we give only 2 !
517 */
518 else if ((i & 0xE0) == 0xE0) {
519- if (lastError != XML_ERR_INVALID_CHAR)
520+ if (lastError != XML_ERR_INVALID_CHAR) {
521 fprintf(stderr,
522 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n",
523 i, j);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800524+ return(1);
525+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500526 }
527
528 /*
529@@ -329,6 +363,7 @@
530 else if ((lastError != 0) || (len != 2)) {
531 fprintf(stderr,
532 "Failed to parse char for Bytes 0x%02X 0x%02X\n", i, j);
533+ return(1);
534 }
535
536 /*
537@@ -338,12 +373,14 @@
538 fprintf(stderr,
539 "Failed to parse char for Bytes 0x%02X 0x%02X: expect %d got %d\n",
540 i, j, ((j & 0x3F) + ((i & 0x1F) << 6)), c);
541+ return(1);
542 }
543 }
544 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800545+ return(0);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500546 }
547
548-static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
549+static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) {
550 int i, j, k, K;
551 int len, c;
552 unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
553@@ -368,20 +405,24 @@
554 * at least 4 bytes, but we give only 3 !
555 */
556 if ((i & 0xF0) == 0xF0) {
557- if (lastError != XML_ERR_INVALID_CHAR)
558+ if (lastError != XML_ERR_INVALID_CHAR) {
559 fprintf(stderr,
560 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
561 i, j, K, data[3]);
562+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800563+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500564 }
565
566 /*
567 * The second and the third bytes must start with 10
568 */
569 else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80)) {
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\n",
574 i, j, K);
575+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800576+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500577 }
578
579 /*
580@@ -390,10 +431,12 @@
581 * the 6th byte of data[1] must be set
582 */
583 else if (((i & 0xF) == 0) && ((j & 0x20) == 0)) {
584- if (lastError != XML_ERR_INVALID_CHAR)
585+ if (lastError != XML_ERR_INVALID_CHAR) {
586 fprintf(stderr,
587 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n",
588 i, j, K);
589+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800590+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500591 }
592
593 /*
594@@ -401,10 +444,12 @@
595 */
596 else if (((value > 0xD7FF) && (value <0xE000)) ||
597 ((value > 0xFFFD) && (value <0x10000))) {
598- if (lastError != XML_ERR_INVALID_CHAR)
599+ if (lastError != XML_ERR_INVALID_CHAR) {
600 fprintf(stderr,
601 "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n",
602 value, i, j, K);
603+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800604+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500605 }
606
607 /*
608@@ -414,6 +459,7 @@
609 fprintf(stderr,
610 "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n",
611 i, j, K);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800612+ return(1);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500613 }
614
615 /*
616@@ -423,13 +469,15 @@
617 fprintf(stderr,
618 "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n",
619 i, j, data[2], value, c);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800620+ return(1);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500621 }
622 }
623 }
624 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800625+ return(0);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500626 }
627
628-static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
629+static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) {
630 int i, j, k, K, l, L;
631 int len, c;
632 unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
633@@ -458,10 +506,12 @@
634 * at least 5 bytes, but we give only 4 !
635 */
636 if ((i & 0xF8) == 0xF8) {
637- if (lastError != XML_ERR_INVALID_CHAR)
638+ if (lastError != XML_ERR_INVALID_CHAR) {
639 fprintf(stderr,
640 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
641 i, j, K, data[3]);
642+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800643+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500644 }
645
646 /*
647@@ -469,10 +519,12 @@
648 */
649 else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) ||
650 ((L & 0xC0) != 0x80)) {
651- if (lastError != XML_ERR_INVALID_CHAR)
652+ if (lastError != XML_ERR_INVALID_CHAR) {
653 fprintf(stderr,
654 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
655 i, j, K, L);
656+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800657+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500658 }
659
660 /*
661@@ -481,10 +533,12 @@
662 * the 6 or 5th byte of j must be set
663 */
664 else if (((i & 0x7) == 0) && ((j & 0x30) == 0)) {
665- if (lastError != XML_ERR_INVALID_CHAR)
666+ if (lastError != XML_ERR_INVALID_CHAR) {
667 fprintf(stderr,
668 "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
669 i, j, K, L);
670+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800671+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500672 }
673
674 /*
675@@ -493,10 +547,12 @@
676 else if (((value > 0xD7FF) && (value <0xE000)) ||
677 ((value > 0xFFFD) && (value <0x10000)) ||
678 (value > 0x10FFFF)) {
679- if (lastError != XML_ERR_INVALID_CHAR)
680+ if (lastError != XML_ERR_INVALID_CHAR) {
681 fprintf(stderr,
682 "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
683 value, i, j, K, L);
684+ return(1);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800685+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500686 }
687
688 /*
689@@ -506,6 +562,7 @@
690 fprintf(stderr,
691 "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n",
692 i, j, K);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800693+ return(1);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500694 }
695
696 /*
697@@ -515,11 +572,13 @@
698 fprintf(stderr,
699 "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n",
700 i, j, data[2], value, c);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800701+ return(1);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500702 }
703 }
704 }
705 }
706 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800707+ return(0);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500708 }
709
710 /**
711@@ -530,11 +589,12 @@
712 * cover the full range of UTF-8 chars accepted by XML-1.0
713 */
714
715-static void testCharRanges(void) {
716+static int testCharRanges(void) {
717 char data[5];
718 xmlParserCtxtPtr ctxt;
719 xmlParserInputBufferPtr buf;
720 xmlParserInputPtr input;
721+ int test_ret = 0;
722
723 memset(data, 0, 5);
724
725@@ -545,17 +605,19 @@
726 ctxt = xmlNewParserCtxt();
727 if (ctxt == NULL) {
728 fprintf(stderr, "Failed to allocate parser context\n");
729- return;
730+ return(1);
731 }
732 buf = xmlParserInputBufferCreateStatic(data, sizeof(data),
733 XML_CHAR_ENCODING_NONE);
734 if (buf == NULL) {
735 fprintf(stderr, "Failed to allocate input buffer\n");
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800736+ test_ret = 1;
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500737 goto error;
738 }
739 input = xmlNewInputStream(ctxt);
740 if (input == NULL) {
741 xmlFreeParserInputBuffer(buf);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800742+ test_ret = 1;
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500743 goto error;
744 }
745 input->filename = NULL;
746@@ -567,25 +629,28 @@
747
748 printf("testing char range: 1");
749 fflush(stdout);
750- testCharRangeByte1(ctxt, data);
751+ test_ret += testCharRangeByte1(ctxt, data);
752 printf(" 2");
753 fflush(stdout);
754- testCharRangeByte2(ctxt, data);
755+ test_ret += testCharRangeByte2(ctxt, data);
756 printf(" 3");
757 fflush(stdout);
758- testCharRangeByte3(ctxt, data);
759+ test_ret += testCharRangeByte3(ctxt, data);
760 printf(" 4");
761 fflush(stdout);
762- testCharRangeByte4(ctxt, data);
763+ test_ret += testCharRangeByte4(ctxt, data);
764 printf(" done\n");
765 fflush(stdout);
766
767 error:
768 xmlFreeParserCtxt(ctxt);
769+ return(test_ret);
770 }
771
772 int main(void) {
773
774+ int ret = 0;
775+
776 /*
777 * this initialize the library and check potential ABI mismatches
778 * between the version it was compiled for and the actual shared
779@@ -602,8 +667,9 @@
780 /*
781 * Run the tests
782 */
783- testCharRanges();
784- testDocumentRanges();
785+ ret += testCharRanges();
786+ ret += testDocumentRanges();
787+ printf("%s: testchar\n\n", (ret == 0) ? "PASS" : "FAIL");
788
789 /*
790 * Cleanup function for the XML library.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500791diff -uNr a/testlimits.c b/testlimits.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800792--- a/testlimits.c 2016-11-07 09:41:40.000000000 +0100
793+++ b/testlimits.c 2018-03-20 08:59:38.965581280 +0100
794@@ -1634,5 +1634,6 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500795 xmlCleanupParser();
796 xmlMemoryDump();
797
798+ printf("%s: testlimits\n", (ret == 0) ? "PASS" : "FAIL");
799 return(ret);
800 }
801diff -uNr a/testrecurse.c b/testrecurse.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800802--- a/testrecurse.c 2017-10-26 09:54:40.000000000 +0200
803+++ b/testrecurse.c 2018-03-20 09:00:46.781628749 +0100
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500804@@ -892,6 +892,7 @@
805 err++;
806 }
807 }
808+ printf("%s: %s\n", (err == 0) ? "PASS" : "FAIL", tst->desc);
809 return(err);
810 }
811
812@@ -961,5 +962,6 @@
813 xmlCleanupParser();
814 xmlMemoryDump();
815
816+ printf("%s: testrecurse\n\n", (ret == 0) ? "PASS" : "FAIL");
817 return(ret);
818 }