Skip to content
Snippets Groups Projects
Select Git revision
  • branch/OpenVMS
  • branch/default default protected
  • wild/1a5dd97bc5c0cdedc5a1e02ebc0ea5dbad28a72c
  • wild/ef383bb403b22bb062eca037fe9eb40395e5239d
  • wild/1b27403b1257ec30ce192e8d0af922c1f428c286
  • wild/37aeffd2f03981fb3090960ba53bb5f5c962970d
  • wild/2e949a79e46e9e813e8970a3ed05ded647a5c08e
  • wild/3fe73b8a3bb36ac30a3c4eb3d3d69d6ae453614c
  • wild/9aeb5555cd4f046940492b4572fbc39864a84ae2
  • wild/897288304f9a2037a9463f6001c4688afe711d08
  • wild/2b12dd122d8382282e90998ebadddcf09e847eaf
  • wild/3888945e4fe6438fa8127b7eaf1b10dd9499b15d
  • wild/53e7fce21ef05bf6fa534f067b88e139782e3d5e
  • wild/6096c67ce603c7404e05c9c91b3114f9c0781521
  • wild/69007011f857740b53ce4072c9b8ec202f6e83f3
  • wild/79ef52d5327d1637ddba0472ff28e137245e5c5f
  • wild/ff7aa1400d0d1c4cfc70f3384b2b9dba73668d14
  • wild/8e133c9799f0891d00226eb2f94cd7867d9baf67
  • wild/51e439c2a307243d9801ed7c639396a36ddef007
  • wild/5214eca35b040c5c2b3b3b25277226635e5b1837
  • 2.11.0
21 results

testThreads.c

Blame
  • 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 {