• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project(lws-minimal-http-client-jit-trust 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-http-client-jit-trust)
9set(SRCS minimal-http-client.c)
10
11set(has_fault_injection 1)
12set(has_h2 1)
13set(has_plugins 1)
14set(has_ss_policy_parse 1)
15set(has_no_system_vhost 1)
16set(has_async_dns 1)
17
18set(requirements 1)
19
20require_lws_config(LWS_ROLE_H1 1 requirements)
21require_lws_config(LWS_WITH_CLIENT 1 requirements)
22require_lws_config(LWS_WITH_SYS_STATE 1 requirements)
23require_lws_config(LWS_WITH_TLS_JIT_TRUST 1 requirements)
24
25require_lws_config(LWS_ROLE_H2 1 has_h2)
26require_lws_config(LWS_WITH_SYS_FAULT_INJECTION 1 has_fault_injection)
27require_lws_config(LWS_WITH_EVLIB_PLUGINS 1 has_plugins)
28require_lws_config(LWS_WITH_EVENT_LIBS 1 has_plugins)
29
30require_lws_config(LWS_WITH_SECURE_STREAMS 1 has_ss_policy_parse)
31require_lws_config(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY 0 has_ss_policy_parse)
32
33require_lws_config(LWS_WITH_SYS_ASYNC_DNS 0 has_no_system_vhost)
34require_lws_config(LWS_WITH_SYS_NTPCLIENT 0 has_no_system_vhost)
35require_lws_config(LWS_WITH_SYS_DHCP_CLIENT 0 has_no_system_vhost)
36
37require_lws_config(LWS_WITH_SYS_ASYNC_DNS 1 has_async_dns)
38
39if (requirements)
40	add_executable(${SAMP} ${SRCS})
41
42	find_program(VALGRIND "valgrind")
43
44	sai_resource(warmcat_conns 1 40 http_client_warmcat)
45
46	if (LWS_CTEST_INTERNET_AVAILABLE)
47		set(mytests http-client-warmcat-h1)
48		if (has_h2)
49			add_test(NAME http-client-warmcat COMMAND lws-minimal-http-client )
50			list(APPEND mytests http-client-warmcat)
51		endif()
52
53
54		add_test(NAME http-client-warmcat-h1 COMMAND lws-minimal-http-client  --h1)
55
56		if (has_fault_injection)
57
58			# creation related faults
59
60			list(APPEND mytests http-client-fi-ctx1)
61			add_test(NAME http-client-fi-ctx1 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail1")
62
63			# if (has_plugins)
64			# !!! need to actually select an available evlib plugin to trigger this
65			#	list(APPEND mytests http-client-fi-pi)
66			#	add_test(NAME http-client-fi-pi COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_plugin_init")
67			# endif()
68
69			list(APPEND mytests http-client-fi-ctx2)
70			add_test(NAME http-client-fi-ctx2 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_evlib_sel")
71
72			list(APPEND mytests http-client-fi-ctx3)
73			add_test(NAME http-client-fi-ctx3 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_oom_ctx")
74
75			list(APPEND mytests http-client-fi-ctx4)
76			add_test(NAME http-client-fi-ctx4 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_privdrop")
77
78			list(APPEND mytests http-client-fi-ctx5)
79			add_test(NAME http-client-fi-ctx5 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_maxfds")
80
81			list(APPEND mytests http-client-fi-ctx6)
82			add_test(NAME http-client-fi-ctx6 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_oom_fds")
83
84			list(APPEND mytests http-client-fi-ctx7)
85			add_test(NAME http-client-fi-ctx7 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_plat_init")
86
87			list(APPEND mytests http-client-fi-ctx8)
88			add_test(NAME http-client-fi-ctx8 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_evlib_init")
89
90			list(APPEND mytests http-client-fi-ctx9)
91			add_test(NAME http-client-fi-ctx9 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_evlib_pt")
92
93			if (NOT has_no_system_vhost)
94
95				list(APPEND mytests http-client-fi-ctx10)
96				add_test(NAME http-client-fi-ctx10 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_sys_vh")
97
98				list(APPEND mytests http-client-fi-ctx11)
99				add_test(NAME http-client-fi-ctx11 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_sys_vh_init")
100
101			endif()
102
103			list(APPEND mytests http-client-fi-ctx12)
104			add_test(NAME http-client-fi-ctx12 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "ctx_createfail_def_vh")
105
106
107			list(APPEND mytests http-client-fi-vh1)
108			add_test(NAME http-client-fi-vh1 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "vh/vh_create_oom")
109
110			list(APPEND mytests http-client-fi-vh2)
111			add_test(NAME http-client-fi-vh2 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "vh/vh_create_pcols_oom")
112
113			list(APPEND mytests http-client-fi-vh3)
114			add_test(NAME http-client-fi-vh3 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "vh/vh_create_ssl_srv")
115
116			list(APPEND mytests http-client-fi-vh4)
117			add_test(NAME http-client-fi-vh4 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "vh/vh_create_ssl_cli")
118
119			list(APPEND mytests http-client-fi-vh5)
120			add_test(NAME http-client-fi-vh5 COMMAND lws-minimal-http-client --expected-exit 5 --fault-injection "vh/vh_create_srv_init")
121
122
123			list(APPEND mytests http-client-fi-dnsfail)
124			add_test(NAME http-client-fi-dnsfail COMMAND lws-minimal-http-client --expected-exit 3 --fault-injection "wsi=user/dnsfail")
125
126			if (has_async_dns)
127				list(APPEND mytests http-client-fi-connfail)
128				add_test(NAME http-client-fi-connfail COMMAND lws-minimal-http-client --expected-exit 3 --fault-injection "wsi=user/connfail")
129			else()
130				list(APPEND mytests http-client-fi-connfail)
131				add_test(NAME http-client-fi-connfail COMMAND lws-minimal-http-client --expected-exit 2 --fault-injection "wsi=user/connfail")
132			endif()
133
134			list(APPEND mytests http-client-fi-user-est-fail)
135			add_test(NAME http-client-fi-user-est-fail COMMAND lws-minimal-http-client --expected-exit 3 --fault-injection "wsi/user_reject_at_est")
136
137
138		endif()
139
140		set_tests_properties(${mytests} PROPERTIES
141		     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-client/minimal-http-client
142		     TIMEOUT 20)
143
144    		if (DEFINED ENV{SAI_OVN})
145			set_tests_properties(${mytests} PROPERTIES
146					     FIXTURES_REQUIRED "res_http_client_warmcat")
147		endif()
148
149	endif()
150
151	if (websockets_shared)
152		target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
153		add_dependencies(${SAMP} websockets_shared)
154	else()
155		target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS})
156	endif()
157endif()
158