From b78acb9303f99d22f56cd71b3400056e77fa7279 Mon Sep 17 00:00:00 2001 From: Dmitriy Gerasimov <naeper@demlabs.net> Date: Wed, 5 Jun 2019 15:02:16 +0700 Subject: [PATCH] [*] Fixed unit tests --- .gitmodules | 12 ++++ .travis.yml | 2 +- CMakeLists.txt | 55 ++++++++++++++----- dap_client.h => include/dap_client.h | 0 .../dap_client_pool.h | 0 dap_client_pvt.h => include/dap_client_pvt.h | 0 libdap | 2 +- libdap-crypto | 1 + libdap-server | 2 +- libdap-server-core | 2 +- libdap-server-udp | 2 +- libdap-stream | 2 +- dap_client.c => src/dap_client.c | 4 -- dap_client_pool.c => src/dap_client_pool.c | 0 dap_client_pvt.c => src/dap_client_pvt.c | 0 test/CMakeLists.txt | 22 ++++---- test/main.c | 2 +- 17 files changed, 71 insertions(+), 37 deletions(-) rename dap_client.h => include/dap_client.h (100%) rename dap_client_pool.h => include/dap_client_pool.h (100%) rename dap_client_pvt.h => include/dap_client_pvt.h (100%) create mode 160000 libdap-crypto rename dap_client.c => src/dap_client.c (99%) rename dap_client_pool.c => src/dap_client_pool.c (100%) rename dap_client_pvt.c => src/dap_client_pvt.c (100%) diff --git a/.gitmodules b/.gitmodules index 8c451bb..20e4429 100755 --- a/.gitmodules +++ b/.gitmodules @@ -1,24 +1,36 @@ [submodule "libdap"] path = libdap url = https://github.com/kelvinblockchain/libdap + branch = master +[submodule "libdap-crypto"] + path = libdap-crypto + url = https://github.com/cellframe/libdap-crypto + branch = master [submodule "libdap-server-core"] path = libdap-server-core url = https://github.com/kelvinblockchain/libdap-server-core + branch = master [submodule "libdap-server"] path = libdap-server url = https://github.com/kelvinblockchain/libdap-server + branch = master [submodule "libdap-stream"] path = libdap-stream url = https://github.com/kelvinblockchain/libdap-stream + branch = master [submodule "libdap-stream-ch"] path = libdap-stream-ch url = https://github.com/kelvinblockchain/libdap-stream-ch + branch = master [submodule "test/libdap-test"] path = test/libdap-test url = https://github.com/kelvinblockchain/libdap-test + branch = master [submodule "libdap-stream-ch-chain"] path = libdap-stream-ch-chain url = https://github.com/kelvinblockchain//libdap-stream-ch-chain + branch = master [submodule "libdap-server-udp"] path = libdap-server-udp url = https://github.com/kelvinblockchain/libdap-server-udp + branch = master diff --git a/.travis.yml b/.travis.yml index 87cdc68..e7bbd5b 100755 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_install: script: - mkdir build - cd build - - cmake -DBUILD_LIB_DAP_CLIENT_TESTS=ON ../ + - cmake -DBUILD_DAP_CLIENT_TESTS=ON ../ - make - ctest --verbose diff --git a/CMakeLists.txt b/CMakeLists.txt index 7acd042..042edff 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,27 +1,52 @@ cmake_minimum_required(VERSION 3.0) -project (dap_client) -set(CMAKE_C_STANDARD 11) +project(dap_client) +add_definitions ("-D_GNU_SOURCE") if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON)) set(SUBMODULES_NO_BUILD ON) - add_subdirectory(libdap) - add_subdirectory(libdap-server-core) - add_subdirectory(libdap-server) - add_subdirectory(libdap-server-udp) - add_subdirectory(libdap-stream) - add_subdirectory(libdap-stream-ch) + if ( NOT ( TARGET dap_core ) ) + add_subdirectory(libdap) + endif() + + if ( NOT ( TARGET dap_crypto ) ) + add_subdirectory(libdap-crypto) + endif() + + if ( NOT ( TARGET dap_server_core ) ) + add_subdirectory(libdap-server-core) + endif() + + if ( NOT ( TARGET dap_server ) ) + add_subdirectory(libdap-server) + endif() + + if ( NOT ( TARGET dap_udp_server ) ) + add_subdirectory(libdap-server-udp) + endif() + + if ( NOT ( TARGET libdap-stream ) ) + add_subdirectory(libdap-stream) + endif() + + if ( NOT ( TARGET dap_stream_ch ) ) + add_subdirectory(libdap-stream-ch) + endif() + - enable_testing() - add_subdirectory(test) endif() +file(GLOB DAP_CLIENT_SOURCES src/*.c) +file(GLOB DAP_CLIENT_HEADERS include/*.h) -file(GLOB DAP_CLIENT_SRCS *.c) -file(GLOB DAP_CLIENT_HEADERS *.h) +add_library(${PROJECT_NAME} STATIC ${DAP_CLIENT_HEADERS} ${DAP_CLIENT_SOURCES}) -add_library(${PROJECT_NAME} STATIC ${DAP_CLIENT_SRCS} ${DAP_CLIENT_HEADERS}) +target_link_libraries(${PROJECT_NAME} dap_test dap_core dap_crypto dap_server dap_udp_server dap_http_server dap_http_client dap_stream dap_session dap_stream_ch pthread memcached ev) +target_include_directories(${PROJECT_NAME} PUBLIC include) +target_include_directories(${PROJECT_NAME} PRIVATE src) -target_link_libraries(${PROJECT_NAME} dap_crypto dap_core dap_http_server dap_session dap_stream dap_stream_ch curl) -target_include_directories(${PROJECT_NAME} INTERFACE .) +if (${BUILD_DAP_CLIENT_TESTS} MATCHES ON) + enable_testing() + add_subdirectory(test) +endif() diff --git a/dap_client.h b/include/dap_client.h similarity index 100% rename from dap_client.h rename to include/dap_client.h diff --git a/dap_client_pool.h b/include/dap_client_pool.h similarity index 100% rename from dap_client_pool.h rename to include/dap_client_pool.h diff --git a/dap_client_pvt.h b/include/dap_client_pvt.h similarity index 100% rename from dap_client_pvt.h rename to include/dap_client_pvt.h diff --git a/libdap b/libdap index d37b2aa..4ab41cd 160000 --- a/libdap +++ b/libdap @@ -1 +1 @@ -Subproject commit d37b2aa26d2a7cc068529db343a87fd728904d33 +Subproject commit 4ab41cdcaa8087323652cd5fef702876ccc25dab diff --git a/libdap-crypto b/libdap-crypto new file mode 160000 index 0000000..ff63d76 --- /dev/null +++ b/libdap-crypto @@ -0,0 +1 @@ +Subproject commit ff63d762657f9687173db825705b8bf4b958abee diff --git a/libdap-server b/libdap-server index 2520382..2cc113d 160000 --- a/libdap-server +++ b/libdap-server @@ -1 +1 @@ -Subproject commit 2520382b703cc4308a6bb017da3b2cc5b95083b9 +Subproject commit 2cc113d3ef8234037016ac21f33731998bba6552 diff --git a/libdap-server-core b/libdap-server-core index e5bb9b7..1008394 160000 --- a/libdap-server-core +++ b/libdap-server-core @@ -1 +1 @@ -Subproject commit e5bb9b75237cd702c5980b4070da9842d1f101e2 +Subproject commit 1008394f0ecdbc41d995a4cc5bbc4b51ad789eaf diff --git a/libdap-server-udp b/libdap-server-udp index 1668210..bbf1b9d 160000 --- a/libdap-server-udp +++ b/libdap-server-udp @@ -1 +1 @@ -Subproject commit 1668210c08275ec85f8278a80c66b50e7414d61c +Subproject commit bbf1b9db2c3af9a3a59f6debb90ddc8db55ae2eb diff --git a/libdap-stream b/libdap-stream index 550a546..7a53ab9 160000 --- a/libdap-stream +++ b/libdap-stream @@ -1 +1 @@ -Subproject commit 550a546222f8b07c0687c9feaea32d3f2c66e87c +Subproject commit 7a53ab997e1079000d0f7477d30e4d58cf4185f7 diff --git a/dap_client.c b/src/dap_client.c similarity index 99% rename from dap_client.c rename to src/dap_client.c index 32a47fb..391b95b 100644 --- a/dap_client.c +++ b/src/dap_client.c @@ -302,12 +302,8 @@ int dap_client_disconnect( dap_client_t *a_client ) // l_client_internal->stream_es = NULL; // } -<<<<<<< HEAD // l_client_internal->stream_es->signal_close = true; dap_events_kill_socket( l_client_internal->stream_es ); -======= - l_client_internal->stream_es->signal_close = true; ->>>>>>> bec1af426c69b6a96e831f61603c00135bbd9305 // if (l_client_internal->stream_socket ) { // close (l_client_internal->stream_socket); diff --git a/dap_client_pool.c b/src/dap_client_pool.c similarity index 100% rename from dap_client_pool.c rename to src/dap_client_pool.c diff --git a/dap_client_pvt.c b/src/dap_client_pvt.c similarity index 100% rename from dap_client_pvt.c rename to src/dap_client_pvt.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4ea6b6a..065db52 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,18 +1,18 @@ -if(TARGET libdap_client_test) - return() # The project has already been built. -endif() -project(libdap_client_test) +project(dap_client_test) + -add_subdirectory(libdap-test) +if ( NOT ( TARGET dap_test ) ) + add_subdirectory(libdap-test) +endif() -file(GLOB SOURCES *.c) -file(GLOB HEADERS *.h) +file(GLOB DAP_CLIENT_TEST_SOURCES *.c) +file(GLOB DAP_CLIENT_TEST_HEADERS *.h) -add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) +add_executable(${PROJECT_NAME} ${DAP_CLIENT_TEST_SOURCES} ${DAP_CLIENT_TEST_HEADERS}) -target_link_libraries(${PROJECT_NAME} dap_test dap_core) +target_link_libraries(${PROJECT_NAME} dap_test dap_core dap_crypto dap_server_core ev pthread) add_test( - NAME libdap_client_test - COMMAND libdap_client_test + NAME dap_client_test + COMMAND dap_client_test ) diff --git a/test/main.c b/test/main.c index d015aec..6527055 100755 --- a/test/main.c +++ b/test/main.c @@ -2,6 +2,6 @@ int main(void) { // switch off debug info from library - set_log_level(L_CRITICAL); + dap_log_level_set(L_CRITICAL); return 0; } -- GitLab