2017-09-19 04:34:08 -04:00
enable_testing ( )
2016-01-03 10:07:53 -05:00
include_directories ( ${ CMAKE_SOURCE_DIR } /src/ )
2016-08-24 15:45:03 -04:00
include_directories ( SYSTEM ${ CMAKE_SOURCE_DIR } /lib/libevent/include )
2017-08-30 10:00:06 -04:00
include_directories ( SYSTEM ${ CMAKE_SOURCE_DIR } /lib/mbedtls/include )
2016-01-03 10:07:53 -05:00
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
2016-08-22 13:49:33 -04:00
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / U r l C l i e n t . c p p
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / U r l 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 / 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
2016-08-22 13:49:33 -04:00
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / U r l C l i e n t . h
$ { C M A K E _ S O U R C E _ D I R } / s r c / H T T P / U r l 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 / S t r i n g U t i l s . h
)
2016-08-22 13:49:33 -04:00
set ( SHARED_SRCS
$ { C M A K E _ S O U R C E _ D I R } / s r c / O S S u p p o r t / E v e n t . c p p
)
2016-01-03 10:07:53 -05:00
add_library ( HTTP
$ { H T T P _ S R C S }
$ { H T T P _ H D R S }
)
2016-08-22 13:49:33 -04:00
target_link_libraries ( HTTP Network OSSupport )
2016-01-03 10:07:53 -05:00
2016-08-24 02:28:44 -04:00
set ( TEST_DATA_FILES
H T T P R e q u e s t 1 . d a t a
H T T P R e q u e s t 2 . d a t a
H T T P R e s p o n s e 1 . d a t a
H T T P R e s p o n s e 2 . d a t a
)
source_group ( "Data Files" FILES ${ TEST_DATA_FILES } )
2016-01-03 10:07:53 -05:00
2016-08-22 13:49:33 -04:00
# Define individual test executables:
2016-01-03 10:07:53 -05:00
2016-02-20 05:50:52 -05:00
# 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 } )
2016-08-22 13:49:33 -04:00
target_link_libraries ( HTTPMessageParser_file-exe HTTP Network OSSupport )
# 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 )
# Define individual tests:
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):
2016-03-13 14:57:25 -04:00
add_test ( NAME HTTPMessageParser_file-test1-2 COMMAND HTTPMessageParser_file-exe ${ CMAKE_CURRENT_SOURCE_DIR } /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):
2016-03-13 14:57:25 -04:00
add_test ( NAME HTTPMessageParser_file-test1-128 COMMAND HTTPMessageParser_file-exe ${ CMAKE_CURRENT_SOURCE_DIR } /HTTPResponse1.data 128 )
2016-02-20 05:50:52 -05:00
# Test parsing a chunked-encoding response:
2016-03-13 14:57:25 -04:00
add_test ( NAME HTTPMessageParser_file-test2 COMMAND HTTPMessageParser_file-exe ${ CMAKE_CURRENT_SOURCE_DIR } /HTTPResponse2.data )
2016-02-20 05:50:52 -05:00
# 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):
2016-03-13 14:57:25 -04:00
add_test ( NAME HTTPMessageParser_file-test3-2 COMMAND HTTPMessageParser_file-exe ${ CMAKE_CURRENT_SOURCE_DIR } /HTTPRequest1.data 2 )
2016-02-20 05:50:52 -05:00
# Test parsing the request file in 512-byte chunks (should process everything in a single call):
2016-03-13 14:57:25 -04:00
add_test ( NAME HTTPMessageParser_file-test4-512 COMMAND HTTPMessageParser_file-exe ${ CMAKE_CURRENT_SOURCE_DIR } /HTTPRequest1.data 512 )
2016-02-04 11:44:10 -05:00
2016-08-22 13:53:34 -04:00
# Test the URLClient
add_test ( NAME UrlClient-test COMMAND UrlClientTest-exe )
2016-03-13 13:22:35 -04:00
# Put all the tests into a solution folder (MSVC):
set_target_properties (
H T T P M e s s a g e P a r s e r _ f i l e - e x e
2016-08-22 13:49:33 -04:00
U r l C l i e n t T e s t - e x e
P R O P E R T I E S F O L D E R T e s t s / H T T P
2016-03-13 13:22:35 -04:00
)
set_target_properties (
H T T P
P R O P E R T I E S F O L D E R L i b
)