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