diff options
Diffstat (limited to 'runtest.c')
-rw-r--r-- | runtest.c | 139 |
1 files changed, 68 insertions, 71 deletions
@@ -11,8 +11,11 @@ * daniel@veillard.com */ +#ifdef HAVE_CONFIG_H #include "libxml.h" +#else #include <stdio.h> +#endif #if !defined(_WIN32) || defined(__CYGWIN__) #include <unistd.h> @@ -192,6 +195,10 @@ static void globfree(glob_t *pglob) { } } +#if !defined(__MINGW32__) +#define vsnprintf _vsnprintf +#define snprintf _snprintf +#endif #else #include <glob.h> #endif @@ -2093,7 +2100,7 @@ static void processNode(FILE *out, xmlTextReaderPtr reader) { } static int streamProcessTest(const char *filename, const char *result, const char *err, - xmlTextReaderPtr reader, const char *rng, int options) { + xmlTextReaderPtr reader, const char *rng) { int ret; char *temp = NULL; FILE *t = NULL; @@ -2189,7 +2196,7 @@ streamParseTest(const char *filename, const char *result, const char *err, int ret; reader = xmlReaderForFile(filename, NULL, options); - ret = streamProcessTest(filename, result, err, reader, NULL, options); + ret = streamProcessTest(filename, result, err, reader, NULL); xmlFreeTextReader(reader); return(ret); } @@ -2217,7 +2224,7 @@ walkerParseTest(const char *filename, const char *result, const char *err, return(-1); } reader = xmlReaderWalker(doc); - ret = streamProcessTest(filename, result, err, reader, NULL, options); + ret = streamProcessTest(filename, result, err, reader, NULL); xmlFreeTextReader(reader); xmlFreeDoc(doc); return(ret); @@ -2249,7 +2256,7 @@ streamMemParseTest(const char *filename, const char *result, const char *err, return(-1); } reader = xmlReaderForMemory(base, size, filename, NULL, options); - ret = streamProcessTest(filename, result, err, reader, NULL, options); + ret = streamProcessTest(filename, result, err, reader, NULL); free((char *)base); xmlFreeTextReader(reader); return(ret); @@ -2724,7 +2731,7 @@ static const char *urip_testURLs[] = { "file:///path/to/a%20b.html", "/path/to/a b.html", "/path/to/a%20b.html", - "urip://example.com/r" "\xe9" "sum" "\xe9" ".html", + "urip://example.com/résumé.html", "urip://example.com/test?a=1&b=2%263&c=4#foo", NULL }; @@ -3308,11 +3315,9 @@ rngStreamTest(const char *filename, fprintf(stderr, "Failed to build reder for %s\n", instance); } if (disable_err == 1) - ret = streamProcessTest(instance, result, NULL, reader, filename, - options); + ret = streamProcessTest(instance, result, NULL, reader, filename); else - ret = streamProcessTest(instance, result, err, reader, filename, - options); + ret = streamProcessTest(instance, result, err, reader, filename); xmlFreeTextReader(reader); if (ret != 0) { fprintf(stderr, "instance %s failed\n", instance); @@ -3934,7 +3939,60 @@ thread_specific_data(void *private_data) return ((void *) Okay); } -#if defined WIN32 +#if defined(linux) || defined(__sun) || defined(__APPLE_CC__) + +#include <pthread.h> + +static pthread_t tid[MAX_ARGC]; + +static int +testThread(void) +{ + unsigned int i, repeat; + unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]); + void *results[MAX_ARGC]; + int ret; + int res = 0; + + xmlInitParser(); + + for (repeat = 0; repeat < 500; repeat++) { + xmlLoadCatalog(catalog); + nb_tests++; + + for (i = 0; i < num_threads; i++) { + results[i] = NULL; + tid[i] = (pthread_t) - 1; + } + + for (i = 0; i < num_threads; i++) { + ret = pthread_create(&tid[i], 0, thread_specific_data, + (void *) testfiles[i]); + if (ret != 0) { + fprintf(stderr, "pthread_create failed\n"); + return (1); + } + } + for (i = 0; i < num_threads; i++) { + ret = pthread_join(tid[i], &results[i]); + if (ret != 0) { + fprintf(stderr, "pthread_join failed\n"); + return (1); + } + } + + xmlCatalogCleanup(); + for (i = 0; i < num_threads; i++) + if (results[i] != (void *) Okay) { + fprintf(stderr, "Thread %d handling %s failed\n", + i, testfiles[i]); + res = 1; + } + } + return (res); +} + +#elif defined WIN32 #include <windows.h> #include <string.h> @@ -4060,59 +4118,6 @@ testThread(void) return(1); return (0); } - -#elif defined HAVE_PTHREAD_H -#include <pthread.h> - -static pthread_t tid[MAX_ARGC]; - -static int -testThread(void) -{ - unsigned int i, repeat; - unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]); - void *results[MAX_ARGC]; - int ret; - int res = 0; - - xmlInitParser(); - - for (repeat = 0; repeat < 500; repeat++) { - xmlLoadCatalog(catalog); - nb_tests++; - - for (i = 0; i < num_threads; i++) { - results[i] = NULL; - tid[i] = (pthread_t) - 1; - } - - for (i = 0; i < num_threads; i++) { - ret = pthread_create(&tid[i], 0, thread_specific_data, - (void *) testfiles[i]); - if (ret != 0) { - fprintf(stderr, "pthread_create failed\n"); - return (1); - } - } - for (i = 0; i < num_threads; i++) { - ret = pthread_join(tid[i], &results[i]); - if (ret != 0) { - fprintf(stderr, "pthread_join failed\n"); - return (1); - } - } - - xmlCatalogCleanup(); - for (i = 0; i < num_threads; i++) - if (results[i] != (void *) Okay) { - fprintf(stderr, "Thread %d handling %s failed\n", - i, testfiles[i]); - res = 1; - } - } - return (res); -} - #else static int testThread(void) @@ -4205,14 +4210,6 @@ testDesc testDescriptions[] = { { "Validity checking regression tests" , errParseTest, "./test/VC/*", "result/VC/", NULL, "", XML_PARSE_DTDVALID }, -#ifdef LIBXML_READER_ENABLED - { "Streaming validity checking regression tests" , - streamParseTest, "./test/valid/*.xml", "result/valid/", NULL, ".err.rdr", - XML_PARSE_DTDVALID }, - { "Streaming validity error checking regression tests" , - streamParseTest, "./test/VC/*", "result/VC/", NULL, ".rdr", - XML_PARSE_DTDVALID }, -#endif { "General documents valid regression tests" , errParseTest, "./test/valid/*", "result/valid/", "", ".err", XML_PARSE_DTDVALID }, |