One HttpClient owns a small pool of workers, each with its own CURLM; an easy handle lives on one worker for its life. Public start/pause/resume/ cancel enqueue a command + curl_multi_wakeup(); callbacks (on_head / on_data / on_finished) run on the worker thread and return a DataAction (proceed / pause / abort). Covers redirects (final-response head only), ranges (inclusive ByteRange -> CURLOPT_RANGE), proxy/SOCKS5, basic/digest auth, cookies, verbatim headers, stall detection, a coarse recv-rate cap, and a curl_share DNS/TLS cache across workers. CURLcode + HTTP status -> vdm::Error in net/curl_error. A probe is on_head returning abort: it finishes successfully (head_complete), not canceled. Tests drive tools/testserver: full GET, ranged 206, redirect chain, 404 -> not_found, connection refused -> connect_failed, HEAD probe + ranged 0-0 probe (no body), cancel mid-transfer, pause/resume completes. Skip cleanly if testserver isn't in the tree. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HPPSGhiArbvQgwC2DNiURS
37 lines
1.7 KiB
CMake
37 lines
1.7 KiB
CMake
# CORE unit tests.
|
|
#
|
|
# Harness is the provisional header-only vtest (support/vtest.hpp); PKG owns the final
|
|
# framework choice (core/docs/pkg-requests-m1.md P2). vdm_add_test() is the only thing
|
|
# test files touch, so swapping harnesses is a one-function edit.
|
|
|
|
add_library(vtest_main STATIC support/vtest_main.cpp)
|
|
target_include_directories(vtest_main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/support)
|
|
target_compile_features(vtest_main PUBLIC cxx_std_23)
|
|
|
|
function(vdm_add_test name)
|
|
add_executable(${name} ${ARGN})
|
|
target_link_libraries(${name} PRIVATE veloxcore vtest_main)
|
|
target_compile_options(${name} PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
add_test(NAME ${name} COMMAND ${name})
|
|
endfunction()
|
|
|
|
vdm_add_test(veloxcore_result_test util/result_test.cpp)
|
|
vdm_add_test(veloxcore_event_bus_test util/event_bus_test.cpp)
|
|
vdm_add_test(veloxcore_thread_pool_test util/thread_pool_test.cpp)
|
|
vdm_add_test(veloxcore_bytes_test util/bytes_test.cpp)
|
|
vdm_add_test(veloxcore_log_test util/log_test.cpp)
|
|
|
|
# net/ integration tests drive tools/testserver (lane PKG/QA). Skip cleanly if it isn't
|
|
# in the tree yet (lanes merge independently).
|
|
set(_testserver ${CMAKE_SOURCE_DIR}/tools/testserver/testserver.py)
|
|
vdm_add_test(veloxcore_http_client_test net/http_client_test.cpp)
|
|
target_include_directories(veloxcore_http_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/net)
|
|
if(EXISTS ${_testserver})
|
|
target_compile_definitions(veloxcore_http_client_test
|
|
PRIVATE VDM_TESTSERVER_PY="${_testserver}")
|
|
set_tests_properties(veloxcore_http_client_test PROPERTIES TIMEOUT 120)
|
|
else()
|
|
message(STATUS "veloxcore: tools/testserver not present; http_client_test will skip "
|
|
"its server-backed cases.")
|
|
endif()
|