Update tests and corresponding makefiles (#1862)

This commit is contained in:
R4SAS 2023-01-30 01:17:49 +00:00 committed by GitHub
parent 86dbfdb536
commit 3cee8bfcb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 89 additions and 83 deletions

View File

@ -118,9 +118,9 @@ obj/%.o: %.cpp | mk_obj_dir
$(I2PD): $(DAEMON_OBJS) $(ARLIB) $(ARLIB_CLIENT) $(ARLIB_LANG) $(I2PD): $(DAEMON_OBJS) $(ARLIB) $(ARLIB_CLIENT) $(ARLIB_LANG)
$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) $(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)
$(SHLIB): $(LIB_OBJS) $(SHLIB_LANG) $(SHLIB): $(LIB_OBJS)
ifneq ($(USE_STATIC),yes) ifneq ($(USE_STATIC),yes)
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) $(SHLIB_LANG) $(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
endif endif
$(SHLIB_CLIENT): $(LIB_CLIENT_OBJS) $(SHLIB) $(SHLIB_LANG) $(SHLIB_CLIENT): $(LIB_CLIENT_OBJS) $(SHLIB) $(SHLIB_LANG)

View File

@ -23,7 +23,7 @@ else ifeq ($(shell expr match ${CXXVER} "[5-6]"),1) # gcc 5 - 6
else ifeq ($(shell expr match ${CXXVER} "[7-9]"),1) # gcc 7 - 9 else ifeq ($(shell expr match ${CXXVER} "[7-9]"),1) # gcc 7 - 9
NEEDED_CXXFLAGS += -std=c++17 NEEDED_CXXFLAGS += -std=c++17
LDLIBS = -latomic LDLIBS = -latomic
else ifeq ($(shell expr match ${CXXVER} "1[0-9]"),2) # gcc 10 - 19 else ifeq ($(shell expr match ${CXXVER} "1[0-9]"),2) # gcc 10+
# NEEDED_CXXFLAGS += -std=c++20 # NEEDED_CXXFLAGS += -std=c++20
NEEDED_CXXFLAGS += -std=c++17 NEEDED_CXXFLAGS += -std=c++17
LDLIBS = -latomic LDLIBS = -latomic

3
build/.gitignore vendored
View File

@ -1,5 +1,7 @@
# Various generated files # Various generated files
/CMakeFiles/ /CMakeFiles/
/Testing/
/tests/
/i2pd /i2pd
/libi2pd.a /libi2pd.a
/libi2pdclient.a /libi2pdclient.a
@ -8,6 +10,7 @@
/CMakeCache.txt /CMakeCache.txt
/CPackConfig.cmake /CPackConfig.cmake
/CPackSourceConfig.cmake /CPackSourceConfig.cmake
/CTestTestfile.cmake
/install_manifest.txt /install_manifest.txt
/arch.c /arch.c
# windows build script # windows build script

12
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
/test-http-merge_chunked
/test-http-req
/test-http-res
/test-http-url
/test-http-url_decode
/test-gost
/test-gost-sig
/test-base-64
/test-x25519
/test-aeadchacha20poly1305
/test-blinding
/test-elligator

View File

@ -4,9 +4,9 @@ include_directories(${CHECK_INCLUDE_DIRS})
# Compiler flags: # Compiler flags:
if(APPLE) if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter -Wextra -pedantic -O0 -g -Wl,-undefined,dynamic_lookup") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -Wl,-undefined,dynamic_lookup")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter -Wextra -pedantic -O0 -g -D_GLIBCXX_USE_NANOSLEEP=1 -Wl,--unresolved-symbols=ignore-in-object-files") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -Wl,--unresolved-symbols=ignore-in-object-files")
endif() endif()
set(TEST_PATH ${CMAKE_CURRENT_BINARY_DIR}) set(TEST_PATH ${CMAKE_CURRENT_BINARY_DIR})
@ -18,80 +18,50 @@ include_directories(
) )
set(test-http-merge_chunked_SRCS set(test-http-merge_chunked_SRCS
../libi2pd/HTTP.cpp
test-http-merge_chunked.cpp test-http-merge_chunked.cpp
) )
set(test-http-req_SRCS set(test-http-req_SRCS
../libi2pd/HTTP.cpp
test-http-req.cpp test-http-req.cpp
) )
set(test-http-res_SRCS set(test-http-res_SRCS
../libi2pd/HTTP.cpp
test-http-res.cpp test-http-res.cpp
) )
set(test-http-url_decode_SRCS set(test-http-url_decode_SRCS
../libi2pd/HTTP.cpp
test-http-url_decode.cpp test-http-url_decode.cpp
) )
set(test-http-url_SRCS set(test-http-url_SRCS
../libi2pd/HTTP.cpp
test-http-url.cpp test-http-url.cpp
) )
set(test-base-64_SRCS set(test-base-64_SRCS
../libi2pd/Base.cpp
test-base-64.cpp test-base-64.cpp
) )
set(test-gost_SRCS set(test-gost_SRCS
../libi2pd/Gost.cpp
../libi2pd/I2PEndian.cpp
test-gost.cpp test-gost.cpp
) )
set(test-gost-sig_SRCS set(test-gost-sig_SRCS
../libi2pd/Gost.cpp
../libi2pd/I2PEndian.cpp
../libi2pd/Crypto.cpp
../libi2pd/Log.cpp
test-gost-sig.cpp test-gost-sig.cpp
) )
set(test-x25519_SRCS set(test-x25519_SRCS
../libi2pd/Ed25519.cpp
../libi2pd/I2PEndian.cpp
../libi2pd/Log.cpp
../libi2pd/Crypto.cpp
test-x25519.cpp test-x25519.cpp
) )
set(test-aeadchacha20poly1305_SRCS set(test-aeadchacha20poly1305_SRCS
../libi2pd/Crypto.cpp
../libi2pd/ChaCha20.cpp
../libi2pd/Poly1305.cpp
test-aeadchacha20poly1305.cpp test-aeadchacha20poly1305.cpp
) )
set(test-blinding_SRCS set(test-blinding_SRCS
../libi2pd/Crypto.cpp
../libi2pd/Blinding.cpp
../libi2pd/Ed25519.cpp
../libi2pd/I2PEndian.cpp
../libi2pd/Log.cpp
../libi2pd/util.cpp
../libi2pd/Identity.cpp
../libi2pd/Signature.cpp
../libi2pd/Timestamp.cpp
test-blinding.cpp test-blinding.cpp
) )
SET(test-elligator_SRCS SET(test-elligator_SRCS
../libi2pd/Elligator.cpp
../libi2pd/Crypto.cpp
test-elligator.cpp test-elligator.cpp
) )
@ -109,15 +79,23 @@ add_executable(test-blinding ${test-blinding_SRCS})
add_executable(test-elligator ${test-elligator_SRCS}) add_executable(test-elligator ${test-elligator_SRCS})
set(LIBS set(LIBS
libi2pd
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${CHECK_LDFLAGS}
${CMAKE_REQUIRED_LIBRARIES}
OpenSSL::SSL OpenSSL::SSL
OpenSSL::Crypto OpenSSL::Crypto
ZLIB::ZLIB
Threads::Threads Threads::Threads
${CHECK_LDFLAGS}
${CMAKE_REQUIRED_LIBRARIES}
) )
target_link_libraries(test-gost OpenSSL::Crypto Threads::Threads) target_link_libraries(test-http-merge_chunked ${LIBS})
target_link_libraries(test-http-req ${LIBS})
target_link_libraries(test-http-res ${LIBS})
target_link_libraries(test-http-url_decode ${LIBS})
target_link_libraries(test-http-url ${LIBS})
target_link_libraries(test-base-64 ${LIBS})
target_link_libraries(test-gost ${LIBS})
target_link_libraries(test-gost-sig ${LIBS}) target_link_libraries(test-gost-sig ${LIBS})
target_link_libraries(test-x25519 ${LIBS}) target_link_libraries(test-x25519 ${LIBS})
target_link_libraries(test-aeadchacha20poly1305 ${LIBS}) target_link_libraries(test-aeadchacha20poly1305 ${LIBS})

View File

@ -1,36 +1,50 @@
CXXFLAGS += -Wall -Wno-unused-parameter -Wextra -pedantic -O0 -g -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1 -pthread -Wl,--unresolved-symbols=ignore-in-object-files CXXFLAGS += -Wall -Wno-unused-parameter -Wextra -pedantic -O0 -g -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1 -DOPENSSL_SUPPRESS_DEPRECATED -pthread -Wl,--unresolved-symbols=ignore-in-object-files
INCFLAGS += -I../libi2pd INCFLAGS += -I../libi2pd
TESTS = test-gost test-gost-sig test-base-64 test-x25519 test-aeadchacha20poly1305 test-blinding test-elligator LIBI2PD = ../libi2pd.a
TESTS = \
test-http-merge_chunked test-http-req test-http-res test-http-url test-http-url_decode \
test-gost test-gost-sig test-base-64 test-x25519 test-aeadchacha20poly1305 test-blinding test-elligator
LDLIBS = \
-lcrypto \
-lssl \
-lboost_filesystem \
-lboost_program_options \
-lpthread
all: $(TESTS) run all: $(TESTS) run
test-http-%: ../libi2pd/HTTP.cpp test-http-%.cpp $(LIBI2PD):
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ @echo "Building libi2pd.a ..." && cd .. && $(MAKE) libi2pd.a
test-base-%: ../libi2pd/Base.cpp test-base-%.cpp test-http-%: test-http-%.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-gost: ../libi2pd/Gost.cpp ../libi2pd/I2PEndian.cpp test-gost.cpp test-base-%: test-base-%.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-gost-sig: ../libi2pd/Gost.cpp ../libi2pd/I2PEndian.cpp ../libi2pd/Crypto.cpp ../libi2pd/Log.cpp test-gost-sig.cpp test-gost: test-gost.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-x25519: ../libi2pd/Ed25519.cpp ../libi2pd/I2PEndian.cpp ../libi2pd/Log.cpp ../libi2pd/Crypto.cpp test-x25519.cpp test-gost-sig: test-gost-sig.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-aeadchacha20poly1305: ../libi2pd/Crypto.cpp ../libi2pd/ChaCha20.cpp ../libi2pd/Poly1305.cpp test-aeadchacha20poly1305.cpp test-x25519: test-x25519.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-blinding: ../libi2pd/Crypto.cpp ../libi2pd/Blinding.cpp ../libi2pd/Ed25519.cpp ../libi2pd/I2PEndian.cpp ../libi2pd/Log.cpp ../libi2pd/util.cpp ../libi2pd/Identity.cpp ../libi2pd/Signature.cpp ../libi2pd/Timestamp.cpp test-blinding.cpp test-aeadchacha20poly1305: test-aeadchacha20poly1305.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-elligator: ../libi2pd/Elligator.cpp ../libi2pd/Crypto.cpp test-elligator.cpp test-blinding: test-blinding.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
test-elligator: test-elligator.cpp $(LIBI2PD)
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ $(LDLIBS)
run: $(TESTS) run: $(TESTS)
@for TEST in $(TESTS); do ./$$TEST ; done @for TEST in $(TESTS); do echo Running $$TEST; ./$$TEST ; done
clean: clean:
rm -f $(TESTS) rm -f $(TESTS)

View File

@ -36,4 +36,3 @@ int main ()
assert(memcmp (buf, p, 32) == 0); assert(memcmp (buf, p, 32) == 0);
#endif #endif
} }