/*
* runtest.c: C program to run libxml2 regression tests without
* requiring make or Python, and reducing platform dependancies
* to a strict minimum.
*
* To compile on Unixes:
* cc -o runtest `xml2-config --cflags` runtest.c `xml2-config --libs` -lpthread
*
* 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>
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef LIBXML_READER_ENABLED
#include <libxml/xmlreader.h>
#endif
#ifdef LIBXML_XINCLUDE_ENABLED
#include <libxml/xinclude.h>
#endif
#ifdef LIBXML_XPATH_ENABLED
#include <libxml/xpathInternals.h>
#ifdef LIBXML_XPTR_ENABLED
#include <libxml/xpointer.h>
#endif
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemas.h>
#include <libxml/xmlschemastypes.h>
#endif
#ifdef LIBXML_PATTERN_ENABLED
#endif
#ifdef LIBXML_C14N_ENABLED
#endif
#ifdef LIBXML_HTML_ENABLED
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
/*
* pseudo flag for the unification of HTML and XML tests
*/
#endif
#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED)
#include <string.h>
#endif
/*
* O_BINARY is just for Windows compatibility - if it isn't defined
* on this system, avoid any compilation error
*/
#ifdef O_BINARY
#else
#endif
struct testDesc {
};
static int checkTestFile(const char *filename);
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#include <io.h>
typedef struct
{
} glob_t;
#define GLOB_DOOFFS 0
unsigned int nb_paths = 0;
int len;
len++;
break;
}
}
if (len <= 0)
len = 0;
if (hFind == INVALID_HANDLE_VALUE)
return(0);
nb_paths = 20;
return(-1);
}
goto done;
continue;
break;
nb_paths *= 2;
}
break;
}
done:
return(0);
}
unsigned int i;
return;
}
}
#else
#include <glob.h>
#endif
/************************************************************************
* *
* Libxml2 specific routines *
* *
************************************************************************/
static int nb_tests = 0;
static int nb_errors = 0;
static int nb_leaks = 0;
static int extraMemoryFromResolver = 0;
static int
fatalError(void) {
exit(1);
}
/*
* 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
if (checkTestFile(URL)) {
} else {
}
return(ret);
}
/*
* Trapping the error messages at the generic level to grab the equivalent of
* stderr messages on CLI tools.
*/
static int testErrorsSize = 0;
static void XMLCDECL
int res;
if (testErrorsSize >= 32768)
return;
32768 - testErrorsSize,
/* buffer is full */
testErrorsSize = 32768;
testErrors[testErrorsSize] = 0;
} else {
testErrorsSize += res;
}
testErrors[testErrorsSize] = 0;
}
static void XMLCDECL
int res;
if (testErrorsSize >= 32768)
return;
32768 - testErrorsSize,
/* buffer is full */
testErrorsSize = 32768;
testErrors[testErrorsSize] = 0;
} else {
testErrorsSize += res;
}
testErrors[testErrorsSize] = 0;
}
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
*
* Displays current context within the input content for error tracking
*/
static void
/* skip backwards over any end-of-lines */
cur--;
}
n = 0;
/* search backwards for beginning-of-line (to max buff size) */
cur--;
/* calculate the error position in terms of the current position */
/* search forward for end-of-line (to max buff size) */
n = 0;
/* copy selected text to our buffer */
n++;
}
*ctnt = 0;
/* print out the selected text */
/* create blank line with problem pointer */
n = 0;
/* (leave buffer space for pointer + line terminator) */
if (*(ctnt) != '\t')
*(ctnt) = ' ';
ctnt++;
}
*ctnt++ = '^';
*ctnt = 0;
}
static void
int line = 0;
int domain;
const char *str;
return;
}
if (code == XML_ERR_OK)
return;
/*
* Maintain the compatibility with the legacy error handling
*/
}
}
} else {
}
}
if (code == XML_ERR_OK)
return;
switch (domain) {
case XML_FROM_PARSER:
break;
case XML_FROM_NAMESPACE:
break;
case XML_FROM_DTD:
case XML_FROM_VALID:
break;
case XML_FROM_HTML:
break;
case XML_FROM_MEMORY:
break;
case XML_FROM_OUTPUT:
break;
case XML_FROM_IO:
break;
case XML_FROM_XINCLUDE:
break;
case XML_FROM_XPATH:
break;
case XML_FROM_XPOINTER:
break;
case XML_FROM_REGEXP:
break;
case XML_FROM_MODULE:
break;
case XML_FROM_SCHEMASV:
break;
case XML_FROM_SCHEMASP:
break;
case XML_FROM_RELAXNGP:
break;
case XML_FROM_RELAXNGV:
break;
case XML_FROM_CATALOG:
break;
case XML_FROM_C14N:
break;
case XML_FROM_XSLT:
break;
default:
break;
}
if (code == XML_ERR_OK)
return;
switch (level) {
case XML_ERR_NONE:
break;
case XML_ERR_WARNING:
break;
case XML_ERR_ERROR:
break;
case XML_ERR_FATAL:
break;
}
if (code == XML_ERR_OK)
return;
int len;
else
} else {
}
if (code == XML_ERR_OK)
return;
}
}
int i;
buf[i] = ' ';
buf[i++] = '^';
buf[i] = 0;
}
}
static void
initializeLibxml2(void) {
#ifdef LIBXML_SCHEMAS_ENABLED
#endif
}
/************************************************************************
* *
* File name and path utilities *
* *
************************************************************************/
const char *cur;
return(NULL);
cur--;
if (*cur == '/')
return(cur + 1);
return(cur);
}
const char *suffix) {
const char *base;
/*************
if ((filename[0] == 't') && (filename[1] == 'e') &&
(filename[2] == 's') && (filename[3] == 't') &&
(filename[4] == '/'))
filename = &filename[5];
*************/
suffix = ".tmp";
out = "";
#ifdef VMS
suffixbuff[0]='_';
#endif
res[499] = 0;
}
return(0);
#if defined(_WIN32) && !defined(__CYGWIN__)
return(0);
#else
return(0);
#endif
return(1);
}
if (fd1 < 0)
return(-1);
if (fd2 < 0) {
return(-1);
}
while (1) {
return(1);
}
if (res1 == 0)
break;
return(1);
}
}
return(0);
}
int res;
int fd;
int idx = 0;
return(-1);
return(-1);
if (fd < 0)
return(-1);
if (res <= 0)
break;
break;
int ix;
break;
return(1);
}
}
}
char *base;
int siz = 0;
return(-1);
return(-1);
return(-1);
}
}
#if !defined(_WIN32)
return(-1);
}
#endif
return(0);
}
return(0);
}
/************************************************************************
* *
* Tests implementations *
* *
************************************************************************/
/************************************************************************
* *
* Parse to SAX based tests *
* *
************************************************************************/
/*
* empty SAX block
*/
NULL, /* internalSubset */
NULL, /* isStandalone */
NULL, /* hasInternalSubset */
NULL, /* hasExternalSubset */
NULL, /* resolveEntity */
NULL, /* getEntity */
NULL, /* entityDecl */
NULL, /* notationDecl */
NULL, /* attributeDecl */
NULL, /* elementDecl */
NULL, /* unparsedEntityDecl */
NULL, /* setDocumentLocator */
NULL, /* startDocument */
NULL, /* endDocument */
NULL, /* startElement */
NULL, /* endElement */
NULL, /* reference */
NULL, /* characters */
NULL, /* ignorableWhitespace */
NULL, /* processingInstruction */
NULL, /* comment */
NULL, /* xmlParserWarning */
NULL, /* xmlParserError */
NULL, /* xmlParserError */
NULL, /* getParameterEntity */
NULL, /* cdataBlock; */
NULL, /* externalSubset; */
1,
NULL,
NULL, /* startElementNs */
NULL, /* endElementNs */
NULL /* xmlStructuredErrorFunc */
};
static int callbacks = 0;
static int quiet = 0;
/**
* isStandaloneDebug:
* @ctxt: An XML parser context
*
* Is this document tagged standalone ?
*
* Returns 1 if true
*/
static int
{
callbacks++;
if (quiet)
return(0);
return(0);
}
/**
* hasInternalSubsetDebug:
* @ctxt: An XML parser context
*
* Does this document has an internal subset
*
* Returns 1 if true
*/
static int
{
callbacks++;
if (quiet)
return(0);
return(0);
}
/**
* hasExternalSubsetDebug:
* @ctxt: An XML parser context
*
* Does this document has an external subset
*
* Returns 1 if true
*/
static int
{
callbacks++;
if (quiet)
return(0);
return(0);
}
/**
* internalSubsetDebug:
* @ctxt: An XML parser context
*
* Does this document has an internal subset
*/
static void
{
callbacks++;
if (quiet)
return;
if (ExternalID == NULL)
else
else
}
/**
* externalSubsetDebug:
* @ctxt: An XML parser context
*
* Does this document has an external subset
*/
static void
{
callbacks++;
if (quiet)
return;
if (ExternalID == NULL)
else
else
}
/**
* resolveEntityDebug:
* @ctxt: An XML parser context
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
*
* Special entity resolver, better left to the parser, it has
* more context than the application layer.
* The default behaviour is to NOT resolve the entities, in that case
* the ENTITY_REF nodes are built in the structure (and the parameter
* values).
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/
static xmlParserInputPtr
{
callbacks++;
if (quiet)
return(NULL);
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
else
else
/*********
if (systemId != NULL) {
return(xmlNewInputFromFile(ctxt, (char *) systemId));
}
*********/
return(NULL);
}
/**
* getEntityDebug:
* @ctxt: An XML parser context
* @name: The entity name
*
* Get an entity by name
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/
static xmlEntityPtr
{
callbacks++;
if (quiet)
return(NULL);
return(NULL);
}
/**
* getParameterEntityDebug:
* @ctxt: An XML parser context
* @name: The entity name
*
* Get a parameter entity by name
*
* Returns the xmlParserInputPtr
*/
static xmlEntityPtr
{
callbacks++;
if (quiet)
return(NULL);
return(NULL);
}
/**
* entityDeclDebug:
* @ctxt: An XML parser context
* @name: the entity name
* @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
*
* An entity definition has been parsed
*/
static void
{
/* not all libraries handle printing null pointers nicely */
callbacks++;
if (quiet)
return;
}
/**
* attributeDeclDebug:
* @ctxt: An XML parser context
* @name: the attribute name
* @type: the attribute type
*
* An attribute definition has been parsed
*/
static void
{
callbacks++;
if (quiet)
return;
if (defaultValue == NULL)
else
}
/**
* elementDeclDebug:
* @ctxt: An XML parser context
* @name: the element name
* @type: the element type
* @content: the element value (without processing).
*
* An element definition has been parsed
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* notationDeclDebug:
* @ctxt: An XML parser context
* @name: The name of the notation
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
*
* What to do when a notation declaration has been parsed.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* unparsedEntityDeclDebug:
* @ctxt: An XML parser context
* @name: The name of the entity
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @notationName: the name of the notation
*
* What to do when an unparsed entity declaration is parsed
*/
static void
const xmlChar *notationName)
{
if (notationName == NULL)
callbacks++;
if (quiet)
return;
(char *) notationName);
}
/**
* setDocumentLocatorDebug:
* @ctxt: An XML parser context
* @loc: A SAX Locator
*
* Receive the document locator at startup, actually xmlDefaultSAXLocator
* Everything is available on the context, so this is useless in our case.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* startDocumentDebug:
* @ctxt: An XML parser context
*
* called when the document start being processed.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* endDocumentDebug:
* @ctxt: An XML parser context
*
* called when the document end has been detected.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* startElementDebug:
* @ctxt: An XML parser context
* @name: The element name
*
* called when an opening tag has been processed.
*/
static void
{
int i;
callbacks++;
if (quiet)
return;
}
}
}
/**
* endElementDebug:
* @ctxt: An XML parser context
* @name: The element name
*
* called when the end of an element has been detected.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* charactersDebug:
* @ctxt: An XML parser context
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* receiving some chars from the parser.
* Question: how much at a time ???
*/
static void
{
int i;
callbacks++;
if (quiet)
return;
for (i = 0;(i<len) && (i < 30);i++)
output[i] = 0;
}
/**
* referenceDebug:
* @ctxt: An XML parser context
* @name: The entity name
*
* called when an entity reference is detected.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* ignorableWhitespaceDebug:
* @ctxt: An XML parser context
* @ch: a xmlChar string
* @start: the first char in the string
* @len: the number of xmlChar
*
* receiving some ignorable whitespaces from the parser.
* Question: how much at a time ???
*/
static void
{
int i;
callbacks++;
if (quiet)
return;
for (i = 0;(i<len) && (i < 30);i++)
output[i] = 0;
}
/**
* processingInstructionDebug:
* @ctxt: An XML parser context
* @target: the target name
* @data: the PI data's
* @len: the number of xmlChar
*
* A processing instruction has been parsed.
*/
static void
{
callbacks++;
if (quiet)
return;
else
(char *) target);
}
/**
* cdataBlockDebug:
* @ctx: the user data (XML parser context)
* @value: The pcdata content
* @len: the block length
*
* called when a pcdata block has been parsed
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* commentDebug:
* @ctxt: An XML parser context
* @value: the comment content
*
* A comment has been parsed.
*/
static void
{
callbacks++;
if (quiet)
return;
}
/**
* warningDebug:
* @ctxt: An XML parser context
* @...: extra parameters for the message display
*
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
static void XMLCDECL
{
callbacks++;
if (quiet)
return;
}
/**
* errorDebug:
* @ctxt: An XML parser context
* @...: extra parameters for the message display
*
* Display and format a error messages, gives file, line, position and
* extra parameters.
*/
static void XMLCDECL
{
callbacks++;
if (quiet)
return;
}
/**
* fatalErrorDebug:
* @ctxt: An XML parser context
* @...: extra parameters for the message display
*
* Display and format a fatalError messages, gives file, line, position and
* extra parameters.
*/
static void XMLCDECL
{
callbacks++;
if (quiet)
return;
}
1,
NULL,
NULL,
NULL,
};
/*
* SAX2 specific callbacks
*/
/**
* startElementNsDebug:
* @ctxt: An XML parser context
* @name: The element name
*
* called when an opening tag has been processed.
*/
static void
int nb_namespaces,
const xmlChar **namespaces,
int nb_attributes,
int nb_defaulted,
const xmlChar **attributes)
{
int i;
callbacks++;
if (quiet)
return;
else
else
if (namespaces != NULL) {
for (i = 0;i < nb_namespaces * 2;i++) {
if (namespaces[i] != NULL)
i++;
}
}
if (attributes != NULL) {
else
}
}
}
/**
* endElementDebug:
* @ctxt: An XML parser context
* @name: The element name
*
* called when the end of an element has been detected.
*/
static void
{
callbacks++;
if (quiet)
return;
else
else
}
NULL,
NULL,
NULL,
};
#ifdef LIBXML_HTML_ENABLED
/**
* htmlstartElementDebug:
* @ctxt: An XML parser context
* @name: The element name
*
* called when an opening tag has been processed.
*/
static void
{
int i;
}
}
}
}
}
/**
* htmlcharactersDebug:
* @ctxt: An XML parser context
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* receiving some chars from the parser.
* Question: how much at a time ???
*/
static void
{
}
/**
* htmlcdataDebug:
* @ctxt: An XML parser context
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* receiving some cdata chars from the parser.
* Question: how much at a time ???
*/
static void
{
}
1,
NULL,
NULL,
NULL,
};
#endif /* LIBXML_HTML_ENABLED */
#ifdef LIBXML_SAX1_ENABLED
/**
* saxParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file using the SAX API and check for errors.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *err ATTRIBUTE_UNUSED,
int options) {
int ret;
char *temp;
nb_tests++;
fatalError();
}
return(-1);
}
/* for SAX we really want the callbacks though the context handlers */
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML) {
ret = 0;
} else
#endif
if (ret == XML_WAR_UNDECLARED_ENTITY) {
ret = 0;
}
if (ret != 0) {
return(1);
}
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML) {
ret = 0;
} else
#endif
if (options & XML_PARSE_SAX1) {
} else {
}
if (ret == XML_WAR_UNDECLARED_ENTITY) {
ret = 0;
}
ret = 1;
} else
/* switch back to structured error handling */
return(ret);
}
#endif
/************************************************************************
* *
* Parse to tree based tests *
* *
************************************************************************/
/**
* oldParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages: unused
*
* Parse a file using the old xmlParseFile API, then serialize back
* reparse the result and serialize again, then check for deviation
* in serialization.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
char *temp;
int res = 0;
nb_tests++;
/*
* base of the test, parse with the old API
*/
#ifdef LIBXML_SAX1_ENABLED
#else
#endif
return(1);
fatalError();
}
res = 1;
}
/*
* Parse the saved result to make sure the round trip is okay
*/
#ifdef LIBXML_SAX1_ENABLED
#else
#endif
return(1);
res = 1;
}
return(res);
}
#ifdef LIBXML_PUSH_ENABLED
/**
* pushParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages: unused
*
* Parse a file using the Push API, then serialize back
* to check for content.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *err ATTRIBUTE_UNUSED,
int options) {
const char *base;
int cur = 0;
nb_tests++;
/*
* load the document in memory and work from there.
*/
return(-1);
}
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
else
#endif
cur += 4;
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
else
#endif
break;
} else {
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
else
#endif
cur += 1024;
}
}
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
res = 1;
else
#endif
if (!res) {
return(-1);
}
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
else
#endif
return(-1);
}
if (res != 0) {
return(-1);
}
}
return(0);
}
#endif
/**
* memParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages: unused
*
* Parse a file using the old xmlReadMemory API, then serialize back
* reparse the result and serialize again, then check for deviation
* in serialization.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
const char *base;
nb_tests++;
/*
* load and parse the memory
*/
return(-1);
}
return(1);
}
return(-1);
}
return(0);
}
/**
* noentParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages: unused
*
* Parse a file with entity resolution, then serialize back
* reparse the result and serialize again, then check for deviation
* in serialization.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *err ATTRIBUTE_UNUSED,
int options) {
char *temp;
int res = 0;
nb_tests++;
/*
* base of the test, parse with the old API
*/
return(1);
fatalError();
}
res = 1;
}
/*
* Parse the saved result to make sure the round trip is okay
*/
return(1);
res = 1;
}
return(res);
}
/**
* errParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file using the xmlReadFile API and check for errors.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
int options) {
nb_tests++;
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML) {
} else
#endif
#ifdef LIBXML_XINCLUDE_ENABLED
if (options & XML_PARSE_XINCLUDE) {
} else
#endif
{
}
if (result) {
base = "";
size = 0;
} else {
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML) {
} else
#endif
}
}
}
if (res != 0) {
return(-1);
}
if (res != 0) {
return(-1);
}
} else if (options & XML_PARSE_DTDVALID) {
if (testErrorsSize != 0)
}
return(0);
}
#ifdef LIBXML_READER_ENABLED
/************************************************************************
* *
* Reader based tests *
* *
************************************************************************/
type,
name,
else {
}
}
static int
int ret;
return(-1);
nb_tests++;
fatalError();
}
if (t == NULL) {
return(-1);
}
}
#ifdef LIBXML_SCHEMAS_ENABLED
if (ret < 0) {
rng);
fclose(t);
return(0);
}
}
#endif
while (ret == 1) {
processNode(t, reader);
}
if (ret != 0) {
}
} else {
}
}
if (t != NULL) {
fclose(t);
if (ret) {
return(-1);
}
}
if (ret != 0) {
return(-1);
}
}
return(0);
}
/**
* streamParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file using the reader API and check for errors.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
int options) {
int ret;
return(ret);
}
/**
* walkerParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file using the walker, i.e. a reader built from a atree.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
int options) {
int ret;
return(-1);
}
return(ret);
}
/**
* streamMemParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file using the reader API from memory and check for errors.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
int options) {
int ret;
const char *base;
int size;
/*
* load and parse the memory
*/
return(-1);
}
return(ret);
}
#endif
#ifdef LIBXML_XPATH_ENABLED
#ifdef LIBXML_DEBUG_ENABLED
/************************************************************************
* *
* XPath and XPointer based tests *
* *
************************************************************************/
static void
nb_tests++;
#if defined(LIBXML_XPTR_ENABLED)
if (xptr) {
} else {
#endif
if (expr)
else {
/* res = xmlXPathEval(BAD_CAST str, ctxt); */
} else
}
#if defined(LIBXML_XPTR_ENABLED)
}
#endif
}
/**
* xpathExprTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing XPath standalone expressions and evaluate them
*
* Returns 0 in case of success, an error code otherwise
*/
static int
char *temp;
fatalError();
}
if (xpathOutput == NULL) {
return(-1);
}
"Cannot open %s for reading\n", filename);
return(-1);
}
len--;
while ((len >= 0) &&
if (len >= 0) {
"\n========================\nExpression: %s\n",
expression) ;
}
}
if (ret) {
}
}
return(ret);
}
/**
* xpathExprTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing XPath standalone expressions and evaluate them
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
}
/**
* xpathDocTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing XPath expressions and evaluate them against
* a set of corresponding documents.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options) {
size_t i;
if (xpathDocument == NULL) {
return(-1);
}
pattern[499] = 0;
if (res != 0)
}
return(ret);
}
#ifdef LIBXML_XPTR_ENABLED
/**
* xptrDocTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing XPath expressions and evaluate them against
* a set of corresponding documents.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options) {
size_t i;
if (xpathDocument == NULL) {
return(-1);
}
pattern[499] = 0;
if (res != 0)
}
return(ret);
}
#endif /* LIBXML_XPTR_ENABLED */
/**
* xmlidDocTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing xml:id and check for errors and verify
* that XPath queries will work on them as expected.
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *result,
const char *err,
int options) {
int res = 0;
int ret = 0;
char *temp;
if (xpathDocument == NULL) {
return(-1);
}
fatalError();
}
if (xpathOutput == NULL) {
return(-1);
}
testXPath("id('bar')", 0, 0);
if (ret) {
res = 1;
}
}
if (ret != 0) {
res = 1;
}
}
return(res);
}
#endif /* LIBXML_DEBUG_ENABLED */
#endif /* XPATH */
/************************************************************************
* *
* URI based tests *
* *
************************************************************************/
static void
int ret;
uri = xmlCreateURI();
if (ret != 0)
else {
xmlPrintURI(o, uri);
fprintf(o, "\n");
}
} else {
}
else
fprintf(o, "::ERROR::\n");
}
}
/**
* uriCommonTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing URI and check for errors
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *result,
const char *err,
const char *base) {
char *temp;
FILE *o, *f;
fatalError();
}
if (o == NULL) {
return(-1);
}
if (f == NULL) {
fclose(o);
return(-1);
}
while (1) {
/*
* read one line in string buffer.
*/
break;
/*
* remove the ending spaces
*/
while ((i > 0) &&
i--;
str[i] = 0;
}
nb_tests++;
}
fclose(f);
fclose(o);
if (ret) {
res = 1;
}
}
if (ret != 0) {
res = 1;
}
}
return(res);
}
/**
* uriParseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing URI and check for errors
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *result,
const char *err,
int options ATTRIBUTE_UNUSED) {
}
/**
* uriBaseTest:
* @filename: the file to parse
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing URI, compose them against a fixed base and
* check for errors
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *result,
const char *err,
int options ATTRIBUTE_UNUSED) {
"http://foo.com/path/to/index.html?orig#help"));
}
static int urip_current = 0;
static const char *urip_testURLs[] = {
"urip://example.com/r�sum�.html",
"urip://example.com/test?a=1&b=2%263&c=4#foo",
};
static const char *urip_rcvsURLs[] = {
/* it is an URI the strings must be escaped */
/* check that % escaping is not broken */
/* it's an URI path the strings must be escaped */
/* check that % escaping is not broken */
/* this is not an URI, this is a path, so this should not be escaped */
/* check that paths with % are not broken */
/* out of context the encoding can't be guessed byte by byte conversion */
/* verify we don't destroy URIs especially the query part */
"urip://example.com/test?a=1&b=2%263&c=4#foo",
};
static int urip_rlen;
/**
* uripMatch:
* @URI: an URI to test
*
* Check for an urip: query
*
* Returns 1 if yes and 0 if another Input module should be used
*/
static int
return(0);
/* Verify we received the escaped URL */
urip_success = 0;
return(1);
}
/**
* uripOpen:
* @URI: an URI to test
*
* Return a pointer to the urip: query handler, in this example simply
* the urip_current pointer...
*
* Returns an Input context or NULL in case or error
*/
static void *
return(NULL);
/* Verify we received the escaped URL */
urip_success = 0;
return((void *) urip_cur);
}
/**
* uripClose:
* @context: the read context
*
* Close the urip: query handler
*
* Returns 0 or -1 in case of error
*/
static int
urip_rlen = 0;
return(0);
}
/**
* uripRead:
* @context: the read context
* @buffer: where to store data
* @len: number of bytes to read
*
* Implement an urip: query read.
*
* Returns the number of bytes read or -1 in case of error
*/
static int
return(-1);
return(len);
}
static int
return(-1);
return(1);
}
/**
* uriPathTest:
* @filename: ignored
* @result: ignored
* @err: ignored
*
* Run a set of tests to check how Path and URI are handled before
* being passed to the I/O layer
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *result ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
int parsed;
int failures = 0;
/*
* register the new I/O handlers
*/
{
return(-1);
}
urip_success = 1;
if (urip_success != 1) {
failures++;
} else if (parsed != 1) {
failures++;
}
nb_tests++;
}
return(failures);
}
#ifdef LIBXML_SCHEMAS_ENABLED
/************************************************************************
* *
* Schemas tests *
* *
************************************************************************/
static int
const char *filename,
const char *result,
const char *err,
int options,
int ret = 0;
int validResult = 0;
char *temp;
return(-1);
}
fatalError();
}
if (schemasOutput == NULL) {
return(-1);
}
ctxt);
if (validResult == 0) {
} else if (validResult > 0) {
} else {
filename);
}
if (result) {
ret = 1;
}
}
ret = 1;
}
}
return(ret);
}
/**
* schemasTest:
* @filename: the schemas file
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a file containing URI, compose them against a fixed base and
* check for errors
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *resul ATTRIBUTE_UNUSED,
const char *errr ATTRIBUTE_UNUSED,
int options) {
const char *base2;
const char *instance;
size_t i;
char count = 0;
/* first compile the schemas if possible */
ctxt);
/*
* most of the mess is about the output filenames generated by the Makefile
*/
return(-1);
}
}
}
pattern[499] = 0;
len += 2;
}
testErrorsSize = 0;
testErrors[0] = 0;
result[499] = 0;
err[499] = 0;
} else {
continue;
}
} else {
nb_tests++;
if (ret != 0)
}
}
return(res);
}
/************************************************************************
* *
* Schemas tests *
* *
************************************************************************/
static int
const char *filename,
const char *result,
const char *err,
int options,
int ret = 0;
char *temp;
return(-1);
}
fatalError();
}
if (schemasOutput == NULL) {
return(-1);
}
ctxt);
if (ret == 0) {
} else if (ret > 0) {
} else {
filename);
}
if (result) {
ret = 1;
}
}
ret = 1;
}
}
return(ret);
}
/**
* rngTest:
* @filename: the schemas file
* @result: the file with expected result
* @err: the file with error messages
*
* Parse an RNG schemas and then apply it to the related .xml
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *resul ATTRIBUTE_UNUSED,
const char *errr ATTRIBUTE_UNUSED,
int options) {
const char *base2;
const char *instance;
size_t i;
char count = 0;
/* first compile the schemas if possible */
ctxt);
/*
* most of the mess is about the output filenames generated by the Makefile
*/
return(-1);
}
pattern[499] = 0;
testErrorsSize = 0;
testErrors[0] = 0;
result[499] = 0;
err[499] = 0;
} else {
continue;
}
} else {
nb_tests++;
if (res != 0)
}
}
return(res);
}
#ifdef LIBXML_READER_ENABLED
/**
* rngStreamTest:
* @filename: the schemas file
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a set of files with streaming, applying an RNG schemas
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *resul ATTRIBUTE_UNUSED,
const char *errr ATTRIBUTE_UNUSED,
int options) {
const char *base2;
const char *instance;
size_t i;
char count = 0;
int disable_err = 0;
/*
* most of the mess is about the output filenames generated by the Makefile
*/
return(-1);
}
/*
* strictly unifying the error messages is nearly impossible this
* hack is also done in the Makefile
*/
disable_err = 1;
pattern[499] = 0;
testErrorsSize = 0;
testErrors[0] = 0;
result[499] = 0;
err[499] = 0;
} else {
continue;
}
}
if (disable_err == 1)
else
if (ret != 0) {
}
}
return(res);
}
#endif /* READER */
#endif
#ifdef LIBXML_PATTERN_ENABLED
#ifdef LIBXML_READER_ENABLED
/************************************************************************
* *
* Patterns tests *
* *
************************************************************************/
if (type == XML_READER_TYPE_ELEMENT) {
/* do the check only on element start */
if (match) {
}
}
int ret;
if (type == XML_READER_TYPE_ELEMENT) {
if (ret < 0) {
}
"xmlPatternMatch and xmlStreamPush disagree\n");
" pattern %s node %s\n",
}
}
if ((type == XML_READER_TYPE_END_ELEMENT) ||
if (ret < 0) {
}
}
}
}
/**
* patternTest:
* @filename: the schemas file
* @result: the file with expected result
* @err: the file with error messages
*
* Parse a set of files with streaming, applying an RNG schemas
*
* Returns 0 in case of success, an error code otherwise
*/
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options) {
FILE *o, *f;
int len, i;
char *temp;
len -= 4;
result[499] = 0;
if (!checkTestFile(xml)) {
return(-1);
}
if (!checkTestFile(result)) {
return(-1);
}
if (f == NULL) {
return(-1);
}
fatalError();
}
if (o == NULL) {
fclose(f);
return(-1);
}
while (1) {
/*
* read one line in string buffer.
*/
break;
/*
* remove the ending spaces
*/
while ((i > 0) &&
i--;
str[i] = 0;
}
ret = 1;
} else {
int j;
}
namespaces[j++] = NULL;
namespaces[j++] = NULL;
0, &namespaces[0]);
"Pattern %s failed to compile\n", str);
ret = 1;
continue;
}
if (ret < 0) {
}
}
nb_tests++;
while (res == 1) {
}
if (res != 0) {
}
}
}
fclose(f);
fclose(o);
if (ret) {
ret = 1;
}
return(ret);
}
#endif /* READER */
#endif /* PATTERN */
#ifdef LIBXML_C14N_ENABLED
/************************************************************************
* *
* Canonicalization tests *
* *
************************************************************************/
static xmlXPathObjectPtr
/*
* load XPath expr as a file
*/
return(NULL);
}
/*
* Check the document is of the right kind
*/
return(NULL);
}
}
return(NULL);
}
return(NULL);
}
return(NULL);
}
/*
* Register namespaces
*/
fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
return(NULL);
}
}
/*
* Evaluate xpath
*/
return(NULL);
}
/* print_xpath_nodes(xpath->nodesetval); */
return(xpath);
}
/*
* Macro used to grow the current buffer.
*/
#define xxx_growBufferReentrant() { \
buffer_size *= 2; \
perror("realloc failed"); \
return(NULL); \
} \
}
static xmlChar **
int buffer_size = 0;
int len;
return(NULL);
}
str++;
len -= 2;
}
/*
* allocate an translation buffer.
*/
buffer_size = 1000;
perror("malloc failed");
return(NULL);
}
while(*str != '\0') {
}
}
return buffer;
}
static int
const char* xpath_filename, const char *ns_filename,
const char* result_file) {
int ret;
int nssize;
/*
* build an XML tree from a the file; we need to add default
* attributes and resolve all character and entities references
*/
return(-1);
}
/*
* Check the document is of the right kind
*/
return(-1);
}
/*
* load xpath file if specified
*/
if(xpath_filename) {
return(-1);
}
}
if (ns_filename != NULL) {
return(-1);
}
}
/*
* Canonical form
*/
/* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
with_comments, &result);
if (ret >= 0) {
ret = -1;
}
}
} else {
ret = -1;
}
/*
* Cleanup
*/
return(ret);
}
static int
const char *subdir) {
const char *base;
int len;
int ret = 0;
len -= 4;
if (!checkTestFile(buf)) {
return(-1);
}
if (checkTestFile(buf)) {
}
if (checkTestFile(buf)) {
}
nb_tests++;
ret = 1;
return(ret);
}
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
}
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
}
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
}
#endif
#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined (LIBXML_SAX1_ENABLED)
/************************************************************************
* *
* Catalog and threads test *
* *
************************************************************************/
/*
* mostly a cut and paste from testThreads.c
*/
static const char *testfiles[] = {
};
#endif
#ifndef xmlGenericErrorContext
#endif
static void *
{
} else {
}
if (myDoc) {
} else {
printf("parse failed\n");
okay = 0;
}
if (xmlDoValidityCheckingDefaultValue != 0) {
printf("ValidityCheckingDefaultValue override failed\n");
okay = 0;
}
if (xmlGenericErrorContext != stdout) {
printf("xmlGenericErrorContext override failed\n");
okay = 0;
}
} else {
if (xmlDoValidityCheckingDefaultValue != 1) {
printf("ValidityCheckingDefaultValue override failed\n");
okay = 0;
}
if (xmlGenericErrorContext != stderr) {
printf("xmlGenericErrorContext override failed\n");
okay = 0;
}
}
if (okay == 0)
return ((void *) Failed);
return ((void *) Okay);
}
#include <pthread.h>
static int
testThread(void)
{
unsigned int i, repeat;
int ret;
int res = 0;
nb_tests++;
for (i = 0; i < num_threads; i++) {
}
for (i = 0; i < num_threads; i++) {
(void *) testfiles[i]);
if (ret != 0) {
return (1);
}
}
for (i = 0; i < num_threads; i++) {
if (ret != 0) {
return (1);
}
}
for (i = 0; i < num_threads; i++)
i, testfiles[i]);
res = 1;
}
}
return (res);
}
#include <windows.h>
#include <string.h>
{
}
static int
testThread(void)
{
unsigned int i, repeat;
int res = 0;
nb_tests++;
for (i = 0; i < num_threads; i++) {
results[i] = 0;
}
for (i = 0; i < num_threads; i++) {
(void *) testfiles[i], 0,
&useless);
return(1);
}
}
WAIT_FAILED) {
return(1);
}
for (i = 0; i < num_threads; i++) {
if (ret == 0) {
return(1);
}
CloseHandle(tid[i]);
}
for (i = 0; i < num_threads; i++) {
i, testfiles[i]);
res = 1;
}
}
}
return (res);
}
#include <OS.h>
static int
testThread(void)
{
unsigned int i, repeat;
int res = 0;
for (i = 0; i < num_threads; i++) {
}
for (i = 0; i < num_threads; i++) {
tid[i] =
B_NORMAL_PRIORITY, (void *) testfiles[i]);
return (1);
}
}
for (i = 0; i < num_threads; i++) {
return (1);
}
}
for (i = 0; i < num_threads; i++)
}
}
return(1);
return (0);
}
#else
static int
testThread(void)
{
"Specific platform thread support not detected\n");
return (-1);
}
#endif
static int
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
return(testThread());
}
#endif
/************************************************************************
* *
* Tests Descriptions *
* *
************************************************************************/
static
{ "XML regression tests" ,
0 },
{ "XML regression tests on memory" ,
0 },
{ "XML entity subst regression tests" ,
{ "XML Namespaces regression tests",
0 },
{ "Error cases regression tests",
0 },
#ifdef LIBXML_READER_ENABLED
{ "Error cases stream regression tests",
0 },
{ "Reader regression tests",
0 },
{ "Reader entities substitution regression tests",
{ "Reader on memory regression tests",
0 },
{ "Walker regression tests",
0 },
#endif
#ifdef LIBXML_SAX1_ENABLED
{ "SAX1 callbacks regression tests" ,
{ "SAX2 callbacks regression tests" ,
0 },
#endif
#ifdef LIBXML_PUSH_ENABLED
{ "XML push regression tests" ,
0 },
#endif
#ifdef LIBXML_HTML_ENABLED
{ "HTML regression tests" ,
#ifdef LIBXML_PUSH_ENABLED
{ "Push HTML regression tests" ,
#endif
#ifdef LIBXML_SAX1_ENABLED
{ "HTML SAX regression tests" ,
#endif
#endif
#ifdef LIBXML_VALID_ENABLED
{ "Valid documents regression tests" ,
{ "Validity checking regression tests" ,
{ "General documents valid regression tests" ,
#endif
#ifdef LIBXML_XINCLUDE_ENABLED
{ "XInclude regression tests" ,
/* Ignore errors at this point ".err", */
{ "XInclude xmlReader regression tests",
/* Ignore errors at this point ".err", */
{ "XInclude regression tests stripping include nodes" ,
/* Ignore errors at this point ".err", */
{ "XInclude xmlReader regression tests stripping include nodes",
/* Ignore errors at this point ".err", */
#endif
#ifdef LIBXML_XPATH_ENABLED
#ifdef LIBXML_DEBUG_ENABLED
{ "XPath expressions regression tests" ,
0 },
{ "XPath document queries regression tests" ,
0 },
#ifdef LIBXML_XPTR_ENABLED
{ "XPointer document queries regression tests" ,
0 },
#endif
{ "xml:id regression tests" ,
0 },
#endif
#endif
{ "URI parsing tests" ,
0 },
{ "URI base composition tests" ,
0 },
{ "Path URI conversion tests" ,
0 },
#ifdef LIBXML_SCHEMAS_ENABLED
{ "Schemas regression tests" ,
0 },
{ "Relax-NG regression tests" ,
#ifdef LIBXML_READER_ENABLED
{ "Relax-NG streaming regression tests" ,
#endif
#endif
#ifdef LIBXML_PATTERN_ENABLED
#ifdef LIBXML_READER_ENABLED
{ "Pattern regression tests" ,
0 },
#endif
#endif
#ifdef LIBXML_C14N_ENABLED
{ "C14N with comments regression tests" ,
0 },
{ "C14N without comments regression tests" ,
0 },
{ "C14N exclusive without comments regression tests" ,
0 },
#endif
#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_SAX1_ENABLED)
{ "Catalog and Threads regression tests" ,
0 },
#endif
};
/************************************************************************
* *
* The main code driving the tests *
* *
************************************************************************/
static int
size_t i;
char *result;
char *error;
int mem;
continue;
fatalError();
}
} else {
}
fatalError();
}
} else {
}
} else {
mem = xmlMemUsed();
testErrorsSize = 0;
testErrors[0] = 0;
if (res != 0) {
nb_errors++;
err++;
}
else if (xmlMemUsed() != mem) {
if ((xmlMemUsed() != mem) &&
(extraMemoryFromResolver == 0)) {
nb_leaks++;
err++;
}
}
testErrorsSize = 0;
}
if (result)
if (error)
}
} else {
testErrorsSize = 0;
testErrors[0] = 0;
if (res != 0) {
nb_errors++;
err++;
}
}
return(err);
}
static int verbose = 0;
static int tests_quiet = 0;
static int
runtest(int i) {
if (res != 0)
ret++;
if (verbose) {
else
printf("Ran %d tests, %d errors, %d leaks\n",
}
return(ret);
}
int
int i, a, ret = 0;
int subset = 0;
for (a = 1; a < argc;a++) {
verbose = 1;
tests_quiet = 1;
else {
subset++;
}
}
}
}
if (subset == 0) {
}
}
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 /* ! LIBXML_OUTPUT_ENABLED */
int
return(1);
}
#endif