• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project(lws-minimal-secure-streams-client-tx 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-client-tx)
9set(SRCS minimal-secure-streams-client-tx.c)
10
11set(requirements 1)
12require_lws_config(LWS_ROLE_H1 1 requirements)
13require_lws_config(LWS_WITHOUT_CLIENT 0 requirements)
14require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements)
15require_lws_config(LWS_WITH_SECURE_STREAMS_PROXY_API 1 requirements)
16require_lws_config(LWS_WITH_SYS_STATE 1 requirements)
17
18if (requirements)
19	add_executable(${SAMP} ${SRCS})
20	add_compile_options(-DLWS_SS_USE_SSPC)
21
22	find_program(VALGRIND "valgrind")
23
24	if (LWS_CTEST_INTERNET_AVAILABLE AND NOT WIN32)
25
26		#
27		# Define test dep to bring up and take down the test
28		# proxy
29		#
30
31		if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
32			# uds abstract namespace for linux
33			set(CTEST_SOCKET_PATH "@ctest-sspctx-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
34		else()
35			# filesystem socket for others
36			set(CTEST_SOCKET_PATH "/tmp/ctest-sspctx-$ENV{SAI_PROJECT}-$ENV{SAI_OVN}")
37		endif()
38		add_test(NAME st_ssproxyctx COMMAND
39			${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh
40			ssproxyctx $<TARGET_FILE:lws-minimal-secure-streams-proxy>
41			-i ${CTEST_SOCKET_PATH} )
42		set_tests_properties(st_ssproxyctx PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP ssproxyctx TIMEOUT 800)
43
44		add_test(NAME ki_ssproxyctx COMMAND
45			${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh
46			ssproxyctx $<TARGET_FILE:lws-minimal-secure-streams-proxy>
47			-i ${CTEST_SOCKET_PATH})
48		set_tests_properties(ki_ssproxyctx PROPERTIES FIXTURES_CLEANUP ssproxyctx)
49
50		#
51		# the client part that will connect to the proxy
52		#
53
54		if (VALGRIND)
55			message("testing via valgrind")
56			add_test(NAME sspc-minimaltx COMMAND
57				${VALGRIND} --tool=memcheck --leak-check=yes --num-callers=20
58				$<TARGET_FILE:lws-minimal-secure-streams-client-tx> -i +${CTEST_SOCKET_PATH})
59		else()
60			add_test(NAME sspc-minimaltx COMMAND lws-minimal-secure-streams-client-tx -i +${CTEST_SOCKET_PATH})
61		endif()
62		set_tests_properties(sspc-minimaltx PROPERTIES
63			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/secure-streams/minimal-secure-streams-client-tx
64			FIXTURES_REQUIRED "ssproxyctx"
65			TIMEOUT 40)
66
67	endif()
68
69
70	if (websockets_shared)
71		target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
72		add_dependencies(${SAMP} websockets_shared)
73	else()
74		target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS})
75	endif()
76endif()
77