diff --git a/CMakeLists.txt b/CMakeLists.txt index 7193fe73..7adf86d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,9 @@ ExternalProject_Add(cJSON GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git GIT_TAG "aafb64a1c549b7b927e339df6d35b1d5059dc235" CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + CMAKE_ARGS += -DCMAKE_MACOSX_RPATH=true +endif() ) add_library(libcJSON STATIC SHARED IMPORTED) add_dependencies(libcJSON cJSON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 713dce9e..a2f5ad44 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,6 @@ target_link_libraries (parodus -lmsgpackc -ltrower-base64 -lnopoll - -luuid -lm -lcimplog -lssl @@ -40,9 +39,13 @@ target_link_libraries (parodus -lcjson -lcjwt -lpthread - -lrt ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (parodus -luuid) +target_link_libraries (parodus rt) +endif() + if (FEATURE_DNS_QUERY) target_link_libraries (parodus -lucresolv -lresolv) endif (FEATURE_DNS_QUERY) diff --git a/src/ParodusInternal.h b/src/ParodusInternal.h index b1b2ce2c..a4dc66ca 100644 --- a/src/ParodusInternal.h +++ b/src/ParodusInternal.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -99,7 +98,7 @@ char* getWebpaConveyHeader(); #ifdef __cplusplus } #endif - + #endif diff --git a/src/connection.c b/src/connection.c index e1d4c520..300e196b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -47,6 +47,7 @@ static noPollConnOpts * createConnOpts (char * extra_headers, bool secure); static noPollConn * nopoll_tls_common_conn (noPollCtx * ctx,char * serverAddr,char *serverPort,char * extra_headers,unsigned int *fallback); static char* build_extra_headers( const char *auth, const char *device_id, const char *user_agent, const char *convey ); +static noPollSslProtocol get_nopoll_tls_protocol(void); static void toggleIPFlag (unsigned int *ptrFallback); static noPollConn * __internal_fallbackConn(noPollCtx * ctx,noPollConnOpts * opts,char * serverAddr,char *serverPort,char * extra_headers,unsigned int *fallback); @@ -501,8 +502,10 @@ static noPollConn * __internal_fallbackConn(noPollCtx * ctx,noPollConnOpts * op static noPollConnOpts * createConnOpts (char * extra_headers, bool secure) { noPollConnOpts * opts; + noPollSslProtocol protocol = NOPOLL_METHOD_TLSV1_2; opts = nopoll_conn_opts_new (); + protocol = get_nopoll_tls_protocol(); if(secure) { if(strlen(get_parodus_cfg()->cert_path) > 0) @@ -510,7 +513,7 @@ static noPollConnOpts * createConnOpts (char * extra_headers, bool secure) nopoll_conn_opts_set_ssl_certs(opts, NULL, NULL, NULL, get_parodus_cfg()->cert_path); } nopoll_conn_opts_ssl_peer_verify (opts, nopoll_true); - nopoll_conn_opts_set_ssl_protocol (opts, NOPOLL_METHOD_TLSV1_2); + nopoll_conn_opts_set_ssl_protocol (opts, protocol); } nopoll_conn_opts_set_interface (opts,get_parodus_cfg()->webpa_interface_used); nopoll_conn_opts_set_extra_headers (opts,extra_headers); @@ -528,3 +531,16 @@ void close_and_unref_connection(noPollConn *conn) } } +static noPollSslProtocol get_nopoll_tls_protocol( void ) +{ + noPollSslProtocol _protocol; +#if defined(NOPOLL_HAVE_TLSv12_ENABLED) + _protocol = NOPOLL_METHOD_TLSV1_2; +#elif defined(NOPOLL_HAVE_TLSv11_ENABLED) + _protocol = NOPOLL_METHOD_TLSV1_1; +#elif defined(NOPOLL_HAVE_TLSv10_ENABLED) + _protocol = NOPOLL_METHOD_TLSV1; +#endif + return _protocol; +} + diff --git a/src/string_helpers.c b/src/string_helpers.c index 8502866e..1b3e1826 100644 --- a/src/string_helpers.c +++ b/src/string_helpers.c @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "string.h" +#include /*----------------------------------------------------------------------------*/ /* Macros */ diff --git a/src/time.h b/src/time.h index 4314a6ff..c64d5d48 100644 --- a/src/time.h +++ b/src/time.h @@ -18,8 +18,8 @@ #include #include -#ifndef _TIME_H_ -#define _TIME_H_ +#ifndef __TIME_H__ +#define __TIME_H__ #ifdef __cplusplus extern "C" { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1cf012a6..fa9c6eb4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,17 +14,16 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -g -fprofile-arcs -ftest-coverage -O0") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST ") +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600 -Du_char='unsigned char' -Du_int='unsigned int' -Du_long='unsigned long'") +endif() set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -g -fprofile-arcs -ftest-coverage -O0") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -O0") set (PARODUS_COMMON_SRC ../src/string_helpers.c ../src/mutex.c ../src/time.c ../src/config.c ../src/spin_thread.c ../src/token.c) -set (PARODUS_COMMON_LIBS gcov -lcunit -lcimplog -lwrp-c - -luuid -lpthread -lmsgpackc -lnopoll -lnanomsg - -Wl,--no-as-needed -lcjson -lcjwt -ltrower-base64 - -lssl -lcrypto -lrt -lm) - -if (ENABLE_SESHAT) -set (PARODUS_COMMON_LIBS -llibseshat ${PARODUS_COMMON_LIBS}) -endif (ENABLE_SESHAT) +set (PARODUS_COMMON_LIBS -lcunit -lcimplog -lwrp-c + -lmsgpackc -lnopoll -lnanomsg -lcjwt -lssl -lpthread + -lcjson -ltrower-base64 -lm) +set (PARODUS_LINUX_ONLY_LIBS gcov -luuid -lrt -Wl,--no-as-needed) if (FEATURE_DNS_QUERY) set (PARODUS_COMMON_LIBS ${PARODUS_COMMON_LIBS} -lucresolv -lresolv) @@ -39,9 +38,16 @@ link_directories ( ${LIBRARY_DIR} ) #------------------------------------------------------------------------------- # test_mutex #------------------------------------------------------------------------------- +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +add_test(NAME test_mutex COMMAND ./test_mutex) +else() add_test(NAME test_mutex COMMAND ${MEMORY_CHECK} ./test_mutex) +endif() add_executable(test_mutex test_mutex.c ../src/mutex.c) target_link_libraries (test_mutex ${PARODUS_COMMON_LIBS} -lcmocka) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_mutex ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_networking @@ -49,13 +55,19 @@ target_link_libraries (test_mutex ${PARODUS_COMMON_LIBS} -lcmocka) add_test(NAME test_networking COMMAND ${MEMORY_CHECK} ./test_networking) add_executable(test_networking test_networking.c ../src/networking.c) target_link_libraries (test_networking ${PARODUS_COMMON_LIBS}) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_networking ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_nopoll_helpers #------------------------------------------------------------------------------- add_test(NAME test_nopoll_helpers COMMAND ${MEMORY_CHECK} ./test_nopoll_helpers) add_executable(test_nopoll_helpers test_nopoll_helpers.c ../src/nopoll_helpers.c) -target_link_libraries (test_nopoll_helpers -Wl,--no-as-needed -lrt -lcmocka -lcimplog -lnopoll) +target_link_libraries (test_nopoll_helpers -lcmocka -lcimplog -lnopoll) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_nopoll_helpers rt -Wl,--no-as-needed) +endif() #------------------------------------------------------------------------------- # libpd_test @@ -66,23 +78,27 @@ target_link_libraries (libpd_test cunit -llibparodus -lwrp-c - -luuid -lmsgpackc -ltrower-base64 -lnanomsg -lcimplog -lm - -lpthread - -lrt) + -lpthread) if (ENABLE_SESHAT) target_link_libraries (libpd_test -llibseshat) endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (libpd_test ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_time #------------------------------------------------------------------------------- add_test(NAME test_time COMMAND ${MEMORY_CHECK} ./test_time) add_executable(test_time test_time.c ../src/time.c) target_link_libraries (test_time ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_time ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_spin_thread error @@ -90,6 +106,9 @@ target_link_libraries (test_time ${PARODUS_COMMON_LIBS} ) add_test(NAME test_spin_thread_e COMMAND ${MEMORY_CHECK} ./test_spin_thread_e) add_executable(test_spin_thread_e test_spin_thread_e.c ../src/spin_thread.c) target_link_libraries (test_spin_thread_e ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_spin_thread_e ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_spin_thread success @@ -97,6 +116,9 @@ target_link_libraries (test_spin_thread_e ${PARODUS_COMMON_LIBS} ) add_test(NAME test_spin_thread_s COMMAND ${MEMORY_CHECK} ./test_spin_thread_s) add_executable(test_spin_thread_s test_spin_thread_s.c ../src/spin_thread.c) target_link_libraries (test_spin_thread_s ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_spin_thread_s ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_string_helpers @@ -104,41 +126,53 @@ target_link_libraries (test_spin_thread_s ${PARODUS_COMMON_LIBS} ) add_test(NAME test_string_helpers COMMAND ${MEMORY_CHECK} ./test_string_helpers) add_executable(test_string_helpers test_string_helpers.c ../src/string_helpers.c) target_link_libraries (test_string_helpers ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_string_helpers ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_nopoll_handlers #------------------------------------------------------------------------------- +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +add_test(NAME test_nopoll_handlers COMMAND ./test_nopoll_handlers) +else() add_test(NAME test_nopoll_handlers COMMAND ${MEMORY_CHECK} ./test_nopoll_handlers) +endif() add_executable(test_nopoll_handlers test_nopoll_handlers.c ../src/nopoll_handlers.c) -target_link_libraries (test_nopoll_handlers -lnopoll -lcunit -lcimplog -Wl,--no-as-needed -lrt -lpthread -lm) +target_link_libraries (test_nopoll_handlers -lnopoll -lcunit -lcimplog -lpthread -lm) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_nopoll_handlers -lrt -Wl,--no-as-needed) +endif() #------------------------------------------------------------------------------- # test_connection #------------------------------------------------------------------------------- add_test(NAME test_connection COMMAND ${MEMORY_CHECK} ./test_connection) -#add_executable(test_connection test_connection.c ../src/connection.c ${PARODUS_COMMON_SRC}) -#target_link_libraries (test_connection ${PARODUS_COMMON_LIBS} -lcmocka) set(SOURCES test_connection.c ../src/connection.c ${PARODUS_COMMON_SRC}) add_executable(test_connection ${SOURCES}) -#target_link_libraries (test_connection ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS} -lcmocka) target_link_libraries (test_connection ${PARODUS_COMMON_LIBS} -lcmocka) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_connection ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_connection - function createNopollConnection #------------------------------------------------------------------------------- add_test(NAME test_createConnection COMMAND ${MEMORY_CHECK} ./test_createConnection) -#add_executable(test_createConnection test_createConnection.c ../src/connection.c ../src/string_helpers.c ../src/config.c) -#target_link_libraries (test_createConnection ${PARODUS_COMMON_LIBS} -lcmocka) add_executable(test_createConnection test_createConnection.c ../src/connection.c ../src/string_helpers.c ../src/config.c) -#target_link_libraries (test_createConnection ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS} -lcmocka ) target_link_libraries (test_createConnection ${PARODUS_COMMON_LIBS} -lcmocka ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_createConnection ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_client_list #------------------------------------------------------------------------------- +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +add_test(NAME test_client_list COMMAND ./test_client_list) +else() add_test(NAME test_client_list COMMAND ${MEMORY_CHECK} ./test_client_list) -#add_executable(test_client_list test_client_list.c ../src/client_list.c ../src/service_alive.c ../src/upstream.c ../src/networking.c ../src/nopoll_helpers.c ../src/downstream.c ../src/connection.c ../src/nopoll_handlers.c ../src/ParodusInternal.c ../src/thread_tasks.c ../src/conn_interface.c ../src/partners_check.c ${PARODUS_COMMON_SRC}) -#target_link_libraries (test_client_list ${PARODUS_COMMON_LIBS}) +endif() set(SOURCES test_client_list.c ../src/client_list.c ../src/service_alive.c ../src/upstream.c ../src/networking.c ../src/nopoll_helpers.c ../src/downstream.c ../src/connection.c ../src/nopoll_handlers.c @@ -152,24 +186,36 @@ set(SOURCES ${SOURCES} ../src/seshat_interface_stub.c) endif (ENABLE_SESHAT) add_executable(test_client_list ${SOURCES}) -#target_link_libraries (test_client_list ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS}) +if (ENABLE_SESHAT) +target_link_libraries (test_client_list -llibseshat) +endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_client_list ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_client_list ${PARODUS_COMMON_LIBS}) #------------------------------------------------------------------------------- # test_service_alive #------------------------------------------------------------------------------- +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +add_test(NAME test_service_alive COMMAND ./test_service_alive) +else() add_test(NAME test_service_alive COMMAND ${MEMORY_CHECK} ./test_service_alive) -#add_executable(test_service_alive test_service_alive.c ../src/client_list.c ../src/service_alive.c ../src/upstream.c ../src/networking.c ../src/nopoll_helpers.c ../src/nopoll_handlers.c ../src/config.c ../src/connection.c ../src/ParodusInternal.c ../src/downstream.c ../src/thread_tasks.c ../src/conn_interface.c ../src/partners_check.c ${PARODUS_COMMON_SRC}) -#target_link_libraries (test_service_alive ${PARODUS_COMMON_LIBS}) +endif() set(SOURCES test_service_alive.c ../src/client_list.c ../src/service_alive.c ../src/upstream.c ../src/networking.c ../src/nopoll_helpers.c ../src/nopoll_handlers.c ../src/config.c ../src/connection.c ../src/ParodusInternal.c ../src/downstream.c ../src/thread_tasks.c ../src/conn_interface.c ../src/partners_check.c ${PARODUS_COMMON_SRC}) if (ENABLE_SESHAT) set(SOURCES ${SOURCES} ../src/seshat_interface.c) -else() +else(ENABLE_SESHAT) set(SOURCES ${SOURCES} ../src/seshat_interface_stub.c) endif (ENABLE_SESHAT) add_executable(test_service_alive ${SOURCES}) -#target_link_libraries (test_service_alive ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS}) +if (ENABLE_SESHAT) +target_link_libraries (test_service_alive -llibseshat) +endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_service_alive ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_service_alive ${PARODUS_COMMON_LIBS}) #------------------------------------------------------------------------------- @@ -177,10 +223,10 @@ target_link_libraries (test_service_alive ${PARODUS_COMMON_LIBS}) #------------------------------------------------------------------------------- add_test(NAME test_config COMMAND ${MEMORY_CHECK} ./test_config) add_executable(test_config test_config.c ../src/config.c ../src/string_helpers.c) -target_link_libraries (test_config -lcmocka - -Wl,--no-as-needed -lcimplog - -lcjson -lcjwt -ltrower-base64 -lssl -lcrypto -lrt -lm -) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_config ${PARODUS_LINUX_ONLY_LIBS}) +endif() +target_link_libraries (test_config -lcmocka ${PARODUS_COMMON_LIBS}) #------------------------------------------------------------------------------- # test_upstream @@ -188,6 +234,9 @@ target_link_libraries (test_config -lcmocka add_test(NAME test_upstream COMMAND ${MEMORY_CHECK} ./test_upstream) add_executable(test_upstream test_upstream.c ../src/upstream.c ../src/string_helpers.c) target_link_libraries (test_upstream -lcmocka ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_upstream ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_downstream @@ -195,6 +244,9 @@ target_link_libraries (test_upstream -lcmocka ${PARODUS_COMMON_LIBS} ) add_test(NAME test_downstream COMMAND ${MEMORY_CHECK} ./test_downstream) add_executable(test_downstream test_downstream.c ../src/downstream.c ../src/string_helpers.c) target_link_libraries (test_downstream -lcmocka ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_downstream ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_downstream_more @@ -202,6 +254,9 @@ target_link_libraries (test_downstream -lcmocka ${PARODUS_COMMON_LIBS} ) add_test(NAME test_downstream_more COMMAND ${MEMORY_CHECK} ./test_downstream_more) add_executable(test_downstream_more test_downstream_more.c ../src/downstream.c ../src/string_helpers.c) target_link_libraries (test_downstream_more -lcmocka ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_downstream_more ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_thread_tasks @@ -209,6 +264,9 @@ target_link_libraries (test_downstream_more -lcmocka ${PARODUS_COMMON_LIBS} ) add_test(NAME test_thread_tasks COMMAND ${MEMORY_CHECK} ./test_thread_tasks) add_executable(test_thread_tasks test_thread_tasks.c ../src/thread_tasks.c) target_link_libraries (test_thread_tasks -lcmocka ${PARODUS_COMMON_LIBS} ) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_thread_tasks ${PARODUS_LINUX_ONLY_LIBS}) +endif() #------------------------------------------------------------------------------- # test_conn_interface @@ -217,10 +275,16 @@ add_test(NAME test_conn_interface COMMAND ${MEMORY_CHECK} ./test_conn_interface) set(SOURCES test_conn_interface.c ../src/conn_interface.c ../src/config.c ../src/string_helpers.c ../src/mutex.c) if (ENABLE_SESHAT) set(SOURCES ${SOURCES} ../src/seshat_interface.c) -else() +else(ENABLE_SESHAT) set(SOURCES ${SOURCES} ../src/seshat_interface_stub.c) endif (ENABLE_SESHAT) add_executable(test_conn_interface ${SOURCES}) +if (ENABLE_SESHAT) +target_link_libraries (test_conn_interface -llibseshat) +endif(ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_conn_interface ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_conn_interface -lcmocka ${PARODUS_COMMON_LIBS} ) #------------------------------------------------------------------------------- @@ -228,6 +292,9 @@ target_link_libraries (test_conn_interface -lcmocka ${PARODUS_COMMON_LIBS} ) #------------------------------------------------------------------------------- add_test(NAME test_ParodusInternal COMMAND ${MEMORY_CHECK} ./test_ParodusInternal) add_executable(test_ParodusInternal test_ParodusInternal.c ../src/ParodusInternal.c ../src/config.c ../src/string_helpers.c) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_ParodusInternal ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_ParodusInternal -lcmocka ${PARODUS_COMMON_LIBS} ) #------------------------------------------------------------------------------- @@ -235,6 +302,9 @@ target_link_libraries (test_ParodusInternal -lcmocka ${PARODUS_COMMON_LIBS} ) #------------------------------------------------------------------------------- add_test(NAME test_partners_check COMMAND ${MEMORY_CHECK} ./test_partners_check) add_executable(test_partners_check test_partners_check.c ../src/partners_check.c ../src/string_helpers.c) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_partners_check ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_partners_check -lcmocka ${PARODUS_COMMON_LIBS} -lwrp-c) #------------------------------------------------------------------------------- @@ -242,7 +312,12 @@ target_link_libraries (test_partners_check -lcmocka ${PARODUS_COMMON_LIBS} -lwrp #------------------------------------------------------------------------------- add_test(NAME test_token COMMAND ${MEMORY_CHECK} ./test_token) add_executable(test_token ${SOURCES} ) -#target_link_libraries (test_token ${PARODUS_COMMON_LIBS} ${PARODUS_JWT_LIBS} -lcmocka ) +if (ENABLE_SESHAT) +target_link_libraries (test_token -llibseshat ) +endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_token ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_token ${PARODUS_COMMON_LIBS} -lcmocka ) #------------------------------------------------------------------------------- @@ -255,6 +330,12 @@ else() set(SOURCES test_seshat_interface_stub.c ../src/seshat_interface_stub.c) endif (ENABLE_SESHAT) add_executable(test_seshat_interface ${SOURCES}) +if (ENABLE_SESHAT) +target_link_libraries (test_seshat_interface -llibseshat) +endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (test_seshat_interface ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (test_seshat_interface -lcmocka ${PARODUS_COMMON_LIBS} -lwrp-c) if (INTEGRATION_TESTING) @@ -270,6 +351,12 @@ else() set(SOURCES ${SOURCES} ../src/seshat_interface_stub.c) endif (ENABLE_SESHAT) add_executable(simple_connection ${SOURCES}) +if (ENABLE_SESHAT) +target_link_libraries (simple_connection -llibseshat) +endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (simple_connection ${PARODUS_LINUX_ONLY_LIBS}) +endif() target_link_libraries (simple_connection ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS} ) #------------------------------------------------------------------------------- @@ -285,5 +372,11 @@ set(SOURCES ${SOURCES} ../src/seshat_interface_stub.c) endif (ENABLE_SESHAT) add_executable(simple ${SOURCES}) -target_link_libraries (simple ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS} gcov -lnopoll -lnanomsg ) +if (ENABLE_SESHAT) +target_link_libraries (simple -llibseshat) +endif (ENABLE_SESHAT) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +target_link_libraries (simple ${PARODUS_LINUX_ONLY_LIBS}) +endif() +target_link_libraries (simple ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS} -lnopoll -lnanomsg ) endif (INTEGRATION_TESTING) diff --git a/tests/libpd_test.c b/tests/libpd_test.c index bc5d552d..71119dc4 100644 --- a/tests/libpd_test.c +++ b/tests/libpd_test.c @@ -251,12 +251,18 @@ void dbg_log_err (const char *fmt, ...) va_start(arg_ptr, fmt); vprintf(fmt, arg_ptr); va_end(arg_ptr); - - if( 0 == strerror_r (errno, errbuf, 100) ) { +#if _XOPEN_SOURCE >= 600 + if( 0 == strerror_r (errno, errbuf, 100) ) + { printf("LIBPD_TEST: %s\n", errbuf); - } else { - printf("LIBPD_TEST: strerror_r returned failure!\n"); } + else + { + printf("LIBPD_TEST: strerror_r returned failure!\n"); + } +#elif !_XOPEN_SOURCE + printf ("LIBPD_TEST: %s\n", strerror_r (errno, errbuf, 100)); +#endif } void wait_auth_received (void) diff --git a/tests/test_config.c b/tests/test_config.c index 14bc930f..e7087b3d 100644 --- a/tests/test_config.c +++ b/tests/test_config.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -507,7 +507,9 @@ int main(void) cmocka_unit_test(test_parseCommandLine), cmocka_unit_test(test_parseCommandLineNull), cmocka_unit_test(err_parseCommandLine), +#ifndef __MACH__ cmocka_unit_test(test_parodusGitVersion), +#endif //__MACH__ cmocka_unit_test(test_setDefaultValuesToCfg), cmocka_unit_test(err_setDefaultValuesToCfg), }; diff --git a/tests/test_downstream.c b/tests/test_downstream.c index 73a391a6..9d7b516e 100755 --- a/tests/test_downstream.c +++ b/tests/test_downstream.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/test_downstream_more.c b/tests/test_downstream_more.c index 207a0277..b4401a33 100644 --- a/tests/test_downstream_more.c +++ b/tests/test_downstream_more.c @@ -171,7 +171,7 @@ static test_t tests[] = { .s.u.event.payload = NULL, .s.u.event.payload_size = 0, - .r = {0}, + .r.u = {{0}}, }, }; diff --git a/tests/test_partners_check.c b/tests/test_partners_check.c index a3ad9734..62481e65 100755 --- a/tests/test_partners_check.c +++ b/tests/test_partners_check.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/test_service_alive.c b/tests/test_service_alive.c index 559b41ac..c66866ac 100644 --- a/tests/test_service_alive.c +++ b/tests/test_service_alive.c @@ -162,7 +162,7 @@ void test_keep_alive() if(byte >0) { ParodusInfo("Received keep alive msg!!! : %s \n", (char * )buf); - pthread_kill(threadId, SIGUSR1); + pthread_kill(threadId, SIGUSR1); ParodusInfo("keep_alive_thread with tid %p is stopped\n", threadId); break; diff --git a/tests/test_string_helpers.c b/tests/test_string_helpers.c index 036d3c3f..701a43e7 100644 --- a/tests/test_string_helpers.c +++ b/tests/test_string_helpers.c @@ -14,9 +14,6 @@ * limitations under the License. */ #include -#include -#include -#include #include @@ -24,15 +21,6 @@ #define STRING_LENGTH 21 -/*----------------------------------------------------------------------------*/ -/* Mocks */ -/*----------------------------------------------------------------------------*/ -char *strncpy(char *destStr, const char *srcStr, size_t destSize) -{ - (void) destStr; (void) srcStr; (void) destSize; - return NULL; -} - /*----------------------------------------------------------------------------*/ /* Tests */ /*----------------------------------------------------------------------------*/ diff --git a/tests/test_thread_tasks.c b/tests/test_thread_tasks.c index 9375ec09..d3d8cbaf 100755 --- a/tests/test_thread_tasks.c +++ b/tests/test_thread_tasks.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/test_time.c b/tests/test_time.c index 841e653d..fff3acc8 100644 --- a/tests/test_time.c +++ b/tests/test_time.c @@ -28,7 +28,7 @@ /*----------------------------------------------------------------------------*/ #define MOCK_RETURN_SEC 1 -int clock_gettime(int ID, struct timespec *timer) +int clock_gettime(clockid_t ID, struct timespec *timer) { (void) ID; timer->tv_sec = MOCK_RETURN_SEC; diff --git a/tests/test_upstream.c b/tests/test_upstream.c index 35b23648..3d9f5097 100644 --- a/tests/test_upstream.c +++ b/tests/test_upstream.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -589,12 +589,16 @@ int main(void) cmocka_unit_test(err_handleUpstreamSockFailure), cmocka_unit_test(test_processUpstreamMessage), cmocka_unit_test(test_processUpstreamMessageInvalidPartner), +#ifndef __MACH__ cmocka_unit_test(test_processUpstreamMessageRegMsg), +#endif cmocka_unit_test(test_processUpstreamMessageRegMsgNoClients), cmocka_unit_test(err_processUpstreamMessage), cmocka_unit_test(err_processUpstreamMessageDecodeErr), cmocka_unit_test(err_processUpstreamMessageMetapackFailure), +#ifndef __MACH__ cmocka_unit_test(err_processUpstreamMessageRegMsg), +#endif cmocka_unit_test(test_sendUpstreamMsgToServer), cmocka_unit_test(err_sendUpstreamMsgToServer), };