1d4afb5ceSopenharmony_ciproject(lws-minimal-http-client-multi C) 2d4afb5ceSopenharmony_cicmake_minimum_required(VERSION 2.8.12) 3d4afb5ceSopenharmony_cifind_package(libwebsockets CONFIG REQUIRED) 4d4afb5ceSopenharmony_cilist(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR}) 5d4afb5ceSopenharmony_ciinclude(CheckCSourceCompiles) 6d4afb5ceSopenharmony_ciinclude(LwsCheckRequirements) 7d4afb5ceSopenharmony_ci 8d4afb5ceSopenharmony_ciset(SAMP lws-minimal-http-client-multi) 9d4afb5ceSopenharmony_ciset(SRCS minimal-http-client-multi.c) 10d4afb5ceSopenharmony_ci 11d4afb5ceSopenharmony_ciset(requirements 1) 12d4afb5ceSopenharmony_ciset(MBEDTLS 0) 13d4afb5ceSopenharmony_cirequire_lws_config(LWS_ROLE_H1 1 requirements) 14d4afb5ceSopenharmony_cirequire_lws_config(LWS_WITH_CLIENT 1 requirements) 15d4afb5ceSopenharmony_cirequire_lws_config(LWS_WITH_TLS 1 requirements) 16d4afb5ceSopenharmony_cirequire_lws_config(LWS_WITH_SYS_STATE 1 requirements) 17d4afb5ceSopenharmony_ci 18d4afb5ceSopenharmony_cirequire_lws_config(LWS_WITH_MBEDTLS 1 MBEDTLS) 19d4afb5ceSopenharmony_ci 20d4afb5ceSopenharmony_ci 21d4afb5ceSopenharmony_ciif (requirements) 22d4afb5ceSopenharmony_ci add_executable(${SAMP} ${SRCS}) 23d4afb5ceSopenharmony_ci 24d4afb5ceSopenharmony_ci find_program(VALGRIND "valgrind") 25d4afb5ceSopenharmony_ci 26d4afb5ceSopenharmony_ci # 27d4afb5ceSopenharmony_ci # instantiate the server per sai builder instance, they are running in the same 28d4afb5ceSopenharmony_ci # machine context in parallel so they can tread on each other otherwise 29d4afb5ceSopenharmony_ci # 30d4afb5ceSopenharmony_ci set(PORT_HCM_SRV "7670") 31d4afb5ceSopenharmony_ci if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "0") 32d4afb5ceSopenharmony_ci set(PORT_HCM_SRV 7671) 33d4afb5ceSopenharmony_ci endif() 34d4afb5ceSopenharmony_ci if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "1") 35d4afb5ceSopenharmony_ci set(PORT_HCM_SRV 7672) 36d4afb5ceSopenharmony_ci endif() 37d4afb5ceSopenharmony_ci if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "2") 38d4afb5ceSopenharmony_ci set(PORT_HCM_SRV 7673) 39d4afb5ceSopenharmony_ci endif() 40d4afb5ceSopenharmony_ci if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "3") 41d4afb5ceSopenharmony_ci set(PORT_HCM_SRV 7674) 42d4afb5ceSopenharmony_ci endif() 43d4afb5ceSopenharmony_ci 44d4afb5ceSopenharmony_ci 45d4afb5ceSopenharmony_ci# hack 46d4afb5ceSopenharmony_ciif (NOT WIN32 AND LWS_WITH_SERVER) 47d4afb5ceSopenharmony_ci 48d4afb5ceSopenharmony_ci # 49d4afb5ceSopenharmony_ci # Tests against built server running locally (needs daemonization...) 50d4afb5ceSopenharmony_ci # 51d4afb5ceSopenharmony_ci 52d4afb5ceSopenharmony_ciif (WIN32) 53d4afb5ceSopenharmony_ci add_test(NAME st_hcm_srv COMMAND cmd.exe /c start /b $<TARGET_FILE:lws-minimal-http-server-tls> --port ${PORT_HCM_SRV}) 54d4afb5ceSopenharmony_ci add_test(NAME ki_hcm_srv COMMAND taskkill /F /IM $<TARGET_FILE_NAME:lws-minimal-http-server-tls> /T) 55d4afb5ceSopenharmony_ci add_test(NAME st_hcmp_srv COMMAND cmd.exe /c start /b $<TARGET_FILE:test-server> -s --port 1${PORT_HCM_SRV}) 56d4afb5ceSopenharmony_ci add_test(NAME ki_hcmp_srv COMMAND taskkill /F /IM $<TARGET_FILE_NAME:test-server> /T) 57d4afb5ceSopenharmony_cielse() 58d4afb5ceSopenharmony_ci # 59d4afb5ceSopenharmony_ci # mbedtls is too slow to keep up on some targets, when ctest is in parallel 60d4afb5ceSopenharmony_ci # 61d4afb5ceSopenharmony_ci if (VALGRIND AND NOT MBEDTLS) 62d4afb5ceSopenharmony_ci add_test(NAME st_hcm_srv COMMAND 63d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 64d4afb5ceSopenharmony_ci hcm_srv ${VALGRIND} --tool=memcheck $<TARGET_FILE:lws-minimal-http-server-tls> 65d4afb5ceSopenharmony_ci --port ${PORT_HCM_SRV}) 66d4afb5ceSopenharmony_ci add_test(NAME ki_hcm_srv COMMAND 67d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 68d4afb5ceSopenharmony_ci hcm_srv ${VALGRIND} $<TARGET_FILE_NAME:lws-minimal-http-server-tls> 69d4afb5ceSopenharmony_ci --port ${PORT_HCM_SRV}) 70d4afb5ceSopenharmony_ci add_test(NAME st_hcmp_srv COMMAND 71d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 72d4afb5ceSopenharmony_ci hcmp_srv ${VALGRIND} --tool=memcheck $<TARGET_FILE:test-server> -s 73d4afb5ceSopenharmony_ci -r ${CMAKE_SOURCE_DIR}/destdir/usr/local/share/libwebsockets-test-server/ 74d4afb5ceSopenharmony_ci --port 1${PORT_HCM_SRV}) 75d4afb5ceSopenharmony_ci add_test(NAME ki_hcmp_srv COMMAND 76d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 77d4afb5ceSopenharmony_ci hcmp_srv ${VALGRIND} $<TARGET_FILE_NAME:test-server> 78d4afb5ceSopenharmony_ci --port 1${PORT_HCM_SRV}) 79d4afb5ceSopenharmony_ci else() 80d4afb5ceSopenharmony_ci add_test(NAME st_hcm_srv COMMAND 81d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 82d4afb5ceSopenharmony_ci hcm_srv $<TARGET_FILE:lws-minimal-http-server-tls> 83d4afb5ceSopenharmony_ci --port ${PORT_HCM_SRV} ) 84d4afb5ceSopenharmony_ci add_test(NAME ki_hcm_srv COMMAND 85d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 86d4afb5ceSopenharmony_ci hcm_srv $<TARGET_FILE_NAME:lws-minimal-http-server-tls> 87d4afb5ceSopenharmony_ci --port ${PORT_HCM_SRV}) 88d4afb5ceSopenharmony_ci add_test(NAME st_hcmp_srv COMMAND 89d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background.sh 90d4afb5ceSopenharmony_ci hcmp_srv $<TARGET_FILE:test-server> -s 91d4afb5ceSopenharmony_ci -r ${CMAKE_SOURCE_DIR}/destdir/usr/local/share/libwebsockets-test-server/ 92d4afb5ceSopenharmony_ci --port 1${PORT_HCM_SRV} ) 93d4afb5ceSopenharmony_ci add_test(NAME ki_hcmp_srv COMMAND 94d4afb5ceSopenharmony_ci ${CMAKE_SOURCE_DIR}/scripts/ctest-background-kill.sh 95d4afb5ceSopenharmony_ci hcmp_srv $<TARGET_FILE_NAME:test-server> 96d4afb5ceSopenharmony_ci --port 1${PORT_HCM_SRV}) 97d4afb5ceSopenharmony_ci endif() 98d4afb5ceSopenharmony_ciendif() 99d4afb5ceSopenharmony_ci 100d4afb5ceSopenharmony_ci set_tests_properties(st_hcm_srv PROPERTIES 101d4afb5ceSopenharmony_ci WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-server/minimal-http-server-tls 102d4afb5ceSopenharmony_ci FIXTURES_SETUP hcm_srv 103d4afb5ceSopenharmony_ci TIMEOUT 800) 104d4afb5ceSopenharmony_ci set_tests_properties(ki_hcm_srv PROPERTIES 105d4afb5ceSopenharmony_ci FIXTURES_CLEANUP hcm_srv) 106d4afb5ceSopenharmony_ci 107d4afb5ceSopenharmony_ci set_tests_properties(st_hcmp_srv PROPERTIES 108d4afb5ceSopenharmony_ci WORKING_DIRECTORY . 109d4afb5ceSopenharmony_ci FIXTURES_SETUP hcmp_srv 110d4afb5ceSopenharmony_ci TIMEOUT 800) 111d4afb5ceSopenharmony_ci set_tests_properties(ki_hcmp_srv PROPERTIES 112d4afb5ceSopenharmony_ci FIXTURES_CLEANUP hcmp_srv) 113d4afb5ceSopenharmony_ci 114d4afb5ceSopenharmony_ci # 115d4afb5ceSopenharmony_ci # Tests against local server peer 116d4afb5ceSopenharmony_ci # 117d4afb5ceSopenharmony_ci 118d4afb5ceSopenharmony_ci add_test(NAME http-client-multi COMMAND lws-minimal-http-client-multi 119d4afb5ceSopenharmony_ci -l --port ${PORT_HCM_SRV} -d 1151) 120d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-h1 COMMAND lws-minimal-http-client-multi 121d4afb5ceSopenharmony_ci --h1 -l --port ${PORT_HCM_SRV} -d1151) 122d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-pipe COMMAND lws-minimal-http-client-multi 123d4afb5ceSopenharmony_ci -p -l --port ${PORT_HCM_SRV} -d1151) 124d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-h1-pipe COMMAND lws-minimal-http-client-multi 125d4afb5ceSopenharmony_ci --h1 -p -l --port ${PORT_HCM_SRV} -d1151) 126d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-stag COMMAND lws-minimal-http-client-multi 127d4afb5ceSopenharmony_ci -s -l --port ${PORT_HCM_SRV} -d1151) 128d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-stag-h1 COMMAND lws-minimal-http-client-multi 129d4afb5ceSopenharmony_ci --h1 -s -l --port ${PORT_HCM_SRV} -d1151) 130d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-stag-pipe COMMAND lws-minimal-http-client-multi 131d4afb5ceSopenharmony_ci -p -s -l --port ${PORT_HCM_SRV} -d1151) 132d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-stag-h1-pipe COMMAND lws-minimal-http-client-multi 133d4afb5ceSopenharmony_ci --h1 -p -s -l --port ${PORT_HCM_SRV} -d1151) 134d4afb5ceSopenharmony_ci 135d4afb5ceSopenharmony_ci # confirm that the pipelined mode really is doing it in one connection 136d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-restrict-pipe COMMAND lws-minimal-http-client-multi -d1151 --limit 1 -p -l --port ${PORT_HCM_SRV}) 137d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-restrict-h1-pipe COMMAND lws-minimal-http-client-multi -d1151 --limit 1 --h1 -p -l --port ${PORT_HCM_SRV}) 138d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-restrict-stag-pipe COMMAND lws-minimal-http-client-multi -d1151 --limit 1 -p -s -l --port ${PORT_HCM_SRV}) 139d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-restrict-stag-h1-pipe COMMAND lws-minimal-http-client-multi -d1151 --limit 1 --h1 -p -s -l --port ${PORT_HCM_SRV}) 140d4afb5ceSopenharmony_ci # confirm that we do fail with a one connection limit and no pipelining 141d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-restrict-nopipe-fail COMMAND lws-minimal-http-client-multi --limit 1 -l --port ${PORT_HCM_SRV} -d1151) 142d4afb5ceSopenharmony_ci set_property(TEST http-client-multi-restrict-nopipe-fail PROPERTY WILL_FAIL TRUE) 143d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-restrict-h1-nopipe-fail COMMAND lws-minimal-http-client-multi --limit 1 --h1 -l --port ${PORT_HCM_SRV} -d1151) 144d4afb5ceSopenharmony_ci set_property(TEST http-client-multi-restrict-h1-nopipe-fail PROPERTY WILL_FAIL TRUE) 145d4afb5ceSopenharmony_ci 146d4afb5ceSopenharmony_ci set_tests_properties(http-client-multi-restrict-pipe 147d4afb5ceSopenharmony_ci http-client-multi-restrict-h1-pipe 148d4afb5ceSopenharmony_ci http-client-multi-restrict-stag-pipe 149d4afb5ceSopenharmony_ci http-client-multi-restrict-stag-h1-pipe 150d4afb5ceSopenharmony_ci http-client-multi-restrict-nopipe-fail 151d4afb5ceSopenharmony_ci http-client-multi-restrict-h1-nopipe-fail 152d4afb5ceSopenharmony_ci http-client-multi 153d4afb5ceSopenharmony_ci http-client-multi-h1 154d4afb5ceSopenharmony_ci http-client-multi-pipe 155d4afb5ceSopenharmony_ci http-client-multi-h1-pipe 156d4afb5ceSopenharmony_ci http-client-multi-stag 157d4afb5ceSopenharmony_ci http-client-multi-stag-h1 158d4afb5ceSopenharmony_ci http-client-multi-stag-pipe 159d4afb5ceSopenharmony_ci http-client-multi-stag-h1-pipe 160d4afb5ceSopenharmony_ci PROPERTIES 161d4afb5ceSopenharmony_ci FIXTURES_REQUIRED "hcm_srv" 162d4afb5ceSopenharmony_ci WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-client/minimal-http-client-multi 163d4afb5ceSopenharmony_ci TIMEOUT 50) 164d4afb5ceSopenharmony_ci 165d4afb5ceSopenharmony_ci # POSTs against local http-server-form-post 166d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post COMMAND lws-minimal-http-client-multi 167d4afb5ceSopenharmony_ci --post -l --port 1${PORT_HCM_SRV} -d1151) 168d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-h1 COMMAND lws-minimal-http-client-multi 169d4afb5ceSopenharmony_ci --post --h1 -l --port 1${PORT_HCM_SRV} -d1151) 170d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-pipe COMMAND lws-minimal-http-client-multi 171d4afb5ceSopenharmony_ci --post -p -l --port 1${PORT_HCM_SRV} -d1151) 172d4afb5ceSopenharmony_ci if (VALGRIND) 173d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-h1-pipe COMMAND ${VALGRIND} --tool=memcheck $<TARGET_FILE:lws-minimal-http-client-multi> 174d4afb5ceSopenharmony_ci --post --h1 -p -l --port 1${PORT_HCM_SRV} -d1151) 175d4afb5ceSopenharmony_ci else() 176d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-h1-pipe COMMAND lws-minimal-http-client-multi 177d4afb5ceSopenharmony_ci --post --h1 -p -l --port 1${PORT_HCM_SRV} -d1151) 178d4afb5ceSopenharmony_ci endif() 179d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-stag COMMAND lws-minimal-http-client-multi 180d4afb5ceSopenharmony_ci --post -s -l -d1151 --port 1${PORT_HCM_SRV} -d1151) 181d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-stag-h1 COMMAND lws-minimal-http-client-multi 182d4afb5ceSopenharmony_ci --post --h1 -d1151 -s -l --port 1${PORT_HCM_SRV} -d1151) 183d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-stag-pipe COMMAND lws-minimal-http-client-multi 184d4afb5ceSopenharmony_ci --post -p -s -l --port 1${PORT_HCM_SRV} -d1151) 185d4afb5ceSopenharmony_ci add_test(NAME http-client-multi-post-stag-h1-pipe COMMAND lws-minimal-http-client-multi 186d4afb5ceSopenharmony_ci --post --h1 -p -s -l --port 1${PORT_HCM_SRV} -d1151) 187d4afb5ceSopenharmony_ci set_tests_properties(http-client-multi-post 188d4afb5ceSopenharmony_ci http-client-multi-post-h1 189d4afb5ceSopenharmony_ci http-client-multi-post-pipe 190d4afb5ceSopenharmony_ci http-client-multi-post-h1-pipe 191d4afb5ceSopenharmony_ci http-client-multi-post-stag 192d4afb5ceSopenharmony_ci http-client-multi-post-stag-h1 193d4afb5ceSopenharmony_ci http-client-multi-post-stag-pipe 194d4afb5ceSopenharmony_ci http-client-multi-post-stag-h1-pipe 195d4afb5ceSopenharmony_ci PROPERTIES 196d4afb5ceSopenharmony_ci FIXTURES_REQUIRED "hcmp_srv" 197d4afb5ceSopenharmony_ci WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-client/minimal-http-client-multi 198d4afb5ceSopenharmony_ci TIMEOUT 20) 199d4afb5ceSopenharmony_ci 200d4afb5ceSopenharmony_ciendif(NOT WIN32 AND LWS_WITH_SERVER) 201d4afb5ceSopenharmony_ci 202d4afb5ceSopenharmony_ci if (websockets_shared) 203d4afb5ceSopenharmony_ci target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS}) 204d4afb5ceSopenharmony_ci add_dependencies(${SAMP} websockets_shared) 205d4afb5ceSopenharmony_ci else() 206d4afb5ceSopenharmony_ci target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS}) 207d4afb5ceSopenharmony_ci endif() 208d4afb5ceSopenharmony_ciendif() 209