mirror of
				https://gitlab.gnome.org/GNOME/libxml2.git
				synced 2025-10-30 10:45:36 +03:00 
			
		
		
		
	tests: Remove testThreads.c
This was merged into runtest.c some time ago.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -13,7 +13,6 @@ | |||||||
| /runtest | /runtest | ||||||
| /runxmlconf | /runxmlconf | ||||||
| /testModule | /testModule | ||||||
| /testThreads |  | ||||||
| /testapi | /testapi | ||||||
| /testchar | /testchar | ||||||
| /testdict | /testdict | ||||||
|   | |||||||
| @@ -502,7 +502,6 @@ if(LIBXML2_WITH_TESTS) | |||||||
|         testlimits |         testlimits | ||||||
|         testparser |         testparser | ||||||
|         testrecurse |         testrecurse | ||||||
|         testThreads |  | ||||||
|     ) |     ) | ||||||
|     foreach(TEST ${TESTS}) |     foreach(TEST ${TESTS}) | ||||||
|         add_executable(${TEST} ${TEST}.c) |         add_executable(${TEST} ${TEST}.c) | ||||||
| @@ -510,7 +509,7 @@ if(LIBXML2_WITH_TESTS) | |||||||
|         target_link_libraries(${TEST} LibXml2) |         target_link_libraries(${TEST} LibXml2) | ||||||
|     endforeach() |     endforeach() | ||||||
|     if(Threads_FOUND) |     if(Threads_FOUND) | ||||||
|         foreach(TEST runtest testThreads) |         foreach(TEST runtest) | ||||||
|             target_link_libraries(${TEST} Threads::Threads) |             target_link_libraries(${TEST} Threads::Threads) | ||||||
|         endforeach() |         endforeach() | ||||||
|     endif() |     endif() | ||||||
| @@ -526,7 +525,6 @@ if(LIBXML2_WITH_TESTS) | |||||||
|     add_test(NAME testdict COMMAND testdict) |     add_test(NAME testdict COMMAND testdict) | ||||||
|     add_test(NAME testparser COMMAND testparser) |     add_test(NAME testparser COMMAND testparser) | ||||||
|     add_test(NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |     add_test(NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||||||
|     add_test(NAME testThreads COMMAND testThreads WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |  | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| if(LIBXML2_WITH_PYTHON) | if(LIBXML2_WITH_PYTHON) | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ check_PROGRAMS = \ | |||||||
| 	runtest \ | 	runtest \ | ||||||
| 	runxmlconf \ | 	runxmlconf \ | ||||||
| 	testModule \ | 	testModule \ | ||||||
| 	testThreads \ |  | ||||||
| 	testapi \ | 	testapi \ | ||||||
| 	testchar \ | 	testchar \ | ||||||
| 	testdict \ | 	testdict \ | ||||||
| @@ -148,10 +147,6 @@ xmlcatalog_CFLAGS = $(AM_CFLAGS) $(RDL_CFLAGS) $(ICONV_CFLAGS) | |||||||
| xmlcatalog_DEPENDENCIES = $(DEPS) | xmlcatalog_DEPENDENCIES = $(DEPS) | ||||||
| xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS) | xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS) | ||||||
|  |  | ||||||
| testThreads_SOURCES = testThreads.c |  | ||||||
| testThreads_DEPENDENCIES = $(DEPS) |  | ||||||
| testThreads_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS) |  | ||||||
|  |  | ||||||
| testModule_SOURCES=testModule.c | testModule_SOURCES=testModule.c | ||||||
| testModule_DEPENDENCIES = $(DEPS) | testModule_DEPENDENCIES = $(DEPS) | ||||||
| testModule_LDADD= $(LDADDS) | testModule_LDADD= $(LDADDS) | ||||||
| @@ -184,7 +179,6 @@ check-local: | |||||||
| 	$(CHECKER) ./testdict$(EXEEXT) | 	$(CHECKER) ./testdict$(EXEEXT) | ||||||
| 	$(CHECKER) ./testparser$(EXEEXT) | 	$(CHECKER) ./testparser$(EXEEXT) | ||||||
| 	$(CHECKER) ./testModule$(EXEEXT) | 	$(CHECKER) ./testModule$(EXEEXT) | ||||||
| 	$(CHECKER) ./testThreads$(EXEEXT) |  | ||||||
| 	$(CHECKER) ./runxmlconf$(EXEEXT) | 	$(CHECKER) ./runxmlconf$(EXEEXT) | ||||||
| 	$(CHECKER) ./runsuite$(EXEEXT) | 	$(CHECKER) ./runsuite$(EXEEXT) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ ignored_files = { | |||||||
|   "libxml.h": "internal only", |   "libxml.h": "internal only", | ||||||
|   "rngparser.c": "not yet integrated", |   "rngparser.c": "not yet integrated", | ||||||
|   "testModule.c": "test tool", |   "testModule.c": "test tool", | ||||||
|   "testThreads.c": "test tool", |  | ||||||
|   "testapi.c": "generated regression tests", |   "testapi.c": "generated regression tests", | ||||||
|   "runtest.c": "regression tests program", |   "runtest.c": "regression tests program", | ||||||
|   "runsuite.c": "regression tests program", |   "runsuite.c": "regression tests program", | ||||||
|   | |||||||
| @@ -699,7 +699,6 @@ checks = [ | |||||||
|     'runxmlconf', |     'runxmlconf', | ||||||
| # Disabled for now, see #694 | # Disabled for now, see #694 | ||||||
| #    'testModule', | #    'testModule', | ||||||
|     'testThreads', |  | ||||||
|     'testapi', |     'testapi', | ||||||
|     'testchar', |     'testchar', | ||||||
|     'testdict', |     'testdict', | ||||||
|   | |||||||
| @@ -4149,9 +4149,6 @@ c14n11WithoutCommentTest(const char *filename, | |||||||
|  *									* |  *									* | ||||||
|  ************************************************************************/ |  ************************************************************************/ | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * mostly a cut and paste from testThreads.c |  | ||||||
|  */ |  | ||||||
| #define	MAX_ARGC	20 | #define	MAX_ARGC	20 | ||||||
|  |  | ||||||
| typedef struct { | typedef struct { | ||||||
| @@ -4180,6 +4177,12 @@ thread_specific_data(void *private_data) | |||||||
|     const char *filename = params->filename; |     const char *filename = params->filename; | ||||||
|     int okay = 1; |     int okay = 1; | ||||||
|  |  | ||||||
|  |     if (xmlCheckThreadLocalStorage() != 0) { | ||||||
|  |         printf("xmlCheckThreadLocalStorage failed\n"); | ||||||
|  |         params->okay = 0; | ||||||
|  |         return(NULL); | ||||||
|  |     } | ||||||
|  |  | ||||||
| #ifdef LIBXML_THREAD_ALLOC_ENABLED | #ifdef LIBXML_THREAD_ALLOC_ENABLED | ||||||
|     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); |     xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										174
									
								
								testThreads.c
									
									
									
									
									
								
							
							
						
						
									
										174
									
								
								testThreads.c
									
									
									
									
									
								
							| @@ -1,174 +0,0 @@ | |||||||
| #include "config.h" |  | ||||||
| #include <stdlib.h> |  | ||||||
| #include <stdio.h> |  | ||||||
|  |  | ||||||
| #include <libxml/parser.h> |  | ||||||
| #include <libxml/threads.h> |  | ||||||
|  |  | ||||||
| #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) |  | ||||||
| #include <libxml/catalog.h> |  | ||||||
| #ifdef HAVE_PTHREAD_H |  | ||||||
| #include <pthread.h> |  | ||||||
| #elif defined(_WIN32) |  | ||||||
| #include <windows.h> |  | ||||||
| #endif |  | ||||||
| #include <string.h> |  | ||||||
| #include <assert.h> |  | ||||||
|  |  | ||||||
| #define	MAX_ARGC	20 |  | ||||||
| #define TEST_REPEAT_COUNT 500 |  | ||||||
| #ifdef HAVE_PTHREAD_H |  | ||||||
| static pthread_t tid[MAX_ARGC]; |  | ||||||
| #elif defined(_WIN32) |  | ||||||
| static HANDLE 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]); |  | ||||||
|  |  | ||||||
| static void * |  | ||||||
| thread_specific_data(void *private_data) |  | ||||||
| { |  | ||||||
|     xmlDocPtr myDoc; |  | ||||||
|     xmlThreadParams *params = (xmlThreadParams *) private_data; |  | ||||||
|     const char *filename = params->filename; |  | ||||||
|     int okay = 1; |  | ||||||
|     int options = 0; |  | ||||||
|  |  | ||||||
|     if (xmlCheckThreadLocalStorage() != 0) { |  | ||||||
|         printf("xmlCheckThreadLocalStorage failed\n"); |  | ||||||
|         params->okay = 0; |  | ||||||
|         return(NULL); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (strcmp(filename, "test/threads/invalid.xml") != 0) { |  | ||||||
|         options |= XML_PARSE_DTDVALID; |  | ||||||
|     } |  | ||||||
|     myDoc = xmlReadFile(filename, NULL, options); |  | ||||||
|     if (myDoc) { |  | ||||||
|         xmlFreeDoc(myDoc); |  | ||||||
|     } else { |  | ||||||
|         printf("parse failed\n"); |  | ||||||
| 	okay = 0; |  | ||||||
|     } |  | ||||||
|     params->okay = okay; |  | ||||||
|     return(NULL); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #ifdef _WIN32 |  | ||||||
| static DWORD WINAPI |  | ||||||
| win32_thread_specific_data(void *private_data) |  | ||||||
| { |  | ||||||
|     thread_specific_data(private_data); |  | ||||||
|     return(0); |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| #endif /* LIBXML_THREADS_ENABLED */ |  | ||||||
|  |  | ||||||
| int |  | ||||||
| main(void) |  | ||||||
| { |  | ||||||
|     unsigned int repeat; |  | ||||||
|     int status = 0; |  | ||||||
|  |  | ||||||
|     (void) repeat; |  | ||||||
|  |  | ||||||
|     xmlInitParser(); |  | ||||||
|  |  | ||||||
|     if (xmlCheckThreadLocalStorage() != 0) { |  | ||||||
|         printf("xmlCheckThreadLocalStorage failed for main thread\n"); |  | ||||||
|         return(1); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) |  | ||||||
|     for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) { |  | ||||||
|         unsigned int i; |  | ||||||
|         int ret; |  | ||||||
|  |  | ||||||
| 	xmlLoadCatalog(catalog); |  | ||||||
|  |  | ||||||
| #ifdef HAVE_PTHREAD_H |  | ||||||
|         memset(tid, 0xff, sizeof(*tid)*num_threads); |  | ||||||
|  |  | ||||||
| 	for (i = 0; i < num_threads; i++) { |  | ||||||
| 	    ret = pthread_create(&tid[i], NULL, thread_specific_data, |  | ||||||
| 				 (void *) &threadParams[i]); |  | ||||||
| 	    if (ret != 0) { |  | ||||||
| 		perror("pthread_create"); |  | ||||||
| 		exit(1); |  | ||||||
| 	    } |  | ||||||
| 	} |  | ||||||
| 	for (i = 0; i < num_threads; i++) { |  | ||||||
|             void *result; |  | ||||||
| 	    ret = pthread_join(tid[i], &result); |  | ||||||
| 	    if (ret != 0) { |  | ||||||
| 		perror("pthread_join"); |  | ||||||
| 		exit(1); |  | ||||||
| 	    } |  | ||||||
| 	} |  | ||||||
| #elif defined(_WIN32) |  | ||||||
|         for (i = 0; i < num_threads; i++) |  | ||||||
|         { |  | ||||||
|             tid[i] = (HANDLE) -1; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         for (i = 0; i < num_threads; i++) |  | ||||||
|         { |  | ||||||
|             DWORD useless; |  | ||||||
|             tid[i] = CreateThread(NULL, 0, |  | ||||||
|                 win32_thread_specific_data, &threadParams[i], 0, &useless); |  | ||||||
|             if (tid[i] == NULL) |  | ||||||
|             { |  | ||||||
|                 perror("CreateThread"); |  | ||||||
|                 exit(1); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (WaitForMultipleObjects (num_threads, tid, TRUE, INFINITE) == WAIT_FAILED) |  | ||||||
|             perror ("WaitForMultipleObjects failed"); |  | ||||||
|  |  | ||||||
|         for (i = 0; i < num_threads; i++) |  | ||||||
|         { |  | ||||||
|             DWORD exitCode; |  | ||||||
|             ret = GetExitCodeThread (tid[i], &exitCode); |  | ||||||
|             if (ret == 0) |  | ||||||
|             { |  | ||||||
|                 perror("GetExitCodeThread"); |  | ||||||
|                 exit(1); |  | ||||||
|             } |  | ||||||
|             CloseHandle (tid[i]); |  | ||||||
|         } |  | ||||||
| #endif /* pthreads */ |  | ||||||
|  |  | ||||||
| 	xmlCatalogCleanup(); |  | ||||||
|  |  | ||||||
| 	for (i = 0; i < num_threads; i++) { |  | ||||||
| 	    if (threadParams[i].okay == 0) { |  | ||||||
| 		printf("Thread %d handling %s failed\n", i, |  | ||||||
|                        threadParams[i].filename); |  | ||||||
|                 status = 1; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| #endif /* LIBXML_THREADS_ENABLED */ |  | ||||||
|  |  | ||||||
|     xmlCleanupParser(); |  | ||||||
|  |  | ||||||
|     return (status); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| @@ -206,12 +206,6 @@ UTILS = $(BINDIR)\xmllint.exe\ | |||||||
| 	$(BINDIR)\testapi.exe\ | 	$(BINDIR)\testapi.exe\ | ||||||
| 	$(BINDIR)\testlimits.exe | 	$(BINDIR)\testlimits.exe | ||||||
|  |  | ||||||
|  |  | ||||||
| !if "$(WITH_THREADS)" != "no" |  | ||||||
| UTILS = $(UTILS) $(BINDIR)\testThreads.exe |  | ||||||
| !endif |  | ||||||
|  |  | ||||||
|  |  | ||||||
| all : libxml libxmla utils | all : libxml libxmla utils | ||||||
|  |  | ||||||
| libxml : $(BINDIR)\$(XML_SO)  | libxml : $(BINDIR)\$(XML_SO)  | ||||||
|   | |||||||
| @@ -190,10 +190,6 @@ UTILS = $(BINDIR)/xmllint.exe\ | |||||||
| 	$(BINDIR)/testapi.exe\ | 	$(BINDIR)/testapi.exe\ | ||||||
| 	$(BINDIR)/testlimits.exe | 	$(BINDIR)/testlimits.exe | ||||||
|  |  | ||||||
| ifneq ($(WITH_THREADS),no) |  | ||||||
| UTILS += $(BINDIR)/testThreads.exe |  | ||||||
| endif |  | ||||||
|  |  | ||||||
| all : dep libxml libxmla utils | all : dep libxml libxmla utils | ||||||
|  |  | ||||||
| libxml : $(BINDIR)/$(XML_SO)  | libxml : $(BINDIR)/$(XML_SO)  | ||||||
|   | |||||||
| @@ -254,10 +254,6 @@ UTILS = $(BINDIR)\xmllint.exe\ | |||||||
| 	$(BINDIR)\testlimits.exe\ | 	$(BINDIR)\testlimits.exe\ | ||||||
| 	$(BINDIR)\testrecurse.exe | 	$(BINDIR)\testrecurse.exe | ||||||
| 	 | 	 | ||||||
| !if "$(WITH_THREADS)" != "no" |  | ||||||
| UTILS = $(UTILS) $(BINDIR)\testThreads.exe |  | ||||||
| !endif |  | ||||||
|  |  | ||||||
| !if "$(VCMANIFEST)" == "1" | !if "$(VCMANIFEST)" == "1" | ||||||
| _VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 | _VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 | ||||||
| _VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 | _VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user