blob: cef20f484b5ea5db720a040708f85010bb38e03e [file] [log] [blame]
Daniel Veillard7e5c3f42008-07-29 16:12:31 +00001/*
2 * runsuite.c: C program to run libxml2 againts published testsuites
3 *
4 * See Copyright for the status of this software.
5 *
6 * daniel@veillard.com
7 */
8
Daniel Veillard7e5c3f42008-07-29 16:12:31 +00009#include "libxml.h"
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000010#include <stdio.h>
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000011
Daniel Veillard2e36da92008-09-25 15:36:43 +000012#ifdef LIBXML_XPATH_ENABLED
13
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000014#if !defined(_WIN32) || defined(__CYGWIN__)
15#include <unistd.h>
16#endif
17#include <string.h>
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21
22#include <libxml/parser.h>
23#include <libxml/parserInternals.h>
24#include <libxml/tree.h>
25#include <libxml/uri.h>
26#include <libxml/xmlreader.h>
27
28#include <libxml/xpath.h>
29#include <libxml/xpathInternals.h>
30
Daniel Veillard051d52c2008-07-29 16:44:59 +000031#define LOGFILE "runxmlconf.log"
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000032static FILE *logfile = NULL;
33static int verbose = 0;
34
Daniel Veillardda3fee42008-09-01 13:08:57 +000035#define NB_EXPECTED_ERRORS 15
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000036
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000037
Daniel Veillard37334572008-07-31 08:20:02 +000038const char *skipped_tests[] = {
39/* http://lists.w3.org/Archives/Public/public-xml-testsuite/2008Jul/0000.html */
40 "rmt-ns10-035",
41 NULL
42};
43
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000044/************************************************************************
45 * *
46 * File name and path utilities *
47 * *
48 ************************************************************************/
49
50static int checkTestFile(const char *filename) {
51 struct stat buf;
52
53 if (stat(filename, &buf) == -1)
54 return(0);
55
56#if defined(_WIN32) && !defined(__CYGWIN__)
57 if (!(buf.st_mode & _S_IFREG))
58 return(0);
59#else
60 if (!S_ISREG(buf.st_mode))
61 return(0);
62#endif
63
64 return(1);
65}
66
67static xmlChar *composeDir(const xmlChar *dir, const xmlChar *path) {
68 char buf[500];
69
70 if (dir == NULL) return(xmlStrdup(path));
71 if (path == NULL) return(NULL);
72
73 snprintf(buf, 500, "%s/%s", (const char *) dir, (const char *) path);
74 return(xmlStrdup((const xmlChar *) buf));
75}
76
77/************************************************************************
78 * *
79 * Libxml2 specific routines *
80 * *
81 ************************************************************************/
82
83static int nb_skipped = 0;
84static int nb_tests = 0;
85static int nb_errors = 0;
86static int nb_leaks = 0;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000087
88/*
89 * We need to trap calls to the resolver to not account memory for the catalog
Daniel Veillard09459bf2008-07-30 12:58:11 +000090 * and not rely on any external resources.
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000091 */
92static xmlParserInputPtr
Daniel Veillardae0765b2008-07-31 19:54:59 +000093testExternalEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED,
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000094 xmlParserCtxtPtr ctxt) {
95 xmlParserInputPtr ret;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000096
Daniel Veillard09459bf2008-07-30 12:58:11 +000097 ret = xmlNewInputFromFile(ctxt, (const char *) URL);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +000098
99 return(ret);
100}
101
102/*
103 * Trapping the error messages at the generic level to grab the equivalent of
104 * stderr messages on CLI tools.
105 */
106static char testErrors[32769];
107static int testErrorsSize = 0;
Daniel Veillardae0765b2008-07-31 19:54:59 +0000108static int nbError = 0;
109static int nbFatal = 0;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000110
111static void test_log(const char *msg, ...) {
112 va_list args;
113 if (logfile != NULL) {
114 fprintf(logfile, "\n------------\n");
115 va_start(args, msg);
116 vfprintf(logfile, msg, args);
117 va_end(args);
118 fprintf(logfile, "%s", testErrors);
119 testErrorsSize = 0; testErrors[0] = 0;
120 }
121 if (verbose) {
122 va_start(args, msg);
123 vfprintf(stderr, msg, args);
124 va_end(args);
125 }
126}
127
128static void
Daniel Veillardae0765b2008-07-31 19:54:59 +0000129testErrorHandler(void *userData ATTRIBUTE_UNUSED, xmlErrorPtr error) {
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000130 int res;
131
132 if (testErrorsSize >= 32768)
133 return;
Daniel Veillardae0765b2008-07-31 19:54:59 +0000134 res = snprintf(&testErrors[testErrorsSize],
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000135 32768 - testErrorsSize,
Daniel Veillardae0765b2008-07-31 19:54:59 +0000136 "%s:%d: %s\n", (error->file ? error->file : "entity"),
137 error->line, error->message);
138 if (error->level == XML_ERR_FATAL)
139 nbFatal++;
140 else if (error->level == XML_ERR_ERROR)
141 nbError++;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000142 if (testErrorsSize + res >= 32768) {
143 /* buffer is full */
144 testErrorsSize = 32768;
145 testErrors[testErrorsSize] = 0;
146 } else {
147 testErrorsSize += res;
148 }
149 testErrors[testErrorsSize] = 0;
150}
151
152static xmlXPathContextPtr ctxtXPath;
153
154static void
155initializeLibxml2(void) {
156 xmlGetWarningsDefaultValue = 0;
157 xmlPedanticParserDefault(0);
158
159 xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
160 xmlInitParser();
161 xmlSetExternalEntityLoader(testExternalEntityLoader);
162 ctxtXPath = xmlXPathNewContext(NULL);
163 /*
164 * Deactivate the cache if created; otherwise we have to create/free it
165 * for every test, since it will confuse the memory leak detection.
166 * Note that normally this need not be done, since the cache is not
167 * created until set explicitely with xmlXPathContextSetCache();
168 * but for test purposes it is sometimes usefull to activate the
169 * cache by default for the whole library.
170 */
171 if (ctxtXPath->cache != NULL)
172 xmlXPathContextSetCache(ctxtXPath, 0, -1, 0);
Daniel Veillardae0765b2008-07-31 19:54:59 +0000173 xmlSetStructuredErrorFunc(NULL, testErrorHandler);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000174}
175
176/************************************************************************
177 * *
178 * Run the xmlconf test if found *
179 * *
180 ************************************************************************/
181
182static int
Daniel Veillardae0765b2008-07-31 19:54:59 +0000183xmlconfTestInvalid(const char *id, const char *filename, int options) {
184 xmlDocPtr doc;
185 xmlParserCtxtPtr ctxt;
186 int ret = 1;
187
188 ctxt = xmlNewParserCtxt();
189 if (ctxt == NULL) {
190 test_log("test %s : %s out of memory\n",
191 id, filename);
192 return(0);
193 }
194 doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
195 if (doc == NULL) {
196 test_log("test %s : %s invalid document turned not well-formed too\n",
197 id, filename);
198 } else {
199 /* invalidity should be reported both in the context and in the document */
200 if ((ctxt->valid != 0) || (doc->properties & XML_DOC_DTDVALID)) {
201 test_log("test %s : %s failed to detect invalid document\n",
202 id, filename);
203 nb_errors++;
204 ret = 0;
205 }
206 xmlFreeDoc(doc);
207 }
208 xmlFreeParserCtxt(ctxt);
209 return(ret);
210}
211
212static int
213xmlconfTestValid(const char *id, const char *filename, int options) {
214 xmlDocPtr doc;
215 xmlParserCtxtPtr ctxt;
216 int ret = 1;
217
218 ctxt = xmlNewParserCtxt();
219 if (ctxt == NULL) {
220 test_log("test %s : %s out of memory\n",
221 id, filename);
222 return(0);
223 }
224 doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
225 if (doc == NULL) {
226 test_log("test %s : %s failed to parse a valid document\n",
227 id, filename);
228 nb_errors++;
229 ret = 0;
230 } else {
231 /* validity should be reported both in the context and in the document */
232 if ((ctxt->valid == 0) || ((doc->properties & XML_DOC_DTDVALID) == 0)) {
233 test_log("test %s : %s failed to validate a valid document\n",
234 id, filename);
235 nb_errors++;
236 ret = 0;
237 }
238 xmlFreeDoc(doc);
239 }
240 xmlFreeParserCtxt(ctxt);
241 return(ret);
242}
243
244static int
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000245xmlconfTestNotNSWF(const char *id, const char *filename, int options) {
246 xmlDocPtr doc;
247 int ret = 1;
248
249 /*
250 * In case of Namespace errors, libxml2 will still parse the document
251 * but log a Namesapce error.
252 */
253 doc = xmlReadFile(filename, NULL, options);
254 if (doc == NULL) {
255 test_log("test %s : %s failed to parse the XML\n",
256 id, filename);
257 nb_errors++;
258 ret = 0;
259 } else {
260 if ((xmlLastError.code == XML_ERR_OK) ||
261 (xmlLastError.domain != XML_FROM_NAMESPACE)) {
262 test_log("test %s : %s failed to detect namespace error\n",
263 id, filename);
264 nb_errors++;
265 ret = 0;
266 }
267 xmlFreeDoc(doc);
268 }
269 return(ret);
270}
271
272static int
273xmlconfTestNotWF(const char *id, const char *filename, int options) {
274 xmlDocPtr doc;
275 int ret = 1;
276
277 doc = xmlReadFile(filename, NULL, options);
278 if (doc != NULL) {
279 test_log("test %s : %s failed to detect not well formedness\n",
280 id, filename);
281 nb_errors++;
282 xmlFreeDoc(doc);
283 ret = 0;
284 }
285 return(ret);
286}
287
288static int
289xmlconfTestItem(xmlDocPtr doc, xmlNodePtr cur) {
290 int ret = -1;
291 xmlChar *type = NULL;
292 xmlChar *filename = NULL;
293 xmlChar *uri = NULL;
294 xmlChar *base = NULL;
295 xmlChar *id = NULL;
296 xmlChar *rec = NULL;
Daniel Veillardae0765b2008-07-31 19:54:59 +0000297 xmlChar *version = NULL;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000298 xmlChar *entities = NULL;
299 xmlChar *edition = NULL;
300 int options = 0;
301 int nstest = 0;
302 int mem, final;
Daniel Veillard37334572008-07-31 08:20:02 +0000303 int i;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000304
Daniel Veillard37334572008-07-31 08:20:02 +0000305 testErrorsSize = 0; testErrors[0] = 0;
Daniel Veillardae0765b2008-07-31 19:54:59 +0000306 nbError = 0;
307 nbFatal = 0;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000308 id = xmlGetProp(cur, BAD_CAST "ID");
309 if (id == NULL) {
310 test_log("test missing ID, line %ld\n", xmlGetLineNo(cur));
311 goto error;
312 }
Daniel Veillard37334572008-07-31 08:20:02 +0000313 for (i = 0;skipped_tests[i] != NULL;i++) {
314 if (!strcmp(skipped_tests[i], (char *) id)) {
315 test_log("Skipping test %s from skipped list\n", (char *) id);
316 ret = 0;
317 nb_skipped++;
318 goto error;
319 }
320 }
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000321 type = xmlGetProp(cur, BAD_CAST "TYPE");
322 if (type == NULL) {
323 test_log("test %s missing TYPE\n", (char *) id);
324 goto error;
325 }
326 uri = xmlGetProp(cur, BAD_CAST "URI");
327 if (uri == NULL) {
328 test_log("test %s missing URI\n", (char *) id);
329 goto error;
330 }
331 base = xmlNodeGetBase(doc, cur);
332 filename = composeDir(base, uri);
333 if (!checkTestFile((char *) filename)) {
334 test_log("test %s missing file %s \n", id,
335 (filename ? (char *)filename : "NULL"));
336 goto error;
337 }
338
Daniel Veillardae0765b2008-07-31 19:54:59 +0000339 version = xmlGetProp(cur, BAD_CAST "VERSION");
340
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000341 entities = xmlGetProp(cur, BAD_CAST "ENTITIES");
342 if (!xmlStrEqual(entities, BAD_CAST "none")) {
343 options |= XML_PARSE_DTDLOAD;
Daniel Veillard40ec29a2008-07-30 12:35:40 +0000344 options |= XML_PARSE_NOENT;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000345 }
346 rec = xmlGetProp(cur, BAD_CAST "RECOMMENDATION");
347 if ((rec == NULL) ||
348 (xmlStrEqual(rec, BAD_CAST "XML1.0")) ||
349 (xmlStrEqual(rec, BAD_CAST "XML1.0-errata2e")) ||
350 (xmlStrEqual(rec, BAD_CAST "XML1.0-errata3e")) ||
351 (xmlStrEqual(rec, BAD_CAST "XML1.0-errata4e"))) {
Daniel Veillardae0765b2008-07-31 19:54:59 +0000352 if ((version != NULL) && (!xmlStrEqual(version, BAD_CAST "1.0"))) {
353 test_log("Skipping test %s for %s\n", (char *) id,
354 (char *) version);
355 ret = 0;
356 nb_skipped++;
357 goto error;
358 }
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000359 ret = 1;
360 } else if ((xmlStrEqual(rec, BAD_CAST "NS1.0")) ||
361 (xmlStrEqual(rec, BAD_CAST "NS1.0-errata1e"))) {
362 ret = 1;
363 nstest = 1;
364 } else {
365 test_log("Skipping test %s for REC %s\n", (char *) id, (char *) rec);
366 ret = 0;
367 nb_skipped++;
368 goto error;
369 }
370 edition = xmlGetProp(cur, BAD_CAST "EDITION");
371 if ((edition != NULL) && (xmlStrchr(edition, '5') == NULL)) {
372 /* test limited to all versions before 5th */
373 options |= XML_PARSE_OLD10;
374 }
375
376 /*
377 * Reset errors and check memory usage before the test
378 */
379 xmlResetLastError();
380 testErrorsSize = 0; testErrors[0] = 0;
381 mem = xmlMemUsed();
382
383 if (xmlStrEqual(type, BAD_CAST "not-wf")) {
384 if (nstest == 0)
385 xmlconfTestNotWF((char *) id, (char *) filename, options);
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800386 else
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000387 xmlconfTestNotNSWF((char *) id, (char *) filename, options);
388 } else if (xmlStrEqual(type, BAD_CAST "valid")) {
Daniel Veillardae0765b2008-07-31 19:54:59 +0000389 options |= XML_PARSE_DTDVALID;
390 xmlconfTestValid((char *) id, (char *) filename, options);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000391 } else if (xmlStrEqual(type, BAD_CAST "invalid")) {
Daniel Veillardae0765b2008-07-31 19:54:59 +0000392 options |= XML_PARSE_DTDVALID;
393 xmlconfTestInvalid((char *) id, (char *) filename, options);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000394 } else if (xmlStrEqual(type, BAD_CAST "error")) {
Daniel Veillardae0765b2008-07-31 19:54:59 +0000395 test_log("Skipping error test %s \n", (char *) id);
396 ret = 0;
397 nb_skipped++;
398 goto error;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000399 } else {
400 test_log("test %s unknown TYPE value %s\n", (char *) id, (char *)type);
401 ret = -1;
402 goto error;
403 }
404
405 /*
406 * Reset errors and check memory usage after the test
407 */
408 xmlResetLastError();
409 final = xmlMemUsed();
410 if (final > mem) {
411 test_log("test %s : %s leaked %d bytes\n",
412 id, filename, final - mem);
413 nb_leaks++;
Daniel Veillard09459bf2008-07-30 12:58:11 +0000414 xmlMemDisplayLast(logfile, final - mem);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000415 }
416 nb_tests++;
417
418error:
419 if (type != NULL)
420 xmlFree(type);
421 if (entities != NULL)
422 xmlFree(entities);
423 if (edition != NULL)
424 xmlFree(edition);
Daniel Veillardae0765b2008-07-31 19:54:59 +0000425 if (version != NULL)
426 xmlFree(version);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000427 if (filename != NULL)
428 xmlFree(filename);
429 if (uri != NULL)
430 xmlFree(uri);
431 if (base != NULL)
432 xmlFree(base);
433 if (id != NULL)
434 xmlFree(id);
435 if (rec != NULL)
436 xmlFree(rec);
437 return(ret);
438}
439
440static int
Daniel Veillardaa6de472008-08-25 14:53:31 +0000441xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur, int level) {
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000442 xmlChar *profile;
443 int ret = 0;
444 int tests = 0;
Daniel Veillardaa6de472008-08-25 14:53:31 +0000445 int output = 0;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000446
Daniel Veillardaa6de472008-08-25 14:53:31 +0000447 if (level == 1) {
448 profile = xmlGetProp(cur, BAD_CAST "PROFILE");
449 if (profile != NULL) {
450 output = 1;
451 level++;
452 printf("Test cases: %s\n", (char *) profile);
453 xmlFree(profile);
454 }
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000455 }
456 cur = cur->children;
457 while (cur != NULL) {
458 /* look only at elements we ignore everything else */
459 if (cur->type == XML_ELEMENT_NODE) {
460 if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
Daniel Veillardaa6de472008-08-25 14:53:31 +0000461 ret += xmlconfTestCases(doc, cur, level);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000462 } else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) {
463 if (xmlconfTestItem(doc, cur) >= 0)
464 ret++;
465 tests++;
466 } else {
467 fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
468 }
469 }
470 cur = cur->next;
471 }
Daniel Veillardaa6de472008-08-25 14:53:31 +0000472 if (output == 1) {
473 if (tests > 0)
474 printf("Test cases: %d tests\n", tests);
475 }
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000476 return(ret);
477}
478
479static int
480xmlconfTestSuite(xmlDocPtr doc, xmlNodePtr cur) {
481 xmlChar *profile;
482 int ret = 0;
483
484 profile = xmlGetProp(cur, BAD_CAST "PROFILE");
485 if (profile != NULL) {
486 printf("Test suite: %s\n", (char *) profile);
487 xmlFree(profile);
488 } else
489 printf("Test suite\n");
490 cur = cur->children;
491 while (cur != NULL) {
492 /* look only at elements we ignore everything else */
493 if (cur->type == XML_ELEMENT_NODE) {
494 if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
Daniel Veillardaa6de472008-08-25 14:53:31 +0000495 ret += xmlconfTestCases(doc, cur, 1);
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000496 } else {
497 fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
498 }
499 }
500 cur = cur->next;
501 }
502 return(ret);
503}
504
505static void
506xmlconfInfo(void) {
507 fprintf(stderr, " you need to fetch and extract the\n");
508 fprintf(stderr, " latest XML Conformance Test Suites\n");
Stefan Kost851ef942011-05-10 13:06:09 +0300509 fprintf(stderr, " http://www.w3.org/XML/Test/xmlts20080827.tar.gz\n");
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000510 fprintf(stderr, " see http://www.w3.org/XML/Test/ for informations\n");
511}
512
513static int
514xmlconfTest(void) {
515 const char *confxml = "xmlconf/xmlconf.xml";
516 xmlDocPtr doc;
517 xmlNodePtr cur;
518 int ret = 0;
519
520 if (!checkTestFile(confxml)) {
521 fprintf(stderr, "%s is missing \n", confxml);
522 xmlconfInfo();
523 return(-1);
524 }
525 doc = xmlReadFile(confxml, NULL, XML_PARSE_NOENT);
526 if (doc == NULL) {
527 fprintf(stderr, "%s is corrupted \n", confxml);
528 xmlconfInfo();
529 return(-1);
530 }
531
532 cur = xmlDocGetRootElement(doc);
533 if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "TESTSUITE"))) {
534 fprintf(stderr, "Unexpected format %s\n", confxml);
535 xmlconfInfo();
536 ret = -1;
537 } else {
538 ret = xmlconfTestSuite(doc, cur);
539 }
540 xmlFreeDoc(doc);
541 return(ret);
542}
543
544/************************************************************************
545 * *
546 * The driver for the tests *
547 * *
548 ************************************************************************/
549
550int
551main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
552 int ret = 0;
553 int old_errors, old_tests, old_leaks;
554
555 logfile = fopen(LOGFILE, "w");
556 if (logfile == NULL) {
557 fprintf(stderr,
558 "Could not open the log file, running in verbose mode\n");
559 verbose = 1;
560 }
561 initializeLibxml2();
562
563 if ((argc >= 2) && (!strcmp(argv[1], "-v")))
564 verbose = 1;
565
566
567 old_errors = nb_errors;
568 old_tests = nb_tests;
569 old_leaks = nb_leaks;
570 xmlconfTest();
571 if ((nb_errors == old_errors) && (nb_leaks == old_leaks))
572 printf("Ran %d tests, no errors\n", nb_tests - old_tests);
573 else
574 printf("Ran %d tests, %d errors, %d leaks\n",
575 nb_tests - old_tests,
576 nb_errors - old_errors,
577 nb_leaks - old_leaks);
578 if ((nb_errors == 0) && (nb_leaks == 0)) {
579 ret = 0;
580 printf("Total %d tests, no errors\n",
581 nb_tests);
582 } else {
Daniel Veillardda3fee42008-09-01 13:08:57 +0000583 ret = 1;
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000584 printf("Total %d tests, %d errors, %d leaks\n",
585 nb_tests, nb_errors, nb_leaks);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000586 printf("See %s for detailed output\n", LOGFILE);
Daniel Veillardda3fee42008-09-01 13:08:57 +0000587 if ((nb_leaks == 0) && (nb_errors == NB_EXPECTED_ERRORS)) {
588 printf("%d errors were expected\n", nb_errors);
589 ret = 0;
590 }
Daniel Veillard7e5c3f42008-07-29 16:12:31 +0000591 }
592 xmlXPathFreeContext(ctxtXPath);
593 xmlCleanupParser();
594 xmlMemoryDump();
595
596 if (logfile != NULL)
597 fclose(logfile);
598 return(ret);
599}
Daniel Veillard2e36da92008-09-25 15:36:43 +0000600
601#else /* ! LIBXML_XPATH_ENABLED */
602#include <stdio.h>
603int
604main(int argc, char **argv) {
605 fprintf(stderr, "%s need XPath support\n", argv[0]);
606}
607#endif