2016-01-03 10:07:53 -05:00
cmake_minimum_required ( VERSION 2.6 )
enable_testing ( )
include_directories ( ${ CMAKE_SOURCE_DIR } /src/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /lib/libevent/include )
add_definitions ( -DTEST_GLOBALS=1 )
# Create a single HTTP library that contains all the HTTP code:
set ( HTTP_SRCS
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / E n v e l o p e P a r s e r . c p p
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / H T T P M e s s a g e . c p p
2016-02-20 05:50:52 -05:00
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / H T T P M e s s a g e P a r s e r . c p p
2016-01-03 10:07:53 -05:00
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / T r a n s f e r E n c o d i n g P a r s e r . c p p
$ { C M A K E _ S O U R C E _ D I R } / s r c / S t r i n g U t i l s . c p p
)
set ( HTTP_HDRS
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / E n v e l o p e P a r s e r . h
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / H T T P M e s s a g e . h
2016-02-20 05:50:52 -05:00
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / H T T P M e s s a g e P a r s e r . h
2016-01-03 10:07:53 -05:00
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / T r a n s f e r E n c o d i n g P a r s e r . h
$ { C M A K E _ S O U R C E _ D I R } / s r c / S t r i n g U t i l s . h
)
add_library ( HTTP
$ { H T T P _ S R C S }
$ { H T T P _ H D R S }
)
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
add_flags_cxx ( "-Wno-error=conversion -Wno-error=old-style-cast" )
endif ( )
# Define individual tests:
2016-02-20 05:50:52 -05:00
# HTTPMessageParser_file: Feed file contents into a cHTTPResponseParser and print the callbacks as they're called:
add_executable ( HTTPMessageParser_file-exe HTTPMessageParser_file.cpp )
target_link_libraries ( HTTPMessageParser_file-exe HTTP )
2016-02-04 11:44:10 -05:00
2016-02-20 05:50:52 -05:00
# 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 HTTPResponse1.data 2 )
2016-02-04 11:44:10 -05:00
2016-02-20 05:50:52 -05:00
# 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 HTTPResponse1.data 128 )
# Test parsing a chunked-encoding response:
add_test ( NAME HTTPMessageParser_file-test2 COMMAND HTTPMessageParser_file-exe 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 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 HTTPRequest1.data 512 )
2016-02-04 11:44:10 -05:00