• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project(lws-minimal-secure-streams-threads 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_pthreads(requirements)
10require_lws_config(LWS_ROLE_H1 1 requirements)
11require_lws_config(LWS_WITH_CLIENT 1 requirements)
12require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements)
13require_lws_config(LWS_WITH_SYS_SMD 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 AND NOT WIN32)
18# win32 has problems with pthreads.h and timespec struct redef
19	add_executable(${PROJECT_NAME} minimal-secure-streams-threads.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-threads COMMAND
27				${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20
28				$<TARGET_FILE:lws-minimal-secure-streams-threads>)
29		else()
30
31			add_test(NAME ss-threads COMMAND lws-minimal-secure-streams-threads)
32		endif()
33		set_tests_properties(ss-threads
34				     PROPERTIES
35				     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-threads
36				     TIMEOUT 10)
37	endif()
38
39	if (websockets_shared)
40		target_link_libraries(${PROJECT_NAME} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
41		add_dependencies(${PROJECT_NAME} websockets_shared)
42	else()
43		target_link_libraries(${PROJECT_NAME} websockets ${LIBWEBSOCKETS_DEP_LIBS})
44	endif()
45
46	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)
47
48	if (HAS_LWS_WITH_SECURE_STREAMS_PROXY_API OR LWS_WITH_SECURE_STREAMS_PROXY_API)
49		add_compile_options(-DLWS_SS_USE_SSPC)
50
51		add_executable(${PROJECT_NAME}-client minimal-secure-streams-threads.c)
52
53		if (websockets_shared)
54			target_link_libraries(${PROJECT_NAME}-client websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
55			add_dependencies(${PROJECT_NAME}-client websockets_shared)
56		else()
57			target_link_libraries(${PROJECT_NAME}-client websockets ${LIBWEBSOCKETS_DEP_LIBS})
58		endif()
59
60		#
61		# Define test dep to bring up and take down the test
62		# proxy
63		#
64
65		if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
66			# uds abstract namespace for linux
67			set(CTEST_SOCKET_PATH "@ctest-sspthreads_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
68		else()
69			# filesystem socket for others
70			set(CTEST_SOCKET_PATH "/tmp/ctest-sspthreads_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
71		endif()
72
73		add_test(NAME st_ssprxthreads_sspc COMMAND
74			${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh
75			ssproxythreads_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy>
76			-i ${CTEST_SOCKET_PATH}  -d1039)
77		set_tests_properties(st_ssprxthreads_sspc PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP ssproxythreads_sspc TIMEOUT 800)
78
79		add_test(NAME ki_ssprxthreads_sspc COMMAND
80			${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh
81			ssproxythreads_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy>
82			-i ${CTEST_SOCKET_PATH}  -d1039)
83		set_tests_properties(ki_ssprxthreads_sspc PROPERTIES FIXTURES_CLEANUP ssproxythreads_sspc)
84
85		#
86		# the client part that will connect to the proxy
87		#
88
89		if (VALGRIND)
90			message("testing via valgrind")
91			add_test(NAME sspcthreads_sspc COMMAND
92				${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20
93				$<TARGET_FILE:lws-minimal-secure-streams-threads-client> -i +${CTEST_SOCKET_PATH})
94		else()
95			add_test(NAME sspcthreads_sspc COMMAND lws-minimal-secure-streams-threads-client -i +${CTEST_SOCKET_PATH})
96		endif()
97		set_tests_properties(sspcthreads_sspc PROPERTIES
98			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-threads
99			FIXTURES_REQUIRED "ssproxythreads_sspc"
100			TIMEOUT 80)
101
102
103		#
104		# Define test dep to bring up and take down the test
105		# proxy
106		#
107
108		if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
109			# uds abstract namespace for linux
110			set(CTEST_SOCKET_PATH "@ctest-mul-sspthreads_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
111		else()
112			# filesystem socket for others
113			set(CTEST_SOCKET_PATH "/tmp/ctest-mul-sspthreads_sspc-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
114		endif()
115
116		add_test(NAME st_mulssprxthreads_sspc COMMAND
117			${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh
118			mulssproxythreads_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy>
119			-i ${CTEST_SOCKET_PATH}  -d1039)
120		set_tests_properties(st_mulssprxthreads_sspc PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP mulssproxythreads_sspc TIMEOUT 800)
121
122		add_test(NAME ki_mulssprxthreads_sspc COMMAND
123			${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh
124			mulssproxythreads_sspc $<TARGET_FILE:lws-minimal-secure-streams-proxy>
125			-i ${CTEST_SOCKET_PATH}  -d1039)
126		set_tests_properties(ki_mulssprxthreads_sspc PROPERTIES FIXTURES_CLEANUP mulssproxythreads_sspc)
127
128	endif()
129
130endif()
131