CMakeLists.txt revision fbc6cc04
1# Copyright (c) 2017 - 2020 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(ADDL_SOURCES ../wincompat/getopt.c ../wincompat/getopt1.c)
10    SET(LIB_FLAGS "-FORCE:MULTIPLE")
11ELSE()
12    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-value")
13    IF (CMAKE_C_COMPILER_ID STREQUAL GNU)
14        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-override-init")
15    ENDIF()
16    IF (CMAKE_C_COMPILER_ID STREQUAL Clang)
17        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-initializer-overrides")
18    ENDIF()
19ENDIF()
20
21include_directories(../src/liblsquic/ls-qpack)
22INCLUDE_DIRECTORIES(../src/lshpack)
23
24SET(TESTS
25    ack
26    ackgen_gquic_be
27    ackparse_gquic_be
28    ackparse_ietf
29    alarmset
30    alt_svc_ver
31    arr
32    attq
33    blocked_gquic_be
34    bw_sampler
35    conn_close_gquic_be
36    crypto_gen
37    cubic
38    dec
39    di_nocopy
40    elision
41    engine_ctor
42    export_key
43    frame_chop
44    frame_reader
45    frame_writer
46    goaway_gquic_be
47    h3_framing
48    hkdf
49    hpi
50    lsquic_hash
51    packet_out
52    packet_resize
53    packno_len
54    parse_packet_in
55    purga
56    qlog
57    quic_be_floats
58    reg_pkt_headergen
59    rst_stream_gquic_be
60    rtt
61    send_headers
62    senhist
63    set
64    sfcw
65    shi
66    spi
67    stop_waiting_gquic_be
68    streamgen
69    streamparse
70    tokgen
71    trapa
72    varint
73    ver_nego
74    wuf_gquic_be
75)
76
77IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
78    # Linux has fmemopen
79    SET(TESTS ${TESTS} frame_rw)
80ENDIF()
81
82IF (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
83    # No regexes on Windows
84    SET(TESTS ${TESTS} ack_merge)
85    # No open_memstream() on Windows
86    SET(TESTS ${TESTS} hcsi_reader)
87ENDIF()
88
89
90FOREACH(TEST_NAME ${TESTS})
91    ADD_EXECUTABLE(test_${TEST_NAME} test_${TEST_NAME}.c ${ADDL_SOURCES})
92    TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${LIB_FLAGS})
93    ADD_TEST(${TEST_NAME} test_${TEST_NAME})
94ENDFOREACH()
95
96ADD_EXECUTABLE(test_stream test_stream.c ${ADDL_SOURCES})
97TARGET_LINK_LIBRARIES(test_stream ${LIBS} ${LIB_FLAGS})
98ADD_TEST(stream test_stream)
99ADD_TEST(stream_hash test_stream -h)
100ADD_TEST(stream_A test_stream -A)
101ADD_TEST(stream_hash_A test_stream -A -h)
102
103IF(NOT MSVC)
104ADD_EXECUTABLE(graph_cubic graph_cubic.c ${ADDL_SOURCES})
105TARGET_LINK_LIBRARIES(graph_cubic ${LIBS})
106
107ADD_EXECUTABLE(mini_parse mini_parse.c ${ADDL_SOURCES})
108TARGET_LINK_LIBRARIES(mini_parse ${LIBS})
109ENDIF()
110
111ADD_EXECUTABLE(test_min_heap test_min_heap.c ../src/liblsquic/lsquic_min_heap.c)
112ADD_TEST(min_heap test_min_heap)
113
114SET(MALO_SRC test_malo.c ../src/liblsquic/lsquic_malo.c)
115IF(MSVC)
116    LIST(APPEND MALO_SRC ../wincompat/getopt.c)
117ENDIF()
118ADD_EXECUTABLE(test_malo_pooled ${MALO_SRC})
119SET_TARGET_PROPERTIES(test_malo_pooled
120    PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_USE_POOLS=1")
121ADD_TEST(malo_pooled test_malo_pooled)
122
123ADD_EXECUTABLE(test_malo_nopool ${MALO_SRC})
124SET_TARGET_PROPERTIES(test_malo_nopool
125    PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_USE_POOLS=0")
126ADD_TEST(malo_nopool test_malo_nopool)
127
128ADD_EXECUTABLE(test_minmax test_minmax.c ../src/liblsquic/lsquic_minmax.c)
129ADD_TEST(minmax test_minmax)
130
131ADD_EXECUTABLE(test_rechist test_rechist.c ../src/liblsquic/lsquic_rechist.c)
132ADD_TEST(rechist test_rechist)
133
134ADD_EXECUTABLE(test_trechist test_trechist.c ../src/liblsquic/lsquic_trechist.c)
135ADD_TEST(trechist test_trechist)
136