/*
* runsuite.c: C program to run libxml2 againts published testsuites
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#ifdef HAVE_CONFIG_H
#include "libxml.h"
#else
#include <stdio.h>
#endif
#if !defined(_WIN32) || defined(__CYGWIN__)
#include <unistd.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <libxml/parserInternals.h>
#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_XPATH_ENABLED)
#include <libxml/xmlreader.h>
#include <libxml/xpathInternals.h>
#include <libxml/xmlschemas.h>
#include <libxml/xmlschemastypes.h>
static int verbose = 0;
#if defined(_WIN32) && !defined(__CYGWIN__)
#endif
/************************************************************************
* *
* File name and path utilities *
* *
************************************************************************/
return(0);
#if defined(_WIN32) && !defined(__CYGWIN__)
return(0);
#else
return(0);
#endif
return(1);
}
}
/************************************************************************
* *
* Libxml2 specific routines *
* *
************************************************************************/
static int nb_tests = 0;
static int nb_errors = 0;
static int nb_internals = 0;
static int nb_schematas = 0;
static int nb_unimplemented = 0;
static int nb_leaks = 0;
static int extraMemoryFromResolver = 0;
static int
fatalError(void) {
exit(1);
}
/*
* that's needed to implement <resource>
*/
static int nb_entities = 0;
static void resetEntities(void) {
int i;
for (i = 0;i < nb_entities;i++) {
if (testEntitiesName[i] != NULL)
xmlFree(testEntitiesName[i]);
if (testEntitiesValue[i] != NULL)
xmlFree(testEntitiesValue[i]);
}
nb_entities = 0;
}
if (nb_entities >= MAX_ENTITIES) {
return(-1);
}
nb_entities++;
return(0);
}
/*
* We need to trap calls to the resolver to not account memory for the catalog
* which is shared to the current running test. We also don't want to have
* network downloads modifying tests.
*/
static xmlParserInputPtr
int i;
for (i = 0;i < nb_entities;i++) {
(const xmlChar *) testEntitiesValue[i]);
}
return(ret);
}
}
if (checkTestFile(URL)) {
} else {
}
#if 0
}
#endif
return(ret);
}
/*
* Trapping the error messages at the generic level to grab the equivalent of
* stderr messages on CLI tools.
*/
static int testErrorsSize = 0;
testErrorsSize = 0; testErrors[0] = 0;
}
if (verbose) {
}
}
static void
int res;
if (testErrorsSize >= 32768)
return;
32768 - testErrorsSize,
/* buffer is full */
testErrorsSize = 32768;
testErrors[testErrorsSize] = 0;
} else {
testErrorsSize += res;
}
testErrors[testErrorsSize] = 0;
}
static void
initializeLibxml2(void) {
/*
* for every test, since it will confuse the memory leak detection.
* Note that normally this need not be done, since the cache is not
* created until set explicitely with xmlXPathContextSetCache();
* but for test purposes it is sometimes usefull to activate the
* cache by default for the whole library.
*/
/* used as default nanemspace in xstc tests */
#ifdef LIBXML_SCHEMAS_ENABLED
#endif
}
static xmlNodePtr
return(NULL);
return(NULL);
}
return(NULL);
return(ret);
}
static xmlChar *
return(NULL);
return(NULL);
}
return(NULL);
}
return(ret);
}
/************************************************************************
* *
* Test test/xsdtest/xsdtestsuite.xml *
* *
************************************************************************/
static int
return(0);
}
test_log("Failed to find test in correct line %ld\n",
xmlGetLineNo(cur));
return(1);
}
memt = xmlMemUsed();
/*
* dump the schemas to a buffer, then reparse it and compile the schemas
*/
buf = xmlBufferCreate();
fatalError();
}
pctxt);
test_log("Failed to detect incorect RNG line %ld\n",
xmlGetLineNo(test));
ret = 1;
goto done;
}
done:
test_log("Validation of tests starting line %ld leaked %d\n",
nb_leaks++;
}
return(ret);
}
static void
buf = xmlBufferCreate();
fatalError();
}
} else {
}
}
}
}
static void
return;
return;
}
/* Now process resources and subdir recursively */
}
}
}
static int
testErrorsSize = 0; testErrors[0] = 0;
}
}
return(xsdIncorectTestCase(tst));
}
xmlGetLineNo(cur));
return(1);
}
memt = xmlMemUsed();
/*
* dump the schemas to a buffer, then reparse it and compile the schemas
*/
buf = xmlBufferCreate();
fatalError();
}
pctxt);
memt = 0;
test_log("Failed to parse RNGtest line %ld\n",
xmlGetLineNo(test));
nb_errors++;
ret = 1;
goto done;
}
/*
* now scan all the siblings of correct to process the <valid> tests
*/
xmlGetLineNo(tmp));
} else {
/*
* We are ready to run the test
*/
mem = xmlMemUsed();
"test", NULL, 0);
test_log("Failed to parse valid instance line %ld\n",
xmlGetLineNo(tmp));
nb_errors++;
} else {
nb_tests++;
ctxt);
if (ret > 0) {
test_log("Failed to validate valid instance line %ld\n",
xmlGetLineNo(tmp));
nb_errors++;
} else if (ret < 0) {
test_log("Internal error validating instance line %ld\n",
xmlGetLineNo(tmp));
nb_errors++;
}
}
test_log("Validation of instance line %ld leaked %d\n",
nb_leaks++;
}
}
}
/*
* now scan all the siblings of correct to process the <invalid> tests
*/
xmlGetLineNo(tmp));
} else {
/*
* We are ready to run the test
*/
mem = xmlMemUsed();
"test", NULL, 0);
test_log("Failed to parse valid instance line %ld\n",
xmlGetLineNo(tmp));
nb_errors++;
} else {
nb_tests++;
ctxt);
if (ret == 0) {
test_log("Failed to detect invalid instance line %ld\n",
xmlGetLineNo(tmp));
nb_errors++;
} else if (ret < 0) {
test_log("Internal error validating instance line %ld\n",
xmlGetLineNo(tmp));
nb_errors++;
}
}
test_log("Validation of instance line %ld leaked %d\n",
nb_leaks++;
}
}
}
done:
test_log("Validation of tests starting line %ld leaked %d\n",
nb_leaks++;
}
return(ret);
}
static int
if (verbose) {
}
}
}
return(0);
}
static int
xsdTest(void) {
int ret = 0;
return(-1);
}
printf("## XML Schemas datatypes test suite from James Clark\n");
ret = -1;
goto done;
}
ret = -1;
goto done;
}
}
done:
return(ret);
}
static int
if (verbose) {
} else {
}
}
}
}
return(0);
}
static int
rngTest1(void) {
int ret = 0;
return(-1);
}
printf("## Relax NG test suite from James Clark\n");
ret = -1;
goto done;
}
ret = -1;
goto done;
}
}
done:
return(ret);
}
static int
rngTest2(void) {
int ret = 0;
return(-1);
}
printf("## Relax NG test suite for libxml2\n");
ret = -1;
goto done;
}
ret = -1;
goto done;
}
}
done:
return(ret);
}
/************************************************************************
* *
* *
************************************************************************/
static int
testErrorsSize = 0; testErrors[0] = 0;
mem = xmlMemUsed();
"string(ts:instanceDocument/@xlink:href)");
test_log("testGroup line %ld misses href for schemaDocument\n",
xmlGetLineNo(cur));
ret = -1;
goto done;
}
"Failed to build path to schemas testGroup line %ld : %s\n",
ret = -1;
goto done;
}
if (checkTestFile((const char *) path) <= 0) {
test_log("schemas for testGroup line %ld is missing: %s\n",
ret = -1;
goto done;
}
"string(ts:expected/@validity)");
xmlGetLineNo(cur));
ret = -1;
goto done;
}
nb_tests++;
ret = -1;
nb_errors++;
goto done;
}
ctxt);
if (ret > 0) {
test_log("valid instance %s failed to validate against %s\n",
nb_errors++;
} else if (ret < 0) {
test_log("valid instance %s got internal error validating %s\n",
nb_internals++;
nb_errors++;
}
if (ret == 0) {
test_log("Failed to detect invalid instance %s against %s\n",
nb_errors++;
}
} else {
test_log("instanceDocument line %ld has unexpected validity value%s\n",
ret = -1;
goto done;
}
done:
if (mem != xmlMemUsed()) {
test_log("Validation of tests starting line %ld leaked %d\n",
nb_leaks++;
}
return(ret);
}
static int
testErrorsSize = 0; testErrors[0] = 0;
mem = xmlMemUsed();
"string(ts:schemaTest/ts:schemaDocument/@xlink:href)");
test_log("testGroup line %ld misses href for schemaDocument\n",
xmlGetLineNo(cur));
ret = -1;
goto done;
}
test_log("Failed to build path to schemas testGroup line %ld : %s\n",
ret = -1;
goto done;
}
if (checkTestFile((const char *) path) <= 0) {
test_log("schemas for testGroup line %ld is missing: %s\n",
ret = -1;
goto done;
}
"string(ts:schemaTest/ts:expected/@validity)");
test_log("testGroup line %ld misses expected validity\n",
xmlGetLineNo(cur));
ret = -1;
goto done;
}
nb_tests++;
nb_schematas++;
ctxt);
test_log("valid schemas %s failed to parse\n",
path);
ret = 1;
nb_errors++;
}
test_log("valid schemas %s hit an unimplemented block\n",
path);
ret = 1;
nb_errors++;
}
} else {
/*
* We'll automatically mark the instances as failed
* if the schema was broken.
*/
nb_errors++;
}
"following-sibling::ts:instanceTest[1]");
}
nb_schematas++;
ctxt);
test_log("Failed to detect error in schemas %s\n",
path);
nb_errors++;
ret = 1;
}
test_log("invalid schemas %s hit an unimplemented block\n",
path);
ret = 1;
nb_errors++;
}
} else {
test_log("testGroup line %ld misses unexpected validity value%s\n",
ret = -1;
goto done;
}
done:
test_log("Processing test line %ld %s leaked %d\n",
nb_leaks++;
}
return(ret);
}
static int
int ret = 0;
return(-1);
}
return(-1);
}
if (contributor == NULL) {
}
}
ret = -1;
goto done;
}
}
done:
return(ret);
}
/************************************************************************
* *
* The driver for the tests *
* *
************************************************************************/
int
int ret = 0;
"Could not open the log file, running in verbose mode\n");
verbose = 1;
}
verbose = 1;
xsdTest();
else
printf("Ran %d tests, %d errors, %d leaks\n",
rngTest1();
else
printf("Ran %d tests, %d errors, %d leaks\n",
rngTest2();
else
printf("Ran %d tests, %d errors, %d leaks\n",
nb_internals = 0;
nb_schematas = 0;
printf("Ran %d tests (%d schemata), no errors\n",
else
printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n",
nb_internals = 0;
nb_schematas = 0;
printf("Ran %d tests (%d schemata), no errors\n",
else
printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n",
nb_internals = 0;
nb_schematas = 0;
printf("Ran %d tests (%d schemata), no errors\n",
else
printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n",
ret = 0;
printf("Total %d tests, no errors\n",
nb_tests);
} else {
ret = 1;
printf("Total %d tests, %d errors, %d leaks\n",
}
return(ret);
}
#else /* !SCHEMAS */
int
}
#endif