Add WithMeta unit tests
[ep-engine.git] / CMakeLists.txt
1 PROJECT(EventuallyPersistentEngine)
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3
4 IF (${CMAKE_MAJOR_VERSION} GREATER 2)
5     CMAKE_POLICY(SET CMP0042 NEW)
6 ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
7
8 INCLUDE(CheckFunctionExists)
9 INCLUDE(CheckIncludeFileCXX)
10 INCLUDE(CheckIncludeFiles)
11 INCLUDE(CheckLibraryExists)
12 INCLUDE(CheckSymbolExists)
13 INCLUDE(CheckTypeSize)
14 INCLUDE(CTest)
15
16 OPTION(EP_USE_FORESTDB "Enable support for ForestDB" OFF)
17
18 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_INSTALL_PREFIX}/include
19                            ${CMAKE_CURRENT_SOURCE_DIR}
20                            ${CMAKE_CURRENT_SOURCE_DIR}/src
21                            ${CMAKE_CURRENT_BINARY_DIR}/src
22                            ${BOOST_INCLUDE_DIR}
23                            ${SNAPPY_INCLUDE_DIR}
24                            ${BOOST_INCLUDE_DIR}
25                            ${Platform_SOURCE_DIR}/include
26                            ${Platform_SOURCE_DIR}/external
27                            ${Memcached_SOURCE_DIR}
28                            ${Memcached_SOURCE_DIR}/utilities
29                            ${Memcached_SOURCE_DIR}/include
30                            ${Couchstore_SOURCE_DIR}/include
31                            ${phosphor_SOURCE_DIR}/include
32                            ${CMAKE_CURRENT_BINARY_DIR})
33
34 INCLUDE_DIRECTORIES(AFTER ${Memcached_BINARY_DIR}/include)
35
36 IF (EP_USE_FORESTDB)
37     INCLUDE_DIRECTORIES(AFTER ${ForestDB_SOURCE_DIR}/include)
38     SET(FOREST_KVSTORE_SOURCE src/forest-kvstore/forest-kvstore.cc)
39     SET(EP_FORESTDB_LIB forestdb)
40     ADD_DEFINITIONS(-DEP_USE_FORESTDB=1)
41     MESSAGE(STATUS "ep-engine: Using ForestDB")
42 ENDIF (EP_USE_FORESTDB)
43
44 INCLUDE_DIRECTORIES(AFTER
45                     ${gtest_SOURCE_DIR}/include
46                     ${gmock_SOURCE_DIR}/include)
47
48 CHECK_INCLUDE_FILES("alloca.h" HAVE_ALLOCA_H)
49 CHECK_INCLUDE_FILES("arpa/inet.h" HAVE_ARPA_INET_H)
50 CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
51 CHECK_INCLUDE_FILES("netdb.h" HAVE_NETDB_H)
52 CHECK_INCLUDE_FILES("mach/mach_time.h" HAVE_MACH_MACH_TIME_H)
53 CHECK_INCLUDE_FILES("poll.h" HAVE_POLL_H)
54 CHECK_INCLUDE_FILES("sysexits.h" HAVE_SYSEXITS_H)
55 CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
56 CHECK_INCLUDE_FILES("sched.h" HAVE_SCHED_H)
57 CHECK_INCLUDE_FILES("sys/socket.h" HAVE_SYS_SOCKET_H)
58 CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H)
59 CHECK_INCLUDE_FILES("netinet/in.h" HAVE_NETINET_IN_H)
60 CHECK_INCLUDE_FILES("netinet/tcp.h" HAVE_NETINET_TCP_H)
61 CHECK_INCLUDE_FILE_CXX("unordered_map" HAVE_UNORDERED_MAP)
62 CHECK_INCLUDE_FILE_CXX("atomic" HAVE_ATOMIC)
63 CHECK_INCLUDE_FILE_CXX("thread" HAVE_THREAD)
64
65 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
66 CHECK_FUNCTION_EXISTS(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
67 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
68 CHECK_FUNCTION_EXISTS(getopt_long HAVE_GETOPT_LONG)
69
70 # For debugging without compiler optimizations uncomment line below..
71 #SET (CMAKE_BUILD_TYPE DEBUG)
72
73 IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
74    EXECUTE_PROCESS(COMMAND git rev-parse HEAD
75                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
76                    OUTPUT_VARIABLE EP_ENGINE_VERSION
77                    OUTPUT_STRIP_TRAILING_WHITESPACE)
78    IF (EP_ENGINE_VERSION STREQUAL "" OR EP_ENGINE_VERSION STREQUAL "HEAD")
79      MESSAGE (FATAL_ERROR "Failed to determine commit SHA!")
80    ENDIF (EP_ENGINE_VERSION STREQUAL "" OR EP_ENGINE_VERSION STREQUAL "HEAD")
81 ELSE (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
82    SET(EP_ENGINE_VERSION "unknown")
83 ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
84
85 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/src/config.cmake.h
86                 ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
87
88 # Generate the python wrappers
89 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
90                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl)
91 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
92                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats)
93 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
94                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact)
95 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
96                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff)
97 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
98                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl)
99
100 SET(Python_ADDITIONAL_VERSIONS 2.6)
101 FIND_PACKAGE(PythonInterp)
102
103 # to avoid cluttering source dir with name + "c" files
104 SET(ENV{PYTHONDONTWRITEBYTECODE} 1)
105
106 # runs cbstats & cbepctl - will fail on basic syntax errors
107 ADD_TEST(cbstats_test ${PYTHON_EXECUTABLE}
108         ${CMAKE_CURRENT_SOURCE_DIR}/management/cbstats --help)
109 ADD_TEST(cbepctl_test ${PYTHON_EXECUTABLE}
110         ${CMAKE_CURRENT_SOURCE_DIR}/management/cbepctl --help)
111
112 IF (WIN32)
113    INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/platform/include/win32)
114 ENDIF (WIN32)
115
116 ADD_EXECUTABLE(gencode tools/gencode.cc)
117 TARGET_LINK_LIBRARIES(gencode cJSON platform)
118
119 ADD_EXECUTABLE(genconfig tools/genconfig.cc)
120 TARGET_LINK_LIBRARIES(genconfig cJSON platform)
121
122 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
123                           ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.h
124                   COMMAND
125                      gencode -j ${CMAKE_CURRENT_SOURCE_DIR}/docs/stats.json -h ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.h -c ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c -f get_stats_info
126                   DEPENDS
127                         docs/stats.json
128                         gencode
129                   COMMENT "Generating code for stats info")
130
131 ADD_CUSTOM_COMMAND(OUTPUT
132                      ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc
133                      ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.h
134                   COMMAND
135                      genconfig ${CMAKE_CURRENT_SOURCE_DIR}/configuration.json
136                   DEPENDS
137                         configuration.json
138                         genconfig
139                   COMMENT "Generating code for configuration class")
140
141 SET(KVSTORE_SOURCE src/kvstore.cc)
142 SET(COUCH_KVSTORE_SOURCE src/couch-kvstore/couch-kvstore.cc
143             src/couch-kvstore/couch-fs-stats.cc)
144 SET(OBJECTREGISTRY_SOURCE src/objectregistry.cc)
145 SET(CONFIG_SOURCE src/configuration.cc
146   ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc)
147
148 SET(COLLECTIONS_SOURCE src/collections/manifest.cc
149                        src/collections/vbucket_manifest.cc
150                        src/collections/vbucket_manifest_entry.cc)
151
152 ADD_LIBRARY(ep_objs OBJECT
153             src/access_scanner.cc
154             src/atomic.cc
155             src/backfill.cc
156             src/bgfetcher.cc
157             src/bloomfilter.cc
158             src/checkpoint.cc
159             src/checkpoint_remover.cc
160             src/conflict_resolution.cc
161             src/connmap.cc
162             src/crc32.c
163             src/dcp/backfill-manager.cc
164             src/dcp/backfill_disk.cc
165             src/dcp/backfill_memory.cc
166             src/dcp/consumer.cc
167             src/dcp/dcpconnmap.cc
168             src/dcp/flow-control.cc
169             src/dcp/flow-control-manager.cc
170             src/dcp/producer.cc
171             src/dcp/response.cc
172             src/dcp/stream.cc
173             src/defragmenter.cc
174             src/defragmenter_visitor.cc
175             src/ep_bucket.cc
176             src/ep_vb.cc
177             src/ep_engine.cc
178             src/ep_time.cc
179             src/ep_types.cc
180             src/ephemeral_bucket.cc
181             src/ephemeral_tombstone_purger.cc
182             src/ephemeral_vb.cc
183             src/ephemeral_vb_count_visitor.cc
184             src/executorpool.cc
185             src/executorthread.cc
186             src/ext_meta_parser.cc
187             src/failover-table.cc
188             src/flusher.cc
189             src/globaltask.cc
190             src/hash_table.cc
191             src/hlc.cc
192             src/htresizer.cc
193             src/item.cc
194             src/item_pager.cc
195             src/logger.cc
196             src/kv_bucket.cc
197             src/kvshard.cc
198             src/memory_tracker.cc
199             src/murmurhash3.cc
200             src/mutation_log.cc
201             src/mutation_log_entry.cc
202             src/pre_link_document_context.cc
203             src/pre_link_document_context.h
204             src/replicationthrottle.cc
205             src/linked_list.cc
206             src/string_utils.cc
207             src/storeddockey.cc
208             src/stored-value.cc
209             src/systemevent.cc
210             src/tapconnection.cc
211             src/tapconnmap.cc
212             src/tasks.cc
213             src/taskqueue.cc
214             src/vb_count_visitor.cc
215             src/vbucket.cc
216             src/vbucketmap.cc
217             src/vbucketmemorydeletiontask.cc
218             src/warmup.cc
219             ${OBJECTREGISTRY_SOURCE}
220             ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
221             ${CONFIG_SOURCE}
222             ${KVSTORE_SOURCE}
223             ${COUCH_KVSTORE_SOURCE}
224             ${FOREST_KVSTORE_SOURCE}
225             ${COLLECTIONS_SOURCE})
226 SET_PROPERTY(TARGET ep_objs PROPERTY POSITION_INDEPENDENT_CODE 1)
227
228 ADD_LIBRARY(ep SHARED $<TARGET_OBJECTS:ep_objs>)
229
230 SET_TARGET_PROPERTIES(ep PROPERTIES PREFIX "")
231 TARGET_LINK_LIBRARIES(ep cJSON JSON_checker couchstore ${EP_FORESTDB_LIB}
232                       engine_utilities dirutils cbcompress
233                       platform phosphor xattr ${LIBEVENT_LIBRARIES})
234
235 # Single executable containing all class-level unit tests involving
236 # EventuallyPersistentEngine driven by GoogleTest.
237 # (We end up compiling most of the src/ files of ep-engine for these unit tests,
238 # so simpler / quicker just to link them into a single executable).
239 ADD_EXECUTABLE(ep-engine_ep_unit_tests
240                tests/mock/mock_dcp.cc
241                tests/mock/mock_synchronous_ep_engine.cc
242                tests/module_tests/atomic_unordered_map_test.cc
243                tests/module_tests/basic_ll_test.cc
244                tests/module_tests/bloomfilter_test.cc
245                tests/module_tests/checkpoint_test.cc
246                tests/module_tests/collections/collection_dockey_test.cc
247                tests/module_tests/collections/evp_store_collections_test.cc
248                tests/module_tests/collections/manifest_test.cc
249                tests/module_tests/collections/vbucket_manifest_test.cc
250                tests/module_tests/collections/vbucket_manifest_entry_test.cc
251                tests/module_tests/configuration_test.cc
252                tests/module_tests/defragmenter_test.cc
253                tests/module_tests/dcp_test.cc
254                tests/module_tests/ep_unit_tests_main.cc
255                tests/module_tests/ephemeral_bucket_test.cc
256                tests/module_tests/ephemeral_vb_test.cc
257                tests/module_tests/evp_engine_test.cc
258                tests/module_tests/evp_store_rollback_test.cc
259                tests/module_tests/evp_store_test.cc
260                tests/module_tests/evp_store_single_threaded_test.cc
261                tests/module_tests/evp_store_with_meta.cc
262                tests/module_tests/executorpool_test.cc
263                tests/module_tests/failover_table_test.cc
264                tests/module_tests/futurequeue_test.cc
265                tests/module_tests/hash_table_test.cc
266                tests/module_tests/item_pager_test.cc
267                tests/module_tests/kvstore_test.cc
268                tests/module_tests/kv_bucket_test.cc
269                tests/module_tests/memory_tracker_test.cc
270                tests/module_tests/mock_hooks_api.cc
271                tests/module_tests/mutation_log_test.cc
272                tests/module_tests/mutex_test.cc
273                tests/module_tests/stats_test.cc
274                tests/module_tests/storeddockey_test.cc
275                tests/module_tests/stored_value_test.cc
276                tests/module_tests/systemevent_test.cc
277                tests/module_tests/test_helpers.cc
278                tests/module_tests/vbucket_test.cc
279                tests/module_tests/warmup_test.cc
280                $<TARGET_OBJECTS:ep_objs>
281                $<TARGET_OBJECTS:memory_tracking>
282                $<TARGET_OBJECTS:couchstore_test_fileops>
283                ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
284                ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
285                ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
286                ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
287
288 TARGET_INCLUDE_DIRECTORIES(ep-engine_ep_unit_tests
289         PUBLIC
290         ${Couchstore_SOURCE_DIR})
291
292 TARGET_LINK_LIBRARIES(ep-engine_ep_unit_tests couchstore cJSON dirutils
293                       engine_utilities ${EP_FORESTDB_LIB}
294                       gtest gmock JSON_checker mcd_util platform
295                       phosphor xattr cbcompress ${MALLOC_LIBRARIES})
296
297 ADD_EXECUTABLE(ep-engine_atomic_ptr_test
298   tests/module_tests/atomic_ptr_test.cc
299   src/atomic.cc
300   src/testlogger.cc)
301 TARGET_LINK_LIBRARIES(ep-engine_atomic_ptr_test platform)
302
303 ADD_EXECUTABLE(ep-engine_couch-fs-stats_test
304         src/couch-kvstore/couch-fs-stats.cc
305         src/generated_configuration.h
306         tests/module_tests/couch-fs-stats_test.cc
307         $<TARGET_OBJECTS:couchstore_wrapped_fileops_test_framework>)
308 TARGET_INCLUDE_DIRECTORIES(ep-engine_couch-fs-stats_test
309         PRIVATE
310         ${Couchstore_SOURCE_DIR}
311         ${Couchstore_SOURCE_DIR}/src)
312 TARGET_LINK_LIBRARIES(ep-engine_couch-fs-stats_test gtest gtest_main gmock platform)
313
314 ADD_EXECUTABLE(ep-engine_hrtime_test tests/module_tests/hrtime_test.cc)
315 TARGET_LINK_LIBRARIES(ep-engine_hrtime_test platform)
316
317 ADD_EXECUTABLE(ep-engine_misc_test tests/module_tests/misc_test.cc)
318 TARGET_LINK_LIBRARIES(ep-engine_misc_test platform)
319
320 ADD_EXECUTABLE(ep-engine_string_utils_test
321                tests/module_tests/string_utils_test.cc
322                src/string_utils.cc)
323 TARGET_LINK_LIBRARIES(ep-engine_string_utils_test gtest gtest_main platform)
324
325 ADD_EXECUTABLE(ep_engine_benchmarks
326                benchmarks/access_scanner_bench.cc
327                tests/mock/mock_synchronous_ep_engine.cc
328                $<TARGET_OBJECTS:ep_objs>
329                $<TARGET_OBJECTS:memory_tracking>
330                $<TARGET_OBJECTS:couchstore_test_fileops>
331                ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
332                ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
333                ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
334                ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc
335                benchmarks/benchmark_memory_tracker.cc
336                benchmarks/defragmenter_bench.cc
337                tests/module_tests/vbucket_test.cc)
338
339 TARGET_LINK_LIBRARIES(ep_engine_benchmarks benchmark platform xattr couchstore
340         cJSON dirutils engine_utilities gtest gmock JSON_checker mcd_util
341         cbcompress ${MALLOC_LIBRARIES})
342 TARGET_INCLUDE_DIRECTORIES(ep_engine_benchmarks PUBLIC
343                            ${benchmark_SOURCE_DIR}/include
344                            tests
345                            benchmarks
346                            ${Couchstore_SOURCE_DIR})
347
348 ADD_TEST(ep-engine_atomic_ptr_test ep-engine_atomic_ptr_test)
349 ADD_TEST(ep-engine_couch-fs-stats_test ep-engine_couch-fs-stats_test)
350 ADD_TEST(ep-engine_ep_unit_tests ep-engine_ep_unit_tests)
351 ADD_TEST(ep-engine_hrtime_test ep-engine_hrtime_test)
352 ADD_TEST(ep-engine_misc_test ep-engine_misc_test)
353
354 ADD_LIBRARY(timing_tests SHARED tests/module_tests/timing_tests.cc)
355 SET_TARGET_PROPERTIES(timing_tests PROPERTIES PREFIX "")
356 TARGET_LINK_LIBRARIES(timing_tests platform)
357
358 ADD_EXECUTABLE(ep-engine_sizes src/sizes.cc
359                                $<TARGET_OBJECTS:ep_objs>)
360 TARGET_LINK_LIBRARIES(ep-engine_sizes cJSON JSON_checker
361   engine_utilities couchstore
362   ${EP_FORESTDB_LIB} dirutils cbcompress platform phosphor xattr
363   ${LIBEVENT_LIBRARIES})
364
365 ADD_LIBRARY(ep_testsuite SHARED
366    tests/ep_testsuite.cc
367    src/ext_meta_parser.cc
368    tests/ep_testsuite_common.cc
369    tests/ep_test_apis.cc
370    tests/mock/mock_dcp.cc
371    ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
372 SET_TARGET_PROPERTIES(ep_testsuite PROPERTIES PREFIX "")
373 TARGET_LINK_LIBRARIES(ep_testsuite couchstore dirutils JSON_checker platform
374                       xattr
375                       ${LIBEVENT_LIBRARIES})
376 ADD_DEPENDENCIES(ep_testsuite engine_testapp)
377
378 ADD_LIBRARY(ep_testsuite_basic SHARED
379    tests/ep_testsuite_basic.cc
380    src/ext_meta_parser.cc
381    tests/ep_testsuite_common.cc
382    tests/ep_test_apis.cc
383    tests/mock/mock_dcp.cc
384 )
385 SET_TARGET_PROPERTIES(ep_testsuite_basic PROPERTIES PREFIX "")
386 TARGET_LINK_LIBRARIES(ep_testsuite_basic engine_utilities JSON_checker dirutils
387                       platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
388 ADD_DEPENDENCIES(ep_testsuite engine_testapp)
389
390 ADD_LIBRARY(ep_testsuite_dcp SHARED
391 tests/ep_testsuite_dcp.cc
392 src/ext_meta_parser.cc
393 tests/ep_testsuite_common.cc
394 tests/ep_test_apis.cc
395 tests/mock/mock_dcp.cc
396 )
397 SET_TARGET_PROPERTIES(ep_testsuite_dcp PROPERTIES PREFIX "")
398 TARGET_LINK_LIBRARIES(ep_testsuite_dcp cbcompress JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
399 ADD_DEPENDENCIES(ep_testsuite_dcp engine_testapp)
400
401 ADD_LIBRARY(ep_testsuite_tap SHARED
402    tests/ep_testsuite_common.cc
403    tests/ep_testsuite_tap.cc
404    tests/ep_test_apis.cc
405    src/ext_meta_parser.cc)
406 SET_TARGET_PROPERTIES(ep_testsuite_tap PROPERTIES PREFIX "")
407 TARGET_LINK_LIBRARIES(ep_testsuite_tap JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
408 ADD_DEPENDENCIES(ep_testsuite_tap engine_testapp)
409
410 ADD_LIBRARY(ep_testsuite_checkpoint SHARED
411    tests/ep_testsuite_common.cc
412    tests/ep_testsuite_checkpoint.cc
413    tests/ep_test_apis.cc
414    src/ext_meta_parser.cc)
415 SET_TARGET_PROPERTIES(ep_testsuite_checkpoint PROPERTIES PREFIX "")
416 TARGET_LINK_LIBRARIES(ep_testsuite_checkpoint JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
417 ADD_DEPENDENCIES(ep_testsuite_checkpoint engine_testapp)
418
419 ADD_LIBRARY(ep_testsuite_xdcr SHARED
420    tests/ep_testsuite_common.cc
421    tests/ep_testsuite_xdcr.cc
422    tests/ep_test_apis.cc
423    src/ext_meta_parser.cc
424    ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
425 SET_TARGET_PROPERTIES(ep_testsuite_xdcr PROPERTIES PREFIX "")
426 TARGET_LINK_LIBRARIES(ep_testsuite_xdcr JSON_checker dirutils platform xattr
427                       ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
428 ADD_DEPENDENCIES(ep_testsuite_xdcr engine_testapp)
429
430 ADD_LIBRARY(ep_perfsuite SHARED
431    tests/ep_perfsuite.cc
432    src/ext_meta_parser.cc
433    tests/ep_testsuite_common.cc
434    tests/ep_test_apis.cc
435    tests/mock/mock_dcp.cc)
436 SET_TARGET_PROPERTIES(ep_perfsuite PROPERTIES PREFIX "")
437 TARGET_LINK_LIBRARIES(ep_perfsuite dirutils platform)
438 ADD_DEPENDENCIES(ep_perfsuite engine_testapp)
439
440 #ADD_CUSTOM_COMMAND(OUTPUT
441 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
442 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
443 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
444 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
445 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
446 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
447 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
448 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
449 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
450 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c
451 #                  COMMAND
452 #                     ${PYTHON_EXECUTABLE} tests/module_tests/gen_engine_test.py
453 #                  DEPENDS
454 #                        tests/module_tests/gen_engine_test.py
455 #                        tests/module_tests/breakdancer.py
456 #                  COMMENT "Generating testsuite")
457 #
458 #ADD_LIBRARY(generated_testsuite SHARED
459 #            tests/suite_stubs.c
460 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
461 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
462 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
463 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
464 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
465 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
466 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
467 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
468 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
469 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c)
470
471 #SET_TARGET_PROPERTIES(generated_testsuite PROPERTIES PREFIX "")
472
473 INSTALL(PROGRAMS
474         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl
475         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats
476         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact
477         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff
478         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl
479         management/cbanalyze-core
480         DESTINATION bin)
481
482 INSTALL(PROGRAMS
483         management/cbepctl
484         management/cbstats
485         management/cbcompact
486         management/cbvdiff
487         management/cbvbucketctl
488         DESTINATION lib/python)
489
490 INSTALL(FILES
491         management/clitool.py
492         management/cli_auth_utils.py
493         management/mc_bin_client.py
494         management/mc_bin_server.py
495         management/memcacheConstants.py
496         management/tap.py
497         management/tap_example.py
498         DESTINATION lib/python)
499
500 INSTALL(FILES
501         docs/stats.org
502         DESTINATION share/doc/ep-engine)
503
504 INSTALL(TARGETS ep
505         RUNTIME DESTINATION bin
506         LIBRARY DESTINATION lib
507         ARCHIVE DESTINATION lib)
508
509
510 # Defines a testsuite which runs in full and value eviction
511 # (persistent), ephemeral buckets (which has no eviction).
512 FUNCTION(ADD_TESTSUITE name timeout)
513   CMAKE_PARSE_ARGUMENTS("arg" "SKIP_EPHEMERAL" "" "" ${ARGN} )
514
515   SET(_cmdline
516     ${CMAKE_BINARY_DIR}/memcached/engine_testapp
517         -E ${CMAKE_CURRENT_BINARY_DIR}/ep.so
518         -T ${CMAKE_CURRENT_BINARY_DIR}/${name}.so)
519   ADD_TEST(NAME ${name}.value_eviction
520          COMMAND ${_cmdline} -v -e "dbname=./${name}.value_eviction.db")
521   ADD_TEST(NAME ${name}.full_eviction
522          COMMAND ${_cmdline} -v -e "item_eviction_policy=full_eviction$<SEMICOLON>dbname=./${name}.full_eviction.db")
523   SET_TESTS_PROPERTIES(${name}.value_eviction PROPERTIES TIMEOUT ${timeout})
524   SET_TESTS_PROPERTIES(${name}.full_eviction PROPERTIES TIMEOUT ${timeout})
525
526   IF(NOT arg_SKIP_EPHEMERAL)
527     ADD_TEST(NAME ${name}.ephemeral
528              COMMAND ${_cmdline} -v -e "bucket_type=ephemeral$<SEMICOLON>dbname=./${name}.ephemeral.db")
529     SET_TESTS_PROPERTIES(${name}.ephemeral PROPERTIES TIMEOUT ${timeout})
530   ENDIF()
531 ENDFUNCTION()
532
533 ADD_TESTSUITE(ep_testsuite 1800)
534
535 ADD_TESTSUITE(ep_testsuite_basic 600)
536
537 ADD_TESTSUITE(ep_testsuite_dcp 1200)
538
539 # TAP not supported for Ephemeral buckets.
540 ADD_TESTSUITE(ep_testsuite_tap 180 SKIP_EPHEMERAL)
541
542 ADD_TESTSUITE(ep_testsuite_checkpoint 120)
543
544 ADD_TESTSUITE(ep_testsuite_xdcr 120)
545
546 # ================================ PERF_TESTS ================================ #
547 SET(_ep_perfsuite_cmdline ${CMAKE_BINARY_DIR}/memcached/engine_testapp -E ${CMAKE_CURRENT_BINARY_DIR}/ep.so -T ${CMAKE_CURRENT_BINARY_DIR}/ep_perfsuite.so -v)
548
549 # Micro perf tests: value-only eviction mode. Note that it makes no sense to run
550 # these tests in full-eviction mode as we disable persistence - see MB-19504.
551 ADD_CUSTOM_TARGET(test-perfsuite
552                   COMMAND ${_ep_perfsuite_cmdline}
553                   DEPENDS ${CMAKE_BINARY_DIR}/memcached/engine_testapp
554                           ep
555                           ep_perfsuite
556                   VERBATIM)
557 ADD_TEST(NAME ep_perfsuite.value_eviction
558          COMMAND ${_ep_perfsuite_cmdline} -e "dbname=./ep_perfsuite.value_eviction.db")
559
560 ADD_TEST(NAME ep_perfsuite.ephemeral
561          COMMAND ${_ep_perfsuite_cmdline} -e "bucket_type=ephemeral$<SEMICOLON>dbname=./ep_perfsuite.ephemeral.db")
562
563 # ============================================================================ #
564
565 ENABLE_CODE_COVERAGE_REPORT()