1# Makefile for the pthreads test suite. 2# If all of the .pass files can be created, the test suite has passed. 3# 4# -------------------------------------------------------------------------- 5# 6# Pthreads-win32 - POSIX Threads Library for Win32 7# Copyright(C) 1998 John E. Bossom 8# Copyright(C) 1999,2005 Pthreads-win32 contributors 9# 10# Contact Email: rpj@callisto.canberra.edu.au 11# 12# The current list of contributors is contained 13# in the file CONTRIBUTORS included with the source 14# code distribution. The list can also be seen at the 15# following World Wide Web location: 16# http://sources.redhat.com/pthreads-win32/contributors.html 17# 18# This library is free software; you can redistribute it and/or 19# modify it under the terms of the GNU Lesser General Public 20# License as published by the Free Software Foundation; either 21# version 2 of the License, or (at your option) any later version. 22# 23# This library is distributed in the hope that it will be useful, 24# but WITHOUT ANY WARRANTY; without even the implied warranty of 25# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26# Lesser General Public License for more details. 27# 28# You should have received a copy of the GNU Lesser General Public 29# License along with this library in the file COPYING.LIB; 30# if not, write to the Free Software Foundation, Inc., 31# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 32# 33 34DLL_VER = 2 35 36.PRECIOUS: $(*.exe) $(*.pass) 37.SECONDARY: 38 39target = $(CROSS) 40 41ifeq (,$(findstring i686, $(WTHR_TARGET_ARCH))) 42ifeq (,$(findstring x86_64, $(target))) 43#32bit 44BITNESS=-m32 45DLLFLAG=-m i386 46WINDRESFLAG=pe-i386 47else 48#64bit 49BITNESS=-m64 50DLLFLAG=-m i386:x86-64 51WINDRESFLAG=pe-x86-64 52endif 53else 54ifeq (,$(findstring x86_64, $(WTHR_TARGET_ARCH))) 55#32bit 56BITNESS=-m32 57DLLFLAG=-m i386 58WINDRESFLAG=pe-i386 59else 60BITNESS=-m64 61DLLFLAG=-m i386:x86-64 62WINDRESFLAG=pe-x86-64 63endif 64endif 65 66CC = $(target)-gcc $(BITNESS) 67CP = cp -f 68MV = mv -f 69RM = rm -f 70CAT = cat 71#CP = copy 72#MV = rename 73#RM = erase 74#CAT = type 75MKDIR = mkdir 76TOUCH = echo Passed > 77ECHO = @echo 78MAKE = make -k 79 80# 81# Mingw32 82# 83XXCFLAGS = 84XXLIBS = -lws2_32 85CFLAGS = -O3 -UNDEBUG -Wall $(XXCFLAGS) 86BUILD_DIR = .. 87INCLUDES = -I./include 88 89 90TEST = GC 91 92# Default lib version 93GCX = $(TEST)$(DLL_VER) 94 95# Files we need to run the tests 96# - paths are relative to pthreads build dir. 97HDR = include/pthread.h include/semaphore.h 98ifeq (,$(findstring i686, $(WTHR_TARGET_ARCH))) 99ifeq (,$(findstring x86_64, $(target))) 100#32bit 101LIB = ./outlib/libpthread$(GCX)-32.dll.a 102LIBSTATIC = ./outlib/libpthread$(GCX)-32.a 103DLL = ./outlib/pthread$(GCX)-32.dll 104LINKAGEFLAG = -lpthread$(GCX)-32 105else 106#64bit 107LIB = ./outlib/libpthread$(GCX)-64.dll.a 108LIBSTATIC = ./outlib/libpthread$(GCX)-64.a 109DLL = ./outlib/pthread$(GCX)-64.dll 110LINKAGEFLAG = -lpthread$(GCX)-64 111endif 112else 113ifeq (,$(findstring x86_64, $(WTHR_TARGET_ARCH))) 114#32bit 115LIB = ./outlib/libpthread$(GCX)-32.dll.a 116LIBSTATIC = ./outlib/libpthread$(GCX)-32.a 117DLL = ./outlib/pthread$(GCX)-32.dll 118LINKAGEFLAG = -lpthread$(GCX)-32 119else 120LIB = ./outlib/libpthread$(GCX)-64.dll.a 121LIBSTATIC = ./outlib/libpthread$(GCX)-64.a 122DLL = ./outlib/pthread$(GCX)-64.dll 123LINKAGEFLAG = -lpthread$(GCX)-64 124endif 125endif 126 127ifdef $(WTHR_STATIC_LIB) 128LIB = $(LIBSTATIC) 129endif 130 131# The next path is relative to $BUILD_DIR 132# QAPC = ../QueueUserAPCEx/User/quserex.dll 133 134COPYFILES = $(HDR) $(QAPC) 135 136# If a test case returns a non-zero exit code to the shell, make will 137# stop. 138 139TESTS = runall \ 140 sizes loadfree \ 141 self1 mutex5 mutex1 mutex1e mutex1n mutex1r \ 142 semaphore1 semaphore2 semaphore3 \ 143 condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \ 144 create1 create2 reuse1 reuse2 equal1 \ 145 kill1 valid1 valid2 \ 146 exit2 exit3 exit4 exit5 \ 147 join0 join1 detach1 join2 join3 \ 148 mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \ 149 mutex4 mutex6 mutex6n mutex6e mutex6r \ 150 mutex6s mutex6es mutex6rs \ 151 mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \ 152 count1 \ 153 once1 once2 once3 once4 self2 \ 154 cancel1 cancel2 \ 155 semaphore4 semaphore4t semaphore5 \ 156 barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \ 157 tsd1 tsd2 openmp1 delay1 delay2 eyal1 \ 158 condvar3 condvar3_1 condvar3_2 condvar3_3 \ 159 condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ 160 errno1 \ 161 rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \ 162 rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \ 163 context1 cancel3 cancel4 cancel5 cancel6a cancel6d \ 164 cancel7 cancel8 \ 165 cleanup0 cleanup1 cleanup2 cleanup3 \ 166 priority1 priority2 inherit1 \ 167 spin1 spin2 spin3 spin4 \ 168 exception1 exception2 exception3 \ 169 cancel9 create3 stress1 170 171STRESSTESTS = \ 172 stress1 173 174BENCHTESTS = \ 175 benchtest1 benchtest2 benchtest3 benchtest4 benchtest5 benchtest6 176 177STATICTESTS = runall \ 178 sizes \ 179 self1 mutex5 mutex1 mutex1e mutex1n mutex1r \ 180 semaphore1 semaphore2 semaphore3 \ 181 condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \ 182 create1 create2 reuse1 reuse2 equal1 \ 183 kill1 valid1 valid2 \ 184 exit2 exit3 exit4 exit5 \ 185 join0 join1 detach1 join2 join3 \ 186 mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \ 187 mutex4 mutex6 mutex6n mutex6e mutex6r \ 188 mutex6s mutex6es mutex6rs \ 189 mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \ 190 count1 \ 191 once1 once2 once3 once4 self2 \ 192 cancel1 cancel2 \ 193 semaphore4 semaphore4t semaphore5 \ 194 barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \ 195 tsd1 tsd2 delay1 delay2 eyal1 \ 196 condvar3 condvar3_1 condvar3_2 condvar3_3 \ 197 condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ 198 errno1 \ 199 rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \ 200 rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \ 201 context1 cancel3 cancel4 cancel5 cancel6a cancel6d \ 202 cancel7 cancel8 \ 203 cleanup0 cleanup1 cleanup2 cleanup3 \ 204 priority1 priority2 inherit1 \ 205 spin1 spin2 spin3 spin4 \ 206 exception1 exception2 exception3 \ 207 cancel9 create3 stress1 208 209PASSES = $(TESTS:%=%.pass) 210BENCHRESULTS = $(BENCHTESTS:%=%.bench) 211STRESSRESULTS = $(STRESSTESTS:%=%.pass) 212STATICRESULTS = $(STATICTESTS:%=%.pass) 213 214help: 215 @ $(ECHO) "Run one of the following command lines:" 216 @ $(ECHO) "make clean GC (to test using GC dll with C (no EH) applications)" 217 @ $(ECHO) "make clean GCX (to test using GC dll with C++ (EH) applications)" 218 @ $(ECHO) "make clean GCE (to test using GCE dll with C++ (EH) applications)" 219 @ $(ECHO) "make clean GC-bench (to benchtest using GNU C dll with C cleanup code)" 220 @ $(ECHO) "make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)" 221 @ $(ECHO) "make clean GC-stress (to stresstest using GNU C dll with C cleanup code)" 222 @ $(ECHO) "make clean GCE-stress (to stresstest using GNU C dll with C++ exception handling)" 223 @ $(ECHO) "make clean GC-static (to test using GC static lib with C (no EH) applications)" 224 225all: 226 @ $(MAKE) clean GC 227 @ $(MAKE) clean GCX 228 @ $(MAKE) clean GCE 229 230GC: 231 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 232 @ $(CP) $(BUILD_DIR)/$(LIB) . 233 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 234 @ $(CP) $(BUILD_DIR)/$(DLL) . 235 $(MAKE) TEST=GC CC=$(CROSS)-gcc XXCFLAGS="-D__CLEANUP_C" all-pass 236 237GCE: 238 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 239 @ $(CP) $(BUILD_DIR)/$(LIB) . 240 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 241 @ $(CP) $(BUILD_DIR)/$(DLL) . 242 $(MAKE) TEST=GCE CC=$(CROSS)-g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass 243 244GCX: 245 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 246 @ $(CP) $(BUILD_DIR)/$(LIB) . 247 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 248 @ $(CP) $(BUILD_DIR)/$(DLL) . 249 $(MAKE) TEST=GC CC=$(CROSS)-g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass 250 251GC-bench: 252 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 253 @ $(CP) $(BUILD_DIR)/$(LIB) . 254 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 255 @ $(CP) $(BUILD_DIR)/$(DLL) . 256 $(MAKE) TEST=GC CC=$(CROSS)-gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench 257 258GC-bench-static: 259 @ $(ECHO) Copying $(BUILD_DIR)/$(LIBSTATIC) 260 @ $(CP) $(BUILD_DIR)/$(LIBSTATIC) . 261 $(MAKE) TEST=GC CC=$(CROSS)-gcc XXCFLAGS="-D__CLEANUP_C -DWTHR_STATIC_LIB" XXLIBS="benchlib.o -lws2_32" all-bench 262 263GCE-bench: 264 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 265 @ $(CP) $(BUILD_DIR)/$(LIB) . 266 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 267 @ $(CP) $(BUILD_DIR)/$(DLL) . 268 $(MAKE) TEST=GCE CC=$(CROSS)-g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench 269 270GC-debug: 271 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 272 @ $(CP) $(BUILD_DIR)/$(LIB) . 273 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 274 @ $(CP) $(BUILD_DIR)/$(DLL) . 275 $(MAKE) TEST=GC CC=$(CROSS)-gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" DLL_VER="$(DLL_VER)d" all-pass 276 277GC-static: 278 @ $(ECHO) Copying $(BUILD_DIR)/$(LIBSTATIC) 279 @ $(CP) $(BUILD_DIR)/$(LIBSTATIC) . 280 $(MAKE) TEST=GC CC=$(CROSS)-gcc XXCFLAGS="-D__CLEANUP_C -DWTHR_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static 281 282GC-stress: 283 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 284 @ $(CP) $(BUILD_DIR)/$(LIB) . 285 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 286 @ $(CP) $(BUILD_DIR)/$(DLL) . 287 $(ECHO) Stress tests can take a long time since they are trying to 288 $(ECHO) expose weaknesses that may be intermittant or statistically rare. 289 $(ECHO) A pass does not prove correctness, but may give greater confidence. 290 $(MAKE) TEST=GC CC=$(CROSS)-gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress 291 292GCE-stress: 293 @ $(ECHO) Copying $(BUILD_DIR)/$(LIB) 294 @ $(CP) $(BUILD_DIR)/$(LIB) . 295 @ $(ECHO) Copying $(BUILD_DIR)/$(DLL) 296 @ $(CP) $(BUILD_DIR)/$(DLL) . 297 $(MAKE) TEST=GCE CC=$(CROSS)-g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress 298 299all-pass: $(PASSES) 300 @ $(ECHO) ALL TESTS PASSED! Congratulations! 301 302all-bench: $(BENCHRESULTS) 303 @ $(ECHO) BENCH TESTS COMPLETED. 304 305all-stress: $(STRESSRESULTS) 306 @ $(ECHO) STRESS TESTS COMPLETED. 307 308all-static: $(STATICRESULTS) 309 @ $(ECHO) ALL STATIC TESTS PASSED! Congratulations! 310 311benchtest1.bench: 312benchtest2.bench: 313benchtest3.bench: 314benchtest4.bench: 315benchtest5.bench: 316benchtest6.bench: 317 318barrier1.pass: semaphore4.pass 319barrier2.pass: barrier1.pass 320barrier3.pass: barrier2.pass 321barrier4.pass: barrier3.pass 322barrier5.pass: barrier4.pass 323barrier6.pass: barrier5.pass 324cancel1.pass: create1.pass 325cancel2.pass: cancel1.pass 326cancel2_1.pass: cancel2.pass 327cancel3.pass: context1.pass 328cancel4.pass: cancel3.pass 329cancel5.pass: cancel3.pass 330cancel6a.pass: cancel3.pass 331cancel6d.pass: cancel3.pass 332cancel7.pass: kill1.pass 333cancel8.pass: cancel7.pass 334cancel9.pass: cancel8.pass 335cleanup0.pass: cancel5.pass 336cleanup1.pass: cleanup0.pass 337cleanup2.pass: cleanup1.pass 338cleanup3.pass: cleanup2.pass 339condvar1.pass: 340condvar1_1.pass: condvar1.pass 341condvar1_2.pass: join2.pass 342condvar2.pass: condvar1.pass 343condvar2_1.pass: condvar2.pass join2.pass 344condvar3.pass: create1.pass condvar2.pass 345condvar3_1.pass: condvar3.pass join2.pass 346condvar3_2.pass: condvar3_1.pass 347condvar3_3.pass: condvar3_2.pass 348condvar4.pass: create1.pass 349condvar5.pass: condvar4.pass 350condvar6.pass: condvar5.pass 351condvar7.pass: condvar6.pass cleanup1.pass 352condvar8.pass: condvar7.pass 353condvar9.pass: condvar8.pass 354context1.pass: cancel2.pass 355count1.pass: join1.pass 356create1.pass: mutex2.pass 357create2.pass: create1.pass 358create3.pass: 359delay1.pass: cancel2.pass 360delay2.pass: delay1.pass 361detach1.pass: join0.pass 362equal1.pass: create1.pass 363errno1.pass: mutex3.pass 364exception1.pass: cancel4.pass 365exception2.pass: exception1.pass 366exception3.pass: exception2.pass 367exit1.pass: 368exit2.pass: create1.pass 369exit3.pass: create1.pass 370exit4.pass: 371exit5.pass: exit4.pass kill1.pass 372eyal1.pass: tsd1.pass 373inherit1.pass: join1.pass priority1.pass 374join0.pass: create1.pass 375join1.pass: create1.pass 376join2.pass: create1.pass 377join3.pass: join2.pass 378kill1.pass: 379loadfree.pass: pthread.dll 380mutex1.pass: self1.pass 381mutex1n.pass: mutex1.pass 382mutex1e.pass: mutex1.pass 383mutex1r.pass: mutex1.pass 384mutex2.pass: mutex1.pass 385mutex2r.pass: mutex2.pass 386mutex2e.pass: mutex2.pass 387mutex3.pass: create1.pass 388mutex3r.pass: mutex3.pass 389mutex3e.pass: mutex3.pass 390mutex4.pass: mutex3.pass 391mutex5.pass: 392mutex6.pass: mutex4.pass 393mutex6n.pass: mutex4.pass 394mutex6e.pass: mutex4.pass 395mutex6r.pass: mutex4.pass 396mutex6s.pass: mutex6.pass 397mutex6rs.pass: mutex6r.pass 398mutex6es.pass: mutex6e.pass 399mutex7.pass: mutex6.pass 400mutex7n.pass: mutex6n.pass 401mutex7e.pass: mutex6e.pass 402mutex7r.pass: mutex6r.pass 403mutex8.pass: mutex7.pass 404mutex8n.pass: mutex7n.pass 405mutex8e.pass: mutex7e.pass 406mutex8r.pass: mutex7r.pass 407once1.pass: create1.pass 408once2.pass: once1.pass 409once3.pass: once2.pass 410once4.pass: once3.pass 411openmp1.pass: tsd2.pass 412priority1.pass: join1.pass 413priority2.pass: priority1.pass barrier3.pass 414reuse1.pass: create2.pass 415reuse2.pass: reuse1.pass 416rwlock1.pass: condvar6.pass 417rwlock2.pass: rwlock1.pass 418rwlock3.pass: rwlock2.pass 419rwlock4.pass: rwlock3.pass 420rwlock5.pass: rwlock4.pass 421rwlock6.pass: rwlock5.pass 422rwlock7.pass: rwlock6.pass 423rwlock8.pass: rwlock7.pass 424rwlock2_t.pass: rwlock2.pass 425rwlock3_t.pass: rwlock2_t.pass 426rwlock4_t.pass: rwlock3_t.pass 427rwlock5_t.pass: rwlock4_t.pass 428rwlock6_t.pass: rwlock5_t.pass 429rwlock6_t2.pass: rwlock6_t.pass 430self1.pass: 431self2.pass: create1.pass 432semaphore1.pass: 433semaphore2.pass: 434semaphore3.pass: semaphore2.pass 435semaphore4.pass: semaphore3.pass cancel1.pass 436semaphore4t.pass: semaphore4.pass 437semaphore5.pass: semaphore4.pass 438sizes.pass: 439spin1.pass: 440spin2.pass: spin1.pass 441spin3.pass: spin2.pass 442spin4.pass: spin3.pass 443stress1.pass: 444tsd1.pass: barrier5.pass join1.pass 445tsd2.pass: tsd1.pass 446valid1.pass: join1.pass 447valid2.pass: valid1.pass 448runall.pass: 449sizes.pass: sizes.exe 450 @ $(ECHO) Running $* 451 ./$< > SIZES.$(TEST) 452 @ $(CAT) SIZES.$(TEST) 453 @ $(ECHO) Passed 454 @ $(TOUCH) $@ 455 456%.pass: %.exe 457 @ $(ECHO) Running $* 458 ./$* 459 @ $(ECHO) Passed 460 @ $(TOUCH) $@ 461 462%.bench: $(HDR) $(QAPC) $(XXLIBS) %.exe 463 @ $(ECHO) Running $* 464 ./$* 465 @ $(ECHO) Done 466 @ $(TOUCH) $@ 467 468benchtest%.exe: benchtest%.c $(HDR) $(QAPC) 469 @ $(ECHO) Compiling $@ 470 @ $(ECHO) $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L../outlib $(LINKAGEFLAG) -lsupc++ $(XXLIBS) 471 @ $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L../outlib $(LINKAGEFLAG) -lsupc++ $(XXLIBS) 472 473%.exe: %.c $(HDR) $(QAPC) 474 @ $(ECHO) Compiling $@ 475 @ $(ECHO) $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L../outlib $(LINKAGEFLAG) -lsupc++ $(XXLIBS) 476 @ $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L../outlib $(LINKAGEFLAG) -lsupc++ $(XXLIBS) 477 478%.pre: %.c $(HDR) 479 @ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES) 480 481%.s: %.c $(HDR) 482 @ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES) 483 484$(COPYFILES): 485 @ $(ECHO) Copying $(BUILD_DIR)/$@ 486 @ $(CP) $(BUILD_DIR)/$@ . 487 488benchlib.o: benchlib.c 489 @ $(ECHO) Compiling $@ 490 @ $(ECHO) $(CC) -c $(CFLAGS) $< $(INCLUDES) 491 @ $(CC) -c $(CFLAGS) $< $(INCLUDES) 492 493pthread.dll: 494 @ $(ECHO) Preparing loadfree TESTS 495 496clean: 497 - $(RM) *.dll 498 - $(RM) *.lib 499 - $(RM) pthread.h 500 - $(RM) semaphore.h 501 - $(RM) sched.h 502 - $(RM) *.a 503 - $(RM) *.e 504 - $(RM) *.i 505 - $(RM) *.o 506 - $(RM) *.so 507 - $(RM) *.obj 508 - $(RM) *.pdb 509 - $(RM) *.exe 510 - $(RM) *.pass 511 - $(RM) *.fail 512 - $(RM) *.x 513 - $(RM) *.bench 514 - $(RM) *.static 515 - $(RM) *.log 516