• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project(lws-minimal-ws-client-spam C)
2cmake_minimum_required(VERSION 2.8.12)
3find_package(libwebsockets CONFIG REQUIRED)
4list(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR})
5include(CheckIncludeFile)
6include(CheckCSourceCompiles)
7include(LwsCheckRequirements)
8
9set(SAMP lws-minimal-ws-client-spam)
10set(SRCS minimal-ws-client-spam.c)
11
12set(requirements 1)
13require_pthreads(requirements)
14require_lws_config(LWS_ROLE_WS 1 requirements)
15require_lws_config(LWS_WITH_CLIENT 1 requirements)
16require_lws_config(LWS_WITH_TLS 1 requirements)
17
18if (requirements)
19	add_executable(${SAMP} ${SRCS})
20	find_program(VALGRIND "valgrind")
21       #
22       # instantiate the server per sai builder instance, they are running in the same
23       # machine context in parallel so they can tread on each other otherwise
24       #
25       set(PORT_WCS_SRV "7620")
26       if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "0")
27	       set(PORT_WCS_SRV 7621)
28       endif()
29       if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "1")
30	       set(PORT_WCS_SRV 7622)
31       endif()
32       if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "2")
33	       set(PORT_WCS_SRV 7623)
34       endif()
35       if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "3")
36	       set(PORT_WCS_SRV 7624)
37       endif()
38
39# hack
40if (WIN32)
41else()
42
43if (LWS_WITH_SERVER)
44if (WIN32)
45	add_test(NAME st_wcs_srv COMMAND cmd.exe /c start /b $<TARGET_FILE:test-server> -s --port ${PORT_WCS_SRV})
46	add_test(NAME ki_wcs_srv COMMAND taskkill /F /IM $<TARGET_FILE_NAME:test-server> /T)
47else()
48	if (VALGRIND)
49		add_test(NAME st_wcs_srv COMMAND
50			${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh
51			wcs_srv ${VALGRIND} --tool=memcheck $<TARGET_FILE:test-server>
52				-r ${CMAKE_SOURCE_DIR}/destdir/usr/local/share/libwebsockets-test-server/
53				-s --port ${PORT_WCS_SRV} )
54		add_test(NAME ki_wcs_srv COMMAND
55			${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh
56			wcs_srv ${VALGRIND} $<TARGET_FILE_NAME:test-server> --port ${PORT_WCS_SRV})
57	else()
58		add_test(NAME st_wcs_srv COMMAND
59			${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh
60			wcs_srv $<TARGET_FILE:test-server>
61				-r ${CMAKE_SOURCE_DIR}/destdir/usr/local/share/libwebsockets-test-server/
62				-s --port ${PORT_WCS_SRV} )
63		add_test(NAME ki_wcs_srv COMMAND
64			${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh
65			wcs_srv $<TARGET_FILE_NAME:test-server> --port ${PORT_WCS_SRV})
66	endif()
67endif()
68
69	set_tests_properties(st_wcs_srv PROPERTIES WORKING_DIRECTORY . FIXTURES_SETUP wcs_srv TIMEOUT 800)
70	set_tests_properties(ki_wcs_srv PROPERTIES FIXTURES_CLEANUP wcs_srv)
71
72	add_test(NAME ws-client-spam COMMAND lws-minimal-ws-client-spam --server localhost --port ${PORT_WCS_SRV} -l 32 -c 3)
73	set_tests_properties(ws-client-spam PROPERTIES
74			     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/ws-client/minimal-ws-client-spam
75			     FIXTURES_REQUIRED "wcs_srv"
76			     TIMEOUT 40)
77endif()
78endif()
79
80	if (websockets_shared)
81		target_link_libraries(${SAMP} websockets_shared ${PTHREAD_LIB} ${LIBWEBSOCKETS_DEP_LIBS})
82		add_dependencies(${SAMP} websockets_shared)
83	else()
84		target_link_libraries(${SAMP} websockets ${PTHREAD_LIB} ${LIBWEBSOCKETS_DEP_LIBS})
85	endif()
86endif()
87