1project(lws-minimal-secure-streams-testsfail C) 2cmake_minimum_required(VERSION 2.8.12) 3find_package(libwebsockets CONFIG REQUIRED) 4list(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR}) 5include(CheckCSourceCompiles) 6include(LwsCheckRequirements) 7 8set(SAMP lws-minimal-secure-streams-testsfail) 9 10set(requirements 1) 11require_lws_config(LWS_ROLE_H1 1 requirements) 12require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) 13require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) 14require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) 15require_lws_config(LWS_WITH_SYS_STATE 1 requirements) 16 17if (requirements) 18 add_executable(${SAMP} minimal-secure-streams-testsfail.c) 19 20 find_program(VALGRIND "valgrind") 21 22 if (LWS_CTEST_INTERNET_AVAILABLE AND NOT WIN32) 23 if (VALGRIND) 24 add_test(NAME ss-tf COMMAND 25 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 26 $<TARGET_FILE:lws-minimal-secure-streams-testsfail>) 27 else() 28 add_test(NAME ss-tf COMMAND lws-minimal-secure-streams-testsfail) 29 endif() 30 31 set_tests_properties(ss-tf 32 PROPERTIES 33 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-testsfail 34 TIMEOUT 440) 35 36 if (HAS_LWS_WITH_SECURE_STREAMS_PROXY_API OR LWS_WITH_SECURE_STREAMS_PROXY_API) 37 38 # 39 # Define test dep to bring up and take down the test 40 # proxy 41 # 42 43 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 44 # uds abstract namespace for linux 45 set(CTEST_SOCKET_PATH "@ctest-ssptf-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}") 46 else() 47 # filesystem socket for others 48 set(CTEST_SOCKET_PATH "/tmp/ctest-ssptf-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}") 49 endif() 50 add_test(NAME st_sstfproxy COMMAND 51 ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 52 sstfproxy $<TARGET_FILE:lws-minimal-secure-streams-proxy> 53 -i ${CTEST_SOCKET_PATH} -d1039) 54 set_tests_properties(st_sstfproxy PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP sstfproxy TIMEOUT 800) 55 56 add_test(NAME ki_sstfproxy COMMAND 57 ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 58 sstfproxy $<TARGET_FILE:lws-minimal-secure-streams-proxy> 59 -i ${CTEST_SOCKET_PATH}) 60 set_tests_properties(ki_sstfproxy PROPERTIES FIXTURES_CLEANUP sstfproxy) 61 62 # 63 # the client part that will connect to the proxy 64 # 65 66 if (VALGRIND) 67 add_test(NAME sspc-minimaltf COMMAND 68 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 69 $<TARGET_FILE:lws-minimal-secure-streams-testsfail-client> -i +${CTEST_SOCKET_PATH} -d1039) 70 else() 71 add_test(NAME sspc-minimaltf COMMAND lws-minimal-secure-streams-testsfail-client -i +${CTEST_SOCKET_PATH} -d1039) 72 endif() 73 74 set_tests_properties(sspc-minimaltf PROPERTIES 75 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-testsfail 76 FIXTURES_REQUIRED "sstfproxy" 77 TIMEOUT 440) 78 79 endif() 80 81 endif() 82 83 if (websockets_shared) 84 target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS}) 85 add_dependencies(${SAMP} websockets_shared) 86 else() 87 target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS}) 88 endif() 89 90 CHECK_C_SOURCE_COMPILES("#include <libwebsockets.h>\nint main(void) {\ni#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)\n return 0;\n #else\n fail\n #endif\n return 0;\n}\n" HAS_LWS_WITH_SECURE_STREAMS_PROXY_API) 91 92 if (HAS_LWS_WITH_SECURE_STREAMS_PROXY_API OR LWS_WITH_SECURE_STREAMS_PROXY_API) 93 add_compile_options(-DLWS_SS_USE_SSPC) 94 95 add_executable(${SAMP}-client minimal-secure-streams-testsfail.c) 96 if (websockets_shared) 97 target_link_libraries(${SAMP}-client websockets_shared ${LIBWEBSOCKETS_DEP_LIBS}) 98 add_dependencies(${SAMP}-client websockets_shared) 99 else() 100 target_link_libraries(${SAMP}-client websockets ${LIBWEBSOCKETS_DEP_LIBS}) 101 endif() 102 endif() 103 104endif() 105