diff --git a/Makefile b/Makefile index 486ec17..35d8a85 100644 --- a/Makefile +++ b/Makefile @@ -304,9 +304,11 @@ shared_jni_lib: picotcp $(ZTO_OBJS) tests: selftest nativetest ztproxy # intercept +ZT_UTILS:=zto/node/Utils.cpp -Izto/node + selftest: $(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 @./check.sh $(BUILD)/selftest nativetest: diff --git a/make-liblwip.mk b/make-liblwip.mk index 3ee8f08..e79ae4d 100644 --- a/make-liblwip.mk +++ b/make-liblwip.mk @@ -120,7 +120,7 @@ LWIPFILESW=$(wildcard $(LWIPFILES)) LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o)) %.o: - $(CXX) $(CFLAGS) -c $(<:.o=.c) -o obj/$@ + $(CXX) $(CFLAGS) -Wno-deprecated -c $(<:.o=.c) -o obj/$@ all: .PHONY: all @@ -136,4 +136,4 @@ liblwip.a: clean $(LWIPOBJS) #libtool -static -o $@ $^ .depend: $(LWIPFILES) - $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend \ No newline at end of file + $(CCDEP) $(CFLAGS) -x c -MM $^ > .depend || rm -f .depend \ No newline at end of file diff --git a/test/selftest.cpp b/test/selftest.cpp index 2e95dc3..f97fcfe 100644 --- a/test/selftest.cpp +++ b/test/selftest.cpp @@ -49,7 +49,10 @@ #include #include "libzt.h" + +#if defined(__SELFTEST__) #include "Utils.hpp" +#endif #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) { +#if defined(__SELFTEST__) unsigned int seed; ZeroTier::Utils::getSecureRandom((void*)&seed,sizeof(seed)); srand(seed); +#else + srand((unsigned int)time(NULL)); +#endif return min + rand() % static_cast(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 void multithread_test(int num_iterations, bool *passed) { - int err = 0, i = 0; + int err = 0; fprintf(stderr, "\n\nmultithread_socket_creation\n\n"); // test zts_socket() and zts_close() for (int j=0; j