Skip to content

Commit 057a687

Browse files
committed
api-test-ws-h2-pmd: permessage-deflate over ws-over-h2 selftest
Single-process h2 ws server + client, both offering permessage-deflate, ctest-wired like the other api-tests (needs LWS_WITHOUT_EXTENSIONS=OFF). The server bulk-sends a 64KB deterministic pattern in 4KB messages gated only on lws_send_pipe_choked(); alternate messages are trivially compressible (deflated frame far smaller than the payload) and incompressible hash noise (deflated output overflows pmd's default 1KB chunk buffer, forcing tx_draining_ext). It fails if the connection is not genuinely ws-over-h2, if the client's extended CONNECT did not offer permessage-deflate, if any server lws_write() reports fewer bytes accepted than requested, if the pattern corrupts, or if the transfer stalls. Against the pre-series code it catches all three fixes: without the client extension offer it fails the handshake check; without the orig_len return it fails immediately with 'short write: accepted 75 of 4096'; without the encapsulated tx_draining_ext servicing it wedges at the first incompressible message (the POLLOUT mux loop hits its sanity limit) and times out.
1 parent 611e04b commit 057a687

2 files changed

Lines changed: 460 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
project(lws-api-test-ws-h2-pmd 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-pmd)
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+
require_lws_config(LWS_WITHOUT_EXTENSIONS 0 requirements)
18+
19+
if (requirements)
20+
add_executable(${SAMP} ${SRCS})
21+
22+
if (websockets_shared)
23+
target_link_libraries(${SAMP} websockets_shared ${LIBWEBSOCKETS_DEP_LIBS})
24+
add_dependencies(${SAMP} websockets_shared)
25+
else()
26+
target_link_libraries(${SAMP} websockets ${LIBWEBSOCKETS_DEP_LIBS})
27+
endif()
28+
29+
lws_get_free_port(PORT_WS_H2_PMD)
30+
31+
add_test(NAME api-test-ws-h2-pmd COMMAND lws-api-test-ws-h2-pmd -p ${PORT_WS_H2_PMD})
32+
set_tests_properties(api-test-ws-h2-pmd
33+
PROPERTIES
34+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples-lowlevel/api-tests/api-test-ws-h2-pmd
35+
TIMEOUT 60)
36+
37+
endif()

0 commit comments

Comments
 (0)