1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

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
This commit is contained in:
Daniel Veillard 2001-10-17 11:30:37 +00:00
parent 85c11fa206
commit ab7488efa5
25 changed files with 235 additions and 6 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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 "##"

View File

@ -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

View File

@ -0,0 +1,6 @@
<?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>

1
test/threads/a/a.dtd Normal file
View File

@ -0,0 +1 @@
<!ELEMENT a EMPTY>

7
test/threads/abc.dtd Normal file
View File

@ -0,0 +1,7 @@
<!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)>

7
test/threads/abc.xml Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE abc SYSTEM "http://example.org/abc.dtd">
<abc>
<a/>
<b/>
<c/>
</abc>

7
test/threads/acb.dtd Normal file
View File

@ -0,0 +1,7 @@
<!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)>

7
test/threads/acb.xml Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE acb SYSTEM "http://example.org/acb.dtd">
<acb>
<a/>
<c/>
<b/>
</acb>

View File

@ -0,0 +1,6 @@
<?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>

1
test/threads/b/b.dtd Normal file
View File

@ -0,0 +1 @@
<!ELEMENT b EMPTY>

7
test/threads/bac.dtd Normal file
View File

@ -0,0 +1,7 @@
<!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)>

7
test/threads/bac.xml Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE bac SYSTEM "http://example.org/bac.dtd">
<bac>
<b/>
<a/>
<c/>
</bac>

7
test/threads/bca.dtd Normal file
View File

@ -0,0 +1,7 @@
<!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)>

7
test/threads/bca.xml Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE bca SYSTEM "http://example.org/bca.dtd">
<bca>
<b/>
<c/>
<a/>
</bca>

View File

@ -0,0 +1,6 @@
<?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>

1
test/threads/c/c.dtd Normal file
View File

@ -0,0 +1 @@
<!ELEMENT c EMPTY>

7
test/threads/cab.dtd Normal file
View File

@ -0,0 +1,7 @@
<!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)>

7
test/threads/cab.xml Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE cab SYSTEM "http://example.org/cab.dtd">
<cab>
<c/>
<a/>
<b/>
</cab>

7
test/threads/cba.dtd Normal file
View File

@ -0,0 +1,7 @@
<!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)>

7
test/threads/cba.xml Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE cba SYSTEM "http://example.org/cba.dtd">
<cba>
<c/>
<b/>
<a/>
</cba>

6
test/threads/complex.xml Normal file
View File

@ -0,0 +1,6 @@
<?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>

View File

@ -0,0 +1,9 @@
<?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>

2
test/threads/invalid.xml Normal file
View File

@ -0,0 +1,2 @@
<!-- Well formed but invalid -->
<doc/>

87
testThreads.c Normal file
View File

@ -0,0 +1,87 @@
#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