Skip to content

Commit 54b2b68

Browse files
committed
api-test-ws-h2-txcredit: ws-over-h2 tx flow-control selftest
A ws server vhost and an RFC 8441 h2 ws client in one process. The server bulk-sends a 64KB pattern in 1KB lws_write() chunks gated only on lws_send_pipe_choked(), like typical user code; the client connects with LCCSCF_H2_MANUAL_RXFLOW and drip-feeds tx credit in 1KB WINDOW_UPDATE quanta, forcing the h2 role to park DATA and split frames to fit the window. Fails (within a second) if the connection doesn't come up as genuine ws-over-h2, if the client ever receives more ws payload than it has granted credit for -- only possible when the server ignored the peer's window -- or if the pattern is corrupted / incomplete; passes when the whole transfer arrives in-window. Wired into ctest like the other api-tests.
1 parent bf6902a commit 54b2b68

2 files changed

Lines changed: 428 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
project(lws-api-test-ws-h2-txcredit C)
2+
cmake_minimum_required(VERSION 3.10)
3+
find_package(libwebsockets CONFIG REQUIRED)
4+
list(APPEND CMAKE_MODULE_PATH ${LWS_CMAKE_DIR})
5+
include(CheckCSourceCompiles)
6+
include(LwsCheckRequirements)
7+
8+
set(SAMP lws-api-test-ws-h2-txcredit)
9+
set(SRCS main.c)
10+
11+
set(requirements 1)
12+
require_lws_config(LWS_ROLE_WS 1 requirements)
13+
require_lws_config(LWS_ROLE_H2 1 requirements)
14+
require_lws_config(LWS_WITH_CLIENT 1 requirements)
15+
require_lws_config(LWS_WITH_SERVER 1 requirements)
16+
require_lws_config(LWS_WITH_TLS 1 requirements)
17+
18+
if (requirements)
19+
add_executable(${SAMP} ${SRCS})
20+
21+
if (websockets_shared)
22+
target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
23+
add_dependencies(${SAMP} websockets_shared)
24+
else()
25+
target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS})
26+
endif()
27+
28+
lws_get_free_port(PORT_WS_H2_TXCR)
29+
30+
add_test(NAME api-test-ws-h2-txcredit COMMAND lws-api-test-ws-h2-txcredit -p ${PORT_WS_H2_TXCR})
31+
set_tests_properties(api-test-ws-h2-txcredit
32+
PROPERTIES
33+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples-lowlevel/api-tests/api-test-ws-h2-txcredit
34+
TIMEOUT 60)
35+
36+
endif()

0 commit comments

Comments
 (0)