1
0
cuberite-2a/tests/HTTP/CMakeLists.txt

109 lines
3.6 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.0.2)
2017-09-19 04:34:08 -04:00
enable_testing()
include_directories(${CMAKE_SOURCE_DIR}/src/)
2016-08-24 15:45:03 -04:00
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/libevent/include)
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/mbedtls/include)
add_definitions(-DTEST_GLOBALS=1)
# Create a single HTTP library that contains all the HTTP code:
set (HTTP_SRCS
${CMAKE_SOURCE_DIR}/src/HTTP/EnvelopeParser.cpp
${CMAKE_SOURCE_DIR}/src/HTTP/HTTPMessage.cpp
${CMAKE_SOURCE_DIR}/src/HTTP/HTTPMessageParser.cpp
${CMAKE_SOURCE_DIR}/src/HTTP/TransferEncodingParser.cpp
2016-08-22 13:49:33 -04:00
${CMAKE_SOURCE_DIR}/src/HTTP/UrlClient.cpp
${CMAKE_SOURCE_DIR}/src/HTTP/UrlParser.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/StackTrace.cpp
${CMAKE_SOURCE_DIR}/src/OSSupport/WinStackWalker.cpp
${CMAKE_SOURCE_DIR}/src/StringUtils.cpp
)
set (HTTP_HDRS
${CMAKE_SOURCE_DIR}/src/HTTP/EnvelopeParser.h
${CMAKE_SOURCE_DIR}/src/HTTP/HTTPMessage.h
${CMAKE_SOURCE_DIR}/src/HTTP/HTTPMessageParser.h
${CMAKE_SOURCE_DIR}/src/HTTP/TransferEncodingParser.h
2016-08-22 13:49:33 -04:00
${CMAKE_SOURCE_DIR}/src/HTTP/UrlClient.h
${CMAKE_SOURCE_DIR}/src/HTTP/UrlParser.h
${CMAKE_SOURCE_DIR}/src/OSSupport/StackTrace.h
${CMAKE_SOURCE_DIR}/src/OSSupport/WinStackWalker.h
${CMAKE_SOURCE_DIR}/src/StringUtils.h
)
2016-08-22 13:49:33 -04:00
set (SHARED_SRCS
${CMAKE_SOURCE_DIR}/src/OSSupport/Event.cpp
)
add_library(HTTP
${HTTP_SRCS}
${HTTP_HDRS}
)
2016-08-22 13:49:33 -04:00
target_link_libraries(HTTP Network OSSupport)
2016-08-24 02:28:44 -04:00
set (TEST_DATA_FILES
HTTPRequest1.data
HTTPRequest2.data
HTTPResponse1.data
HTTPResponse2.data
)
source_group("Data Files" FILES ${TEST_DATA_FILES})
2016-08-22 13:49:33 -04:00
# Define individual test executables:
# HTTPMessageParser_file: Feed file contents into a cHTTPResponseParser and print the callbacks as they're called:
2016-08-24 02:28:44 -04:00
add_executable(HTTPMessageParser_file-exe HTTPMessageParser_file.cpp ${TEST_DATA_FILES})
target_link_libraries(HTTPMessageParser_file-exe HTTP Network OSSupport fmt::fmt)
2016-08-22 13:49:33 -04:00
# UrlClientTest: Tests the UrlClient class by requesting a few things off the internet:
add_executable(UrlClientTest-exe UrlClientTest.cpp)
target_link_libraries(UrlClientTest-exe HTTP fmt::fmt)
2016-08-22 13:49:33 -04:00
# Define individual tests:
# Test parsing the response file in 2-byte chunks (should go from response line parsing through headers parsing to body parsing, each within a different step):
add_test(NAME HTTPMessageParser_file-test1-2 COMMAND HTTPMessageParser_file-exe ${CMAKE_CURRENT_SOURCE_DIR}/HTTPResponse1.data 2)
# Test parsing the response file in 128-byte chunks (should parse response line and part of headers in one step, the rest in another step):
add_test(NAME HTTPMessageParser_file-test1-128 COMMAND HTTPMessageParser_file-exe ${CMAKE_CURRENT_SOURCE_DIR}/HTTPResponse1.data 128)
# Test parsing a chunked-encoding response:
add_test(NAME HTTPMessageParser_file-test2 COMMAND HTTPMessageParser_file-exe ${CMAKE_CURRENT_SOURCE_DIR}/HTTPResponse2.data)
# Test parsing the request file in 2-byte chunks (should go from request line parsing through headers parsing to body parsing, each within a different step):
add_test(NAME HTTPMessageParser_file-test3-2 COMMAND HTTPMessageParser_file-exe ${CMAKE_CURRENT_SOURCE_DIR}/HTTPRequest1.data 2)
# Test parsing the request file in 512-byte chunks (should process everything in a single call):
add_test(NAME HTTPMessageParser_file-test4-512 COMMAND HTTPMessageParser_file-exe ${CMAKE_CURRENT_SOURCE_DIR}/HTTPRequest1.data 512)
2016-08-22 13:53:34 -04:00
# Test the URLClient
add_test(NAME UrlClient-test COMMAND UrlClientTest-exe)
# Put all the tests into a solution folder (MSVC):
set_target_properties(
HTTPMessageParser_file-exe
2016-08-22 13:49:33 -04:00
UrlClientTest-exe
PROPERTIES FOLDER Tests/HTTP
)
set_target_properties(
HTTP
PROPERTIES FOLDER Lib
)