• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project(lws-minimal-secure-streams-hugeurl 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-hugeurl)
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.c)
19
20	find_program(VALGRIND "valgrind")
21
22	if (LWS_CTEST_INTERNET_AVAILABLE AND NOT WIN32)
23
24		#
25		# When running in CI, wait for a lease on the resources
26		# before starting this test, so the server does not get
27		# thousands of simultaneous tls connection attempts
28		#
29		# sai-resource holds the lease on the resources until
30		# the time given in seconds or the sai-resource instance
31		# exits, whichever happens first
32		#
33		# If running under Sai, creates a lock test called "res_sspcmin_hurl"
34		#
35
36		sai_resource(warmcat_conns 1 40 sspcmin_hurl)
37
38		#
39		# simple test not via proxy
40		#
41
42		if (VALGRIND)
43			message("testing via valgrind")
44			add_test(NAME ss-warmcat-hurl COMMAND
45				${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20
46				$<TARGET_FILE:lws-minimal-secure-streams-hugeurl>)
47		else()
48			add_test(NAME ss-warmcat-hurl COMMAND lws-minimal-secure-streams-hugeurl)
49		endif()
50
51		set_tests_properties(ss-warmcat-hurl
52				     PROPERTIES
53				     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams
54				     TIMEOUT 20)
55		if (DEFINED ENV{SAI_OVN})
56			set_tests_properties(ss-warmcat-hurl PROPERTIES FIXTURES_REQUIRED "res_sspcmin_hurl")
57		endif()
58
59		if (HAS_LWS_WITH_SECURE_STREAMS_PROXY_API OR LWS_WITH_SECURE_STREAMS_PROXY_API)
60
61			#
62			# Define test dep to bring up and take down the test
63			# proxy
64			#
65
66			if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
67				# uds abstract namespace for linux
68				set(CTEST_SOCKET_PATH "@ctest-ssp-hurl-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
69			else()
70				# filesystem socket for others
71				set(CTEST_SOCKET_PATH "/tmp/ctest-ssp-hurl-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
72			endif()
73			add_test(NAME st_ssproxy-hurl COMMAND
74				${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh
75				ssproxy-hurl $<TARGET_FILE:lws-minimal-secure-streams-proxy>
76				-i ${CTEST_SOCKET_PATH} )
77			set_tests_properties(st_ssproxy-hurl PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP ssproxy-hurl TIMEOUT 800)
78
79			add_test(NAME ki_ssproxy-hurl COMMAND
80				${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh
81				ssproxy-hurl $<TARGET_FILE:lws-minimal-secure-streams-proxy>
82				-i ${CTEST_SOCKET_PATH})
83			set_tests_properties(ki_ssproxy-hurl PROPERTIES FIXTURES_CLEANUP ssproxy-hurl)
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 sspc-minimal-hurl COMMAND
92					${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20
93					$<TARGET_FILE:lws-minimal-secure-streams-client> -i +${CTEST_SOCKET_PATH})
94			else()
95				add_test(NAME sspc-minimal-hurl COMMAND lws-minimal-secure-streams-client -i +${CTEST_SOCKET_PATH})
96			endif()
97
98			set(fixlist "ssproxy-hurl")
99			if (DEFINED ENV{SAI_OVN})
100				list(APPEND fixlist "res_ssproxy-hurl")
101			endif()
102
103			set_tests_properties(sspc-minimal-hurl PROPERTIES
104				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams
105				FIXTURES_REQUIRED "${fixlist}"
106				TIMEOUT 40)
107
108		endif()
109
110	endif()
111
112	if (websockets_shared)
113		target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
114		add_dependencies(${SAMP} websockets_shared)
115	else()
116		target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS})
117	endif()
118
119	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)
120
121	if (HAS_LWS_WITH_SECURE_STREAMS_PROXY_API OR LWS_WITH_SECURE_STREAMS_PROXY_API)
122		add_compile_options(-DLWS_SS_USE_SSPC)
123
124		add_executable(${SAMP}-client minimal-secure-streams.c)
125		if (websockets_shared)
126			target_link_libraries(${SAMP}-client websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
127			add_dependencies(${SAMP}-client websockets_shared)
128		else()
129			target_link_libraries(${SAMP}-client websockets ${LIBWEBSOCKETS_DEP_LIBS})
130		endif()
131	endif()
132
133endif()
134