1project(lws-minimal-secure-streams-smd 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(requirements 1) 9require_lws_config(LWS_ROLE_H1 1 requirements) 10require_lws_config(LWS_WITH_CLIENT 1 requirements) 11require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements) 12require_lws_config(LWS_WITH_SYS_SMD 1 requirements) 13require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 requirements) 14require_lws_config(LWS_WITH_SYS_STATE 1 requirements) 15 16require_lws_config(LWS_WITH_SYS_FAULT_INJECTION 1 has_fault_injection) 17 18if (requirements) 19 add_executable(${PROJECT_NAME} minimal-secure-streams-smd.c) 20 21 find_program(VALGRIND "valgrind") 22 23 if (LWS_CTEST_INTERNET_AVAILABLE AND NOT WIN32) 24 25 if (VALGRIND) 26 add_test(NAME ss-smd COMMAND 27 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 28 $<TARGET_FILE:lws-minimal-secure-streams-smd>) 29 else() 30 31 add_test(NAME ss-smd COMMAND lws-minimal-secure-streams-smd) 32 endif() 33 set_tests_properties(ss-smd 34 PROPERTIES 35 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-smd 36 TIMEOUT 10) 37 38 if (has_fault_injection) 39 if (VALGRIND) 40 add_test(NAME ss-smd-fi1 COMMAND 41 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 42 $<TARGET_FILE:lws-minimal-secure-streams-smd> 43 --fault-injection "ss/ss_create_smd" 44 --expected-exit 1) 45 add_test(NAME ss-smd-fi2 COMMAND 46 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 47 $<TARGET_FILE:lws-minimal-secure-streams-smd> 48 --fault-injection "ss/ss_create_smd_1" 49 --expected-exit 1) 50 add_test(NAME ss-smd-fi3 COMMAND 51 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 52 $<TARGET_FILE:lws-minimal-secure-streams-smd> 53 --fault-injection "ss/ss_create_smd_2" 54 --expected-exit 1) 55 else() 56 add_test(NAME ss-smd-fi1 COMMAND lws-minimal-secure-streams-smd 57 --fault-injection "ss/ss_create_smd" 58 --expected-exit 1) 59 add_test(NAME ss-smd-fi2 COMMAND lws-minimal-secure-streams-smd 60 --fault-injection "ss/ss_create_smd_1" 61 --expected-exit 1) 62 add_test(NAME ss-smd-fi3 COMMAND lws-minimal-secure-streams-smd 63 --fault-injection "ss/ss_create_smd_2" 64 --expected-exit 1) 65 endif() 66 67 set_tests_properties(ss-smd-fi1 68 ss-smd-fi2 69 ss-smd-fi3 70 PROPERTIES 71 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-smd 72 TIMEOUT 5) 73 endif() 74 75 76 77 endif() 78 79 if (websockets_shared) 80 target_link_libraries(${PROJECT_NAME} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS}) 81 add_dependencies(${PROJECT_NAME} websockets_shared) 82 else() 83 target_link_libraries(${PROJECT_NAME} websockets ${LIBWEBSOCKETS_DEP_LIBS}) 84 endif() 85 86 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) 87 88 if (HAS_LWS_WITH_SECURE_STREAMS_PROXY_API OR LWS_WITH_SECURE_STREAMS_PROXY_API) 89 add_compile_options(-DLWS_SS_USE_SSPC) 90 91 add_executable(${PROJECT_NAME}-client minimal-secure-streams-smd.c multi.c) 92 93 if (websockets_shared) 94 target_link_libraries(${PROJECT_NAME}-client websockets_shared ${LIBWEBSOCKETS_DEP_LIBS}) 95 add_dependencies(${PROJECT_NAME}-client websockets_shared) 96 else() 97 target_link_libraries(${PROJECT_NAME}-client websockets ${LIBWEBSOCKETS_DEP_LIBS}) 98 endif() 99 100 # 101 # Define test dep to bring up and take down the test 102 # proxy 103 # 104 105 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 106 # uds abstract namespace for linux 107 set(CTEST_SOCKET_PATH "@ctest-sspsmd_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}") 108 else() 109 # filesystem socket for others 110 set(CTEST_SOCKET_PATH "/tmp/ctest-sspsmd_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}") 111 endif() 112 113 add_test(NAME st_ssprxsmd_sspc COMMAND 114 ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 115 ssproxysmd_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy> 116 -i ${CTEST_SOCKET_PATH} -d1039) 117 set_tests_properties(st_ssprxsmd_sspc PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP ssproxysmd_sspc TIMEOUT 800) 118 119 add_test(NAME ki_ssprxsmd_sspc COMMAND 120 ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 121 ssproxysmd_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy> 122 -i ${CTEST_SOCKET_PATH} -d1039) 123 set_tests_properties(ki_ssprxsmd_sspc PROPERTIES FIXTURES_CLEANUP ssproxysmd_sspc) 124 125 # 126 # the client part that will connect to the proxy 127 # 128 129 if (VALGRIND) 130 message("testing via valgrind") 131 add_test(NAME sspcsmd_sspc COMMAND 132 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 133 $<TARGET_FILE:lws-minimal-secure-streams-smd-client> -i +${CTEST_SOCKET_PATH}) 134 else() 135 add_test(NAME sspcsmd_sspc COMMAND lws-minimal-secure-streams-smd-client -i +${CTEST_SOCKET_PATH}) 136 endif() 137 set_tests_properties(sspcsmd_sspc PROPERTIES 138 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-smd 139 FIXTURES_REQUIRED "ssproxysmd_sspc" 140 TIMEOUT 80) 141 142 143 # 144 # Define test dep to bring up and take down the test 145 # proxy 146 # 147 148 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 149 # uds abstract namespace for linux 150 set(CTEST_SOCKET_PATH "@ctest-mul-sspsmd_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}") 151 else() 152 # filesystem socket for others 153 set(CTEST_SOCKET_PATH "/tmp/ctest-mul-sspsmd_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}") 154 endif() 155 156 add_test(NAME st_mulssprxsmd_sspc COMMAND 157 ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 158 mulssproxysmd_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy> 159 -i ${CTEST_SOCKET_PATH} -d1039) 160 set_tests_properties(st_mulssprxsmd_sspc PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP mulssproxysmd_sspc TIMEOUT 800) 161 162 add_test(NAME ki_mulssprxsmd_sspc COMMAND 163 ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 164 mulssproxysmd_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy> 165 -i ${CTEST_SOCKET_PATH} -d1039) 166 set_tests_properties(ki_mulssprxsmd_sspc PROPERTIES FIXTURES_CLEANUP mulssproxysmd_sspc) 167 168 # 169 # multi tests for the client part that will connect to the proxy 170 # 171 172 if (VALGRIND) 173 message("testing via valgrind") 174 add_test(NAME mulsspcsmd_sspc COMMAND 175 ${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20 176 $<TARGET_FILE:lws-minimal-secure-streams-smd-client> -i +${CTEST_SOCKET_PATH} --multi -d1039) 177 else() 178 add_test(NAME mulsspcsmd_sspc COMMAND lws-minimal-secure-streams-smd-client -i +${CTEST_SOCKET_PATH} --multi -d1039) 179 endif() 180 set_tests_properties(mulsspcsmd_sspc PROPERTIES 181 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-smd 182 FIXTURES_REQUIRED "mulssproxysmd_sspc" 183 TIMEOUT 80) 184 185 endif() 186 187endif() 188