Commit ab7488ef authored by Daniel Veillard's avatar Daniel Veillard

fixed some bugs in CFLAGS passing. added a specific threaded test case

* configure.in: fixed some bugs in CFLAGS passing.
* test/threads Makefile.am testThreads.c: added a specific
  threaded test case (really nasty, guaranteed).
Daniel
parent 85c11fa2
Wed Oct 17 13:29:02 CEST 2001 Daniel Veillard <daniel@veillard.com>
* configure.in: fixed some bugs in CFLAGS passing.
* test/threads Makefile.am testThreads.c: added a specific
threaded test case (really nasty, guaranteed).
Tue Oct 16 23:01:49 CEST 2001 Daniel Veillard <daniel@veillard.com>
* catalog.c: serious cleanup on the management of the
......
......@@ -7,7 +7,7 @@ SUBDIRS = include . doc example
INCLUDES = -I@srcdir@/include -I$(top_builddir)/include @THREAD_CFLAGS@ @Z_CFLAGS@
noinst_PROGRAMS=testSAX testHTML testXPath testURI testDocbook
noinst_PROGRAMS=testSAX testHTML testXPath testURI testDocbook testThreads
bin_PROGRAMS = xmllint xmlcatalog
......@@ -72,6 +72,11 @@ testXPath_LDFLAGS =
testXPath_DEPENDENCIES = $(DEPS)
testXPath_LDADD= $(LDADDS)
testThreads_SOURCES=testThreads.c
testThreads_LDFLAGS =
testThreads_DEPENDENCIES = $(DEPS)
testThreads_LDADD= $(LDADDS)
testURI_SOURCES=testURI.c
testURI_LDFLAGS =
testURI_DEPENDENCIES = $(DEPS)
......@@ -81,7 +86,7 @@ check-local: tests
testall : tests SVGtests SAXtests
tests: XMLtests XMLenttests HTMLtests Validtests URItests XPathtests XPtrtests XIncludetests Scripttests Catatests
tests: XMLtests XMLenttests HTMLtests Validtests URItests XPathtests XPtrtests XIncludetests Scripttests Catatests @TEST_THREADS@
HTMLtests : testHTML
@(echo > .memdump)
......@@ -417,6 +422,12 @@ SVGtests : xmllint
rm result.$$name result2.$$name ; \
fi ; fi ; done)
Threadtests : testThreads
@echo "##"
@echo "## Threaded regression tests"
@echo "##"
testThreads
SAXtests : testSAX
@(echo > .memdump)
@echo "##"
......
......@@ -249,6 +249,7 @@ dnl
THREAD_LIBS=""
WITH_THREADS=0
THREAD_CFLAGS=""
TEST_THREADS=""
AC_ARG_WITH(threads, [ --with-threads Add multithread support(off)])
if test "$with_threads" = "yes" ; then
......@@ -259,20 +260,22 @@ if test "$with_threads" = "yes" ; then
THREAD_LIBS="-lpthread"
AC_DEFINE(HAVE_LIBPTHREAD)
AC_DEFINE(HAVE_PTHREAD_H)
WITH_THREADS=1]))
WITH_THREADS="1"]))
if test "$WITH_THREADS" = "1" ; then
THREAD_CFLAGS="$XML_CFLAGS -D_REENTRANT"
THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
TEST_THREADS="Threadtests"
fi
fi
AC_ARG_WITH(thread-alloc, [ --with-thread-alloc Add per-thread memory(off)])
if test "$with_threads" = "yes" -a "$WITH_THREADS" = "1" ; then
THREAD_CFLAGS="$XML_CFLAGS -DLIBXML_THREAD_ALLOC_ENABLED"
if test "$with_threads_alloc" = "yes" -a "$WITH_THREADS" = "1" ; then
THREAD_CFLAGS="$THREAD_CFLAGS -DLIBXML_THREAD_ALLOC_ENABLED"
fi
AC_SUBST(THREAD_LIBS)
AC_SUBST(WITH_THREADS)
AC_SUBST(THREAD_CFLAGS)
AC_SUBST(TEST_THREADS)
AC_ARG_WITH(history, [ --with-history Add history support to xmllint shell(off)])
if test "$with_history" = "yes" ; then
......
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem systemIdStartString="http://example.org/a" rewritePrefix="a"/>
<nextCatalog catalog="c.example.org.xml"/>
</catalog>
<!ELEMENT a EMPTY>
<!ENTITY % a SYSTEM "http://example.org/a/a.dtd">
%a;
<!ENTITY % b SYSTEM "http://example.org/b/b.dtd">
%b;
<!ENTITY % c SYSTEM "http://example.org/c/c.dtd">
%c;
<!ELEMENT abc (a, b, c)>
<!DOCTYPE abc SYSTEM "http://example.org/abc.dtd">
<abc>
<a/>
<b/>
<c/>
</abc>
<!ENTITY % a SYSTEM "http://example.org/a/a.dtd">
%a;
<!ENTITY % c SYSTEM "http://example.org/c/c.dtd">
%c;
<!ENTITY % b SYSTEM "http://example.org/b/b.dtd">
%b;
<!ELEMENT acb (a, c, b)>
<!DOCTYPE acb SYSTEM "http://example.org/acb.dtd">
<acb>
<a/>
<c/>
<b/>
</acb>
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem systemIdStartString="http://example.org/b" rewritePrefix="b"/>
<nextCatalog catalog="c.example.org.xml"/>
</catalog>
<!ELEMENT b EMPTY>
<!ENTITY % b SYSTEM "http://example.org/b/b.dtd">
%b;
<!ENTITY % a SYSTEM "http://example.org/a/a.dtd">
%a;
<!ENTITY % c SYSTEM "http://example.org/c/c.dtd">
%c;
<!ELEMENT bac (b, a, c)>
<!DOCTYPE bac SYSTEM "http://example.org/bac.dtd">
<bac>
<b/>
<a/>
<c/>
</bac>
<!ENTITY % b SYSTEM "http://example.org/b/b.dtd">
%b;
<!ENTITY % c SYSTEM "http://example.org/c/c.dtd">
%c;
<!ENTITY % a SYSTEM "http://example.org/a/a.dtd">
%a;
<!ELEMENT bca (b, c, a)>
<!DOCTYPE bca SYSTEM "http://example.org/bca.dtd">
<bca>
<b/>
<c/>
<a/>
</bca>
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem systemIdStartString="http://example.org/c" rewritePrefix="c"/>
<rewriteSystem systemIdStartString="http://example.org/" rewritePrefix="./"/>
</catalog>
<!ELEMENT c EMPTY>
<!ENTITY % c SYSTEM "http://example.org/c/c.dtd">
%c;
<!ENTITY % a SYSTEM "http://example.org/a/a.dtd">
%a;
<!ENTITY % b SYSTEM "http://example.org/b/b.dtd">
%b;
<!ELEMENT cab (c, a, b)>
<!DOCTYPE cab SYSTEM "http://example.org/cab.dtd">
<cab>
<c/>
<a/>
<b/>
</cab>
<!ENTITY % c SYSTEM "http://example.org/c/c.dtd">
%c;
<!ENTITY % b SYSTEM "http://example.org/b/b.dtd">
%b;
<!ENTITY % a SYSTEM "http://example.org/a/a.dtd">
%a;
<!ELEMENT cba (c, b, a)>
<!DOCTYPE cba SYSTEM "http://example.org/cba.dtd">
<cba>
<c/>
<b/>
<a/>
</cba>
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<delegateSystem systemIdStartString="http://example.org/"
catalog="example.org.xml"/>
</catalog>
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<delegateSystem systemIdStartString="http://example.org/a"
catalog="a.example.org.xml"/>
<delegateSystem systemIdStartString="http://example.org/b"
catalog="b.example.org.xml"/>
<nextCatalog catalog="c.example.org.xml"/>
</catalog>
<!-- Well formed but invalid -->
<doc/>
#include <stdlib.h>
#include <features.h>
#include <libxml/xmlversion.h>
#ifdef LIBXML_THREAD_ENABLED
#include <libxml/globals.h>
#include <libxml/threads.h>
#include <libxml/parser.h>
#include <libxml/catalog.h>
#include <pthread.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#define MAX_ARGC 20
static pthread_t tid[MAX_ARGC];
static const char *catalog = "test/threads/complex.xml";
static const char *testfiles[] = {
"test/threads/abc.xml",
"test/threads/acb.xml",
"test/threads/bac.xml",
"test/threads/bca.xml",
"test/threads/cab.xml",
"test/threads/cba.xml",
"test/threads/invalid.xml",
};
static void *
thread_specific_data(void *private_data)
{
xmlDocPtr myDoc;
const char *filename = (const char *) private_data;
if (!strcmp(filename, "test/thread/invalid.xml") == 0) {
xmlDoValidityCheckingDefaultValue = 0;
xmlGenericErrorContext = stdout;
} else {
xmlDoValidityCheckingDefaultValue = 1;
xmlGenericErrorContext = stderr;
}
myDoc = xmlParseFile(filename);
if (myDoc) {
xmlFreeDoc(myDoc);
} else
printf("parse failed\n");
if (!strcmp(filename, "test/thread/invalid.xml") == 0) {
if (xmlDoValidityCheckingDefaultValue != 0)
printf("ValidityCheckingDefaultValue override failed\n");
if (xmlGenericErrorContext != stdout)
printf("ValidityCheckingDefaultValue override failed\n");
} else {
if (xmlDoValidityCheckingDefaultValue != 1)
printf("ValidityCheckingDefaultValue override failed\n");
if (xmlGenericErrorContext != stderr)
printf("ValidityCheckingDefaultValue override failed\n");
}
return (NULL);
}
int
main()
{
unsigned int i;
unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]);
xmlInitParser();
xmlLoadCatalog(catalog);
for (i = 0; i < num_threads; i++)
pthread_create(&tid[i], 0, thread_specific_data, (void *) testfiles[i]);
for (i = 0; i < num_threads; i++)
pthread_join(tid[i], NULL);
xmlCleanupParser();
xmlMemoryDump();
return (0);
}
#else /* !LIBXML_THREADS_ENABLED */
int
main()
{
fprintf(stderr, "libxml was not compiled with thread support\n");
return (0);
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment