Switch thread pool test to threading.h

This commit is contained in:
Nick Terrell
2016-12-31 19:10:13 -05:00
parent 3b9d434356
commit d132433534
3 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ matrix:
os: linux os: linux
sudo: false sudo: false
- env: Ubu=12.04cont Cmd="make zlibwrapper && make clean && make -C tests test-pool && make -C tests test-symbols && make clean && make -C tests test-zstd-nolegacy && make clean && make cmaketest && make clean && make -C contrib/pzstd googletest pzstd tests check && make -C contrib/pzstd clean" - env: Ubu=12.04cont Cmd="make zlibwrapper && make clean && make -C tests test-symbols && make clean && make -C tests test-zstd-nolegacy && make clean && make cmaketest && make clean && make -C contrib/pzstd googletest pzstd tests check && make -C contrib/pzstd clean"
os: linux os: linux
sudo: false sudo: false
language: cpp language: cpp
+5 -3
View File
@@ -48,8 +48,10 @@ ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
# Define *.exe as extension for Windows systems # Define *.exe as extension for Windows systems
ifneq (,$(filter Windows%,$(OS))) ifneq (,$(filter Windows%,$(OS)))
EXT =.exe EXT =.exe
PTHREAD = -DZSTD_PTHREAD
else else
EXT = EXT =
PTHREAD = -pthread -DZSTD_PTHREAD
endif endif
VOID = /dev/null VOID = /dev/null
@@ -158,8 +160,8 @@ else
$(CC) $(FLAGS) $^ -o $@$(EXT) -Wl,-rpath=$(ZSTDDIR) $(ZSTDDIR)/libzstd.so $(CC) $(FLAGS) $^ -o $@$(EXT) -Wl,-rpath=$(ZSTDDIR) $(ZSTDDIR)/libzstd.so
endif endif
pool : pool.c $(ZSTDDIR)/common/pool.c pool : pool.c $(ZSTDDIR)/common/pool.c $(ZSTDDIR)/common/threading.c
$(CC) $(FLAGS) -pthread -DZSTD_PTHREAD $^ -o $@$(EXT) $(CC) $(FLAGS) $(PTHREAD) $^ -o $@$(EXT)
namespaceTest: namespaceTest:
if $(CC) namespaceTest.c ../lib/common/xxhash.c -o $@ ; then echo compilation should fail; exit 1 ; fi if $(CC) namespaceTest.c ../lib/common/xxhash.c -o $@ ; then echo compilation should fail; exit 1 ; fi
@@ -225,7 +227,7 @@ zstd-playTests: datagen
file $(ZSTD) file $(ZSTD)
ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST) ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST)
test: test-zstd test-fullbench test-fuzzer test-zstream test-longmatch test-invalidDictionaries test: test-zstd test-fullbench test-fuzzer test-zstream test-longmatch test-invalidDictionaries test-pool
test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zstream32 test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zstream32
+3 -3
View File
@@ -1,5 +1,5 @@
#include "pool.h" #include "pool.h"
#include <pthread.h> #include "threading.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
@@ -31,7 +31,7 @@ int testOrder(size_t numThreads, size_t queueLog) {
POOL_ctx *ctx = POOL_create(numThreads, queueLog); POOL_ctx *ctx = POOL_create(numThreads, queueLog);
ASSERT_TRUE(ctx); ASSERT_TRUE(ctx);
data.i = 0; data.i = 0;
ASSERT_FALSE(pthread_mutex_init(&data.mutex, NULL)); pthread_mutex_init(&data.mutex, NULL);
{ {
size_t i; size_t i;
for (i = 0; i < 1024; ++i) { for (i = 0; i < 1024; ++i) {
@@ -46,7 +46,7 @@ int testOrder(size_t numThreads, size_t queueLog) {
ASSERT_EQ(i, data.data[i]); ASSERT_EQ(i, data.data[i]);
} }
} }
ASSERT_FALSE(pthread_mutex_destroy(&data.mutex)); pthread_mutex_destroy(&data.mutex);
return 0; return 0;
} }