Select Git revision
testThreads.c
-
Nick Wellnhofer authored
Apply the same cross-platform modifications as previously in runtest.c.
Nick Wellnhofer authoredApply the same cross-platform modifications as previously in runtest.c.
testThreads.c 6.58 KiB
#include "libxml.h"
#include <stdlib.h>
#include <stdio.h>
#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED)
#include <libxml/globals.h>
#include <libxml/threads.h>
#include <libxml/parser.h>
#include <libxml/catalog.h>
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#elif defined HAVE_WIN32_THREADS
#include <windows.h>
#elif defined HAVE_BEOS_THREADS
#include <OS.h>
#endif
#include <string.h>
#if !defined(_MSC_VER)
#include <unistd.h>
#endif
#include <assert.h>
#define MAX_ARGC 20
#define TEST_REPEAT_COUNT 500
#ifdef HAVE_PTHREAD_H
static pthread_t tid[MAX_ARGC];
#elif defined HAVE_WIN32_THREADS
static HANDLE tid[MAX_ARGC];
#elif defined HAVE_BEOS_THREADS
static thread_id tid[MAX_ARGC];
#endif
typedef struct {
const char *filename;
int okay;
} xmlThreadParams;
static const char *catalog = "test/threads/complex.xml";
static xmlThreadParams threadParams[] = {
{ "test/threads/abc.xml", 0 },
{ "test/threads/acb.xml", 0 },
{ "test/threads/bac.xml", 0 },
{ "test/threads/bca.xml", 0 },
{ "test/threads/cab.xml", 0 },
{ "test/threads/cba.xml", 0 },
{ "test/threads/invalid.xml", 0 }
};
static const unsigned int num_threads = sizeof(threadParams) /
sizeof(threadParams[0]);
#ifndef xmlDoValidityCheckingDefaultValue
#error xmlDoValidityCheckingDefaultValue is not a macro
#endif
#ifndef xmlGenericErrorContext
#error xmlGenericErrorContext is not a macro
#endif
static void *
thread_specific_data(void *private_data)
{
xmlDocPtr myDoc;
xmlThreadParams *params = (xmlThreadParams *) private_data;
const char *filename = params->filename;
int okay = 1;
if (!strcmp(filename, "test/threads/invalid.xml")) {
xmlDoValidityCheckingDefaultValue = 0;
xmlGenericErrorContext = stdout;
} else {