CMakeLists.txt revision f07b3eae
1# Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. 2INCLUDE_DIRECTORIES(../src/liblsquic) 3 4ENABLE_TESTING() 5 6SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_TEST=1") 7 8IF (MSVC) 9 SET(LIB_FLAGS "-FORCE:MULTIPLE") 10ELSE() 11 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-value") 12 IF (CMAKE_C_COMPILER_ID STREQUAL GNU) 13 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-override-init") 14 ENDIF() 15 IF (CMAKE_C_COMPILER_ID STREQUAL Clang) 16 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-initializer-overrides") 17 ENDIF() 18ENDIF() 19 20include_directories(../src/liblsquic/ls-qpack) 21INCLUDE_DIRECTORIES(../src/lshpack) 22 23SET(TESTS 24 ack 25 ackgen_gquic_be 26 ackparse_gquic_be 27 ackparse_ietf 28 alarmset 29 alt_svc_ver 30 arr 31 attq 32 blocked_gquic_be 33 bw_sampler 34 conn_close_gquic_be 35 crypto_gen 36 cubic 37 dec 38 di_nocopy 39 elision 40 engine_ctor 41 export_key 42 frame_chop 43 frame_reader 44 frame_writer 45 goaway_gquic_be 46 hkdf 47 hpi 48 lsquic_hash 49 packet_out 50 packet_resize 51 packno_len 52 parse_packet_in 53 purga 54 qlog 55 quic_be_floats 56 reg_pkt_headergen 57 rst_stream_gquic_be 58 rtt 59 send_headers 60 senhist 61 set 62 sfcw 63 shi 64 spi 65 stop_waiting_gquic_be 66 streamgen 67 streamparse 68 tokgen 69 trapa 70 varint 71 ver_nego 72 wuf_gquic_be 73) 74 75IF (CMAKE_SYSTEM_NAME STREQUAL "Linux") 76 # Linux has fmemopen 77 SET(TESTS ${TESTS} frame_rw) 78ENDIF() 79 80IF (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") 81 # No regexes on Windows 82 SET(TESTS ${TESTS} ack_merge) 83 # No open_memstream() on Windows 84 SET(TESTS ${TESTS} hcsi_reader) 85 # Takes forever on Windows, for whatever reason. Or maybe it's the 86 # MS C compilers. Something to investigate... later. 87 LIST(APPEND TESTS h3_framing) 88ENDIF() 89 90 91FOREACH(TEST_NAME ${TESTS}) 92 ADD_EXECUTABLE(test_${TEST_NAME} test_${TEST_NAME}.c ${ADDL_SOURCES}) 93 IF(NOT MSVC) 94 TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${LIB_FLAGS}) 95 ELSE() 96 TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${GETOPT_LIB} ${LIB_FLAGS}) 97 # copy any dependencies local to the tests 98 #IF (${CMAKE_VERSION} VERSION_LESS "3.21.0") 99 ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD 100 COMMAND ${CMAKE_COMMAND} -E copy \"$ENV{VCPKG_ROOT}/installed/x64-windows$<$<CONFIG:Debug>:/debug>/bin/getopt.dll\" \"$<TARGET_FILE_DIR:test_${TEST_NAME}>\" 101 COMMAND_EXPAND_LISTS 102 ) 103 #ELSE() 104 # ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD 105 # COMMAND if not \"\"=="$<TARGET_RUNTIME_DLLS:test_${TEST_NAME}>" ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:test_${TEST_NAME}> $<TARGET_FILE_DIR:test_${TEST_NAME}> 106 # COMMAND_EXPAND_LISTS 107 # ) 108 #ENDIF() 109 ENDIF() 110 ADD_TEST(${TEST_NAME} test_${TEST_NAME}) 111ENDFOREACH() 112 113ADD_EXECUTABLE(test_stream test_stream.c ${ADDL_SOURCES}) 114TARGET_LINK_LIBRARIES(test_stream ${LIBS} ${LIB_FLAGS}) 115IF(MSVC) 116 TARGET_LINK_LIBRARIES(test_stream ${GETOPT_LIB}) 117ENDIF() 118ADD_TEST(stream test_stream) 119ADD_TEST(stream_hash test_stream -h) 120ADD_TEST(stream_A test_stream -A) 121ADD_TEST(stream_hash_A test_stream -A -h) 122 123IF(NOT MSVC) 124ADD_EXECUTABLE(graph_cubic graph_cubic.c ${ADDL_SOURCES}) 125TARGET_LINK_LIBRARIES(graph_cubic ${LIBS}) 126 127ADD_EXECUTABLE(mini_parse mini_parse.c ${ADDL_SOURCES}) 128TARGET_LINK_LIBRARIES(mini_parse ${LIBS}) 129ENDIF() 130 131ADD_EXECUTABLE(test_min_heap test_min_heap.c ../src/liblsquic/lsquic_min_heap.c) 132ADD_TEST(min_heap test_min_heap) 133 134SET(MALO_SRC test_malo.c ../src/liblsquic/lsquic_malo.c) 135ADD_EXECUTABLE(test_malo_pooled ${MALO_SRC}) 136IF(MSVC) 137 TARGET_LINK_LIBRARIES(test_malo_pooled ${GETOPT_LIB}) 138ENDIF() 139SET_TARGET_PROPERTIES(test_malo_pooled 140 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_USE_POOLS=1") 141ADD_TEST(malo_pooled test_malo_pooled) 142 143ADD_EXECUTABLE(test_malo_nopool ${MALO_SRC}) 144IF(MSVC) 145 TARGET_LINK_LIBRARIES(test_malo_nopool ${GETOPT_LIB}) 146ENDIF() 147SET_TARGET_PROPERTIES(test_malo_nopool 148 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_USE_POOLS=0") 149ADD_TEST(malo_nopool test_malo_nopool) 150 151ADD_EXECUTABLE(test_minmax test_minmax.c ../src/liblsquic/lsquic_minmax.c) 152IF(MSVC) 153 TARGET_LINK_LIBRARIES(test_minmax ${GETOPT_LIB}) 154ENDIF() 155ADD_TEST(minmax test_minmax) 156 157ADD_EXECUTABLE(test_rechist test_rechist.c ../src/liblsquic/lsquic_rechist.c) 158ADD_TEST(rechist test_rechist) 159 160ADD_EXECUTABLE(test_trechist test_trechist.c ../src/liblsquic/lsquic_trechist.c) 161ADD_TEST(trechist test_trechist) 162