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