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