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