--- embedaddon/libxml2/runtest.c 2013/07/22 01:22:20 1.1.1.2 +++ embedaddon/libxml2/runtest.c 2014/06/15 19:53:30 1.1.1.3 @@ -11,11 +11,8 @@ * daniel@veillard.com */ -#ifdef HAVE_CONFIG_H #include "libxml.h" -#else #include -#endif #if !defined(_WIN32) || defined(__CYGWIN__) #include @@ -195,10 +192,6 @@ static void globfree(glob_t *pglob) { } } -#if !defined(__MINGW32__) -#define vsnprintf _vsnprintf -#define snprintf _snprintf -#endif #else #include #endif @@ -2100,7 +2093,7 @@ static void processNode(FILE *out, xmlTextReaderPtr re } static int streamProcessTest(const char *filename, const char *result, const char *err, - xmlTextReaderPtr reader, const char *rng) { + xmlTextReaderPtr reader, const char *rng, int options) { int ret; char *temp = NULL; FILE *t = NULL; @@ -2196,7 +2189,7 @@ streamParseTest(const char *filename, const char *resu int ret; reader = xmlReaderForFile(filename, NULL, options); - ret = streamProcessTest(filename, result, err, reader, NULL); + ret = streamProcessTest(filename, result, err, reader, NULL, options); xmlFreeTextReader(reader); return(ret); } @@ -2224,7 +2217,7 @@ walkerParseTest(const char *filename, const char *resu return(-1); } reader = xmlReaderWalker(doc); - ret = streamProcessTest(filename, result, err, reader, NULL); + ret = streamProcessTest(filename, result, err, reader, NULL, options); xmlFreeTextReader(reader); xmlFreeDoc(doc); return(ret); @@ -2256,7 +2249,7 @@ streamMemParseTest(const char *filename, const char *r return(-1); } reader = xmlReaderForMemory(base, size, filename, NULL, options); - ret = streamProcessTest(filename, result, err, reader, NULL); + ret = streamProcessTest(filename, result, err, reader, NULL, options); free((char *)base); xmlFreeTextReader(reader); return(ret); @@ -2731,7 +2724,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ésumé.html", + "urip://example.com/r" "\xe9" "sum" "\xe9" ".html", "urip://example.com/test?a=1&b=2%263&c=4#foo", NULL }; @@ -3315,9 +3308,11 @@ 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); + ret = streamProcessTest(instance, result, NULL, reader, filename, + options); else - ret = streamProcessTest(instance, result, err, reader, filename); + ret = streamProcessTest(instance, result, err, reader, filename, + options); xmlFreeTextReader(reader); if (ret != 0) { fprintf(stderr, "instance %s failed\n", instance); @@ -3939,60 +3934,7 @@ thread_specific_data(void *private_data) return ((void *) Okay); } -#if defined(linux) || defined(__sun) || defined(__APPLE_CC__) - -#include - -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 +#if defined WIN32 #include #include @@ -4118,6 +4060,59 @@ testThread(void) return(1); return (0); } + +#elif defined HAVE_PTHREAD_H +#include + +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) @@ -4210,6 +4205,14 @@ 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 },