Minor tweaks to Makefile for ZeroTier::Utils in selftest, make-liblwip.mk for warning suppression

This commit is contained in:
Joseph Henry
2017-09-18 12:06:45 -07:00
parent 055a58ac63
commit 3a82d4bada
3 changed files with 13 additions and 4 deletions

View File

@@ -304,9 +304,11 @@ shared_jni_lib: picotcp $(ZTO_OBJS)
tests: selftest nativetest ztproxy tests: selftest nativetest ztproxy
# intercept # intercept
ZT_UTILS:=zto/node/Utils.cpp -Izto/node
selftest: selftest:
$(CXX) $(CXXFLAGS) -D__SELFTEST__ $(STACK_DRIVER_FLAGS) $(LIBZT_FLAGS) \ $(CXX) $(CXXFLAGS) -D__SELFTEST__ $(STACK_DRIVER_FLAGS) $(LIBZT_FLAGS) \
$(SANFLAGS) $(LIBZT_INCLUDES) $(ZT_INCLUDES) test/selftest.cpp -o \ $(SANFLAGS) $(LIBZT_INCLUDES) $(ZT_INCLUDES) $(ZT_UTILS) test/selftest.cpp -o \
$(BUILD)/selftest -L$(BUILD) -lzt -lpthread $(BUILD)/selftest -L$(BUILD) -lzt -lpthread
@./check.sh $(BUILD)/selftest @./check.sh $(BUILD)/selftest
nativetest: nativetest:

View File

@@ -120,7 +120,7 @@ LWIPFILESW=$(wildcard $(LWIPFILES))
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o)) LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
%.o: %.o:
$(CXX) $(CFLAGS) -c $(<:.o=.c) -o obj/$@ $(CXX) $(CFLAGS) -Wno-deprecated -c $(<:.o=.c) -o obj/$@
all: all:
.PHONY: all .PHONY: all
@@ -136,4 +136,4 @@ liblwip.a: clean $(LWIPOBJS)
#libtool -static -o $@ $^ #libtool -static -o $@ $^
.depend: $(LWIPFILES) .depend: $(LWIPFILES)
$(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend $(CCDEP) $(CFLAGS) -x c -MM $^ > .depend || rm -f .depend

View File

@@ -49,7 +49,10 @@
#include <signal.h> #include <signal.h>
#include "libzt.h" #include "libzt.h"
#if defined(__SELFTEST__)
#include "Utils.hpp" #include "Utils.hpp"
#endif
#define EXIT_ON_FAIL false #define EXIT_ON_FAIL false
@@ -258,9 +261,13 @@ void wait_until_tplus_s(long int original_time, int tplus_s)
int rand_in_range(int min, int max) int rand_in_range(int min, int max)
{ {
#if defined(__SELFTEST__)
unsigned int seed; unsigned int seed;
ZeroTier::Utils::getSecureRandom((void*)&seed,sizeof(seed)); ZeroTier::Utils::getSecureRandom((void*)&seed,sizeof(seed));
srand(seed); srand(seed);
#else
srand((unsigned int)time(NULL));
#endif
return min + rand() % static_cast<int>(max - min + 1); return min + rand() % static_cast<int>(max - min + 1);
} }
@@ -2116,7 +2123,7 @@ void* worker_create_socket(void *arg)
// test the core locking logic by creating large numbers of threads and performing random operations over an extended period of time // test the core locking logic by creating large numbers of threads and performing random operations over an extended period of time
void multithread_test(int num_iterations, bool *passed) void multithread_test(int num_iterations, bool *passed)
{ {
int err = 0, i = 0; int err = 0;
fprintf(stderr, "\n\nmultithread_socket_creation\n\n"); fprintf(stderr, "\n\nmultithread_socket_creation\n\n");
// test zts_socket() and zts_close() // test zts_socket() and zts_close()
for (int j=0; j<num_iterations; j++) { for (int j=0; j<num_iterations; j++) {