blob: cb685059f9d33bd4fd8a6b29198f6e5d41eb5383 [file] [log] [blame]
Pascal Bachd5f87e12014-12-12 15:59:17 +01001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20
21# Find required packages
22set(Boost_USE_STATIC_LIBS ON) # Force the use of static boost test framework
23find_package(Boost 1.53.0 REQUIRED COMPONENTS unit_test_framework)
24include_directories("${Boost_INCLUDE_DIR}")
25
26#Make sure gen-cpp files can be included
27include_directories("${CMAKE_CURRENT_BINARY_DIR}")
28
29# Create the thrift C++ test library
30set(testgencpp_SOURCES
31 gen-cpp/DebugProtoTest_types.cpp
32 gen-cpp/DebugProtoTest_types.h
33 gen-cpp/EnumTest_types.cpp
34 gen-cpp/EnumTest_types.h
35 gen-cpp/OptionalRequiredTest_types.cpp
36 gen-cpp/OptionalRequiredTest_types.h
37 gen-cpp/Recursive_types.cpp
38 gen-cpp/Recursive_types.h
39 gen-cpp/ThriftTest_types.cpp
40 gen-cpp/ThriftTest_types.h
41 gen-cpp/TypedefTest_types.cpp
42 gen-cpp/TypedefTest_types.h
43 ThriftTest_extras.cpp
44 DebugProtoTest_extras.cpp
45)
46
47add_library(testgencpp STATIC ${testgencpp_SOURCES})
48target_link_libraries(testgencpp thrift)
49
50set(processortest_SOURCES
51 gen-cpp/ChildService.cpp
52 gen-cpp/ChildService.h
53 gen-cpp/ParentService.cpp
54 gen-cpp/ParentService.h
55 gen-cpp/proc_types.cpp
56 gen-cpp/proc_types.h
57)
58
59
60add_executable(Benchmark Benchmark.cpp)
61target_link_libraries(Benchmark testgencpp)
62add_test(NAME Benchmark COMMAND Benchmark)
63
64set(UnitTest_SOURCES
65 UnitTestMain.cpp
66 TMemoryBufferTest.cpp
67 TBufferBaseTest.cpp
68 Base64Test.cpp
69 ToStringTest.cpp
70 TypedefTest.cpp
71)
72
73if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS)
74 list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp)
75endif()
76
77add_executable(UnitTests ${UnitTest_SOURCES})
78target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES})
79add_test(NAME UnitTests COMMAND UnitTests)
80
81
82if(WITH_ZLIB)
83add_executable(TransportTest TransportTest.cpp)
84target_link_libraries(TransportTest
85 testgencpp
86 thriftz
87 ${Boost_LIBRARIES}
88 ${ZLIB_LIBRARIES}
89)
90add_test(NAME TransportTest COMMAND TransportTest)
91
92add_executable(ZlibTest ZlibTest.cpp)
93target_link_libraries(ZlibTest
94 testgencpp
95 thriftz
96 ${Boost_LIBRARIES}
97 ${ZLIB_LIBRARIES}
98)
99add_test(NAME ZlibTest COMMAND ZlibTest)
100endif(WITH_ZLIB)
101
102
103add_executable(EnumTest EnumTest.cpp)
104target_link_libraries(EnumTest
105 testgencpp
106 ${Boost_LIBRARIES}
107)
108add_test(NAME EnumTest COMMAND EnumTest)
109
110add_executable(TFileTransportTest TFileTransportTest.cpp)
111target_link_libraries(TFileTransportTest
112 testgencpp
113 ${Boost_LIBRARIES}
114)
115add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
116
117add_executable(TFDTransportTest TFDTransportTest.cpp)
118target_link_libraries(TFDTransportTest
119 thrift
120)
121add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
122
123add_executable(TPipedTransportTest TPipedTransportTest.cpp)
124target_link_libraries(TPipedTransportTest
125 thrift
126)
127add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)
128
129set(AllProtocolsTest_SOURCES
130 AllProtocolTests.cpp
131 AllProtocolTests.tcc
132 GenericHelpers
133 )
134
135add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
136target_link_libraries(AllProtocolsTest
137 testgencpp
138)
139add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)
140
141add_executable(DebugProtoTest DebugProtoTest.cpp)
142target_link_libraries(DebugProtoTest
143 testgencpp
144)
145add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
146
147add_executable(JSONProtoTest JSONProtoTest.cpp)
148target_link_libraries(JSONProtoTest
149 testgencpp
150)
151add_test(NAME JSONProtoTest COMMAND JSONProtoTest)
152
153add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
154target_link_libraries(OptionalRequiredTest
155 testgencpp
156)
157add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)
158
159add_executable(RecursiveTest RecursiveTest.cpp)
160target_link_libraries(RecursiveTest
161 testgencpp
162)
163add_test(NAME RecursiveTest COMMAND RecursiveTest)
164
165add_executable(SpecializationTest SpecializationTest.cpp)
166target_link_libraries(SpecializationTest
167 testgencpp
168)
169add_test(NAME SpecializationTest COMMAND SpecializationTest)
170
171set(concurrency_test_SOURCES
172 concurrency/Tests.cpp
173 concurrency/ThreadFactoryTests.h
174 concurrency/ThreadManagerTests.h
175 concurrency/TimerManagerTests.h
176)
177add_executable(concurrency_test ${concurrency_test_SOURCES})
178target_link_libraries(concurrency_test
179 thrift
180)
181add_test(NAME concurrency_test COMMAND concurrency_test)
182
183set(link_test_SOURCES
184 link/LinkTest.cpp
185 link/TemplatedService1.cpp
186 link/TemplatedService2.cpp
187 gen-cpp/ParentService.h
188)
189add_executable(link_test ${link_test_SOURCES})
190add_test(NAME link_test COMMAND link_test)
191
192if(WITH_LIBEVENT)
193set(processor_test_SOURCES
194 processor/ProcessorTest.cpp
195 processor/EventLog.cpp
196 processor/ServerThread.cpp
197 processor/EventLog.h
198 processor/Handlers.h
199 processor/ServerThread.h
200)
201add_executable(processor_test ${processor_test_SOURCES})
202target_link_libraries(processor_test
203 thrift
204 thriftnb
205 ${Boost_LIBRARIES}
206)
207add_test(NAME processor_test COMMAND processor_test)
208endif()
209
210if(OPENSSL_FOUND AND WITH_OPENSSL)
211add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
212target_link_libraries(OpenSSLManualInitTest
213 thrift
214 ${OPENSSL_LIBRARIES}
215 ${Boost_LIBRARIES}
216)
217add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
218endif()
219
220#
221# Common thrift code generation rules
222#
223
224
225add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h
226 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
227)
228
229add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h
230 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift
231)
232
233add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h
234 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift
235)
236
237add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h
238 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
239)
240
241add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h
242 COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift
243)
244
245add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp
246 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
247)
248
249add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h
250 COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
251)
252
253add_custom_command(OUTPUT gen-cpp/ChildService.cpp gen-cpp/ChildService.h gen-cpp/ParentService.cpp gen-cpp/ParentService.h gen-cpp/proc_types.cpp gen-cpp/proc_types.h
254 COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift
255)