2013-04-17 00:00:27 -04:00
## some functions for getting system info so we can construct BUILDNAME
2013-04-17 00:00:25 -04:00
## given an executable, follows symlinks and resolves paths until it runs
## out of symlinks, then gives you the basename
macro ( real_executable_name filename_input out )
set ( res 0 )
set ( filename ${ filename_input } )
while ( NOT(res ) )
execute_process (
C O M M A N D w h i c h $ { f i l e n a m e }
R E S U L T _ V A R I A B L E r e s
O U T P U T _ V A R I A B L E f u l l _ f i l e n a m e
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( NOT(res ) )
execute_process (
C O M M A N D r e a d l i n k $ { f u l l _ f i l e n a m e }
R E S U L T _ V A R I A B L E r e s
O U T P U T _ V A R I A B L E l i n k _ t a r g e t
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( NOT(res ) )
execute_process (
C O M M A N D d i r n a m e $ { f u l l _ f i l e n a m e }
O U T P U T _ V A R I A B L E f i l e p a t h
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
set ( filename "${filepath}/${link_target}" )
else ( )
set ( filename ${ full_filename } )
endif ( )
else ( )
set ( filename ${ filename } )
endif ( )
endwhile ( )
execute_process (
C O M M A N D b a s e n a m e $ { f i l e n a m e }
O U T P U T _ V A R I A B L E r e a l _ f i l e n a m e
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
set ( ${ out } ${ real_filename } )
endmacro ( real_executable_name )
## gives you `uname ${flag}`
macro ( uname flag out )
execute_process (
C O M M A N D u n a m e $ { f l a g }
O U T P U T _ V A R I A B L E $ { o u t }
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
endmacro ( uname )
2013-04-17 00:00:31 -04:00
## gives the current username
macro ( whoami out )
execute_process (
C O M M A N D w h o a m i
O U T P U T _ V A R I A B L E $ { o u t }
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
endmacro ( whoami )
## gives the current hostname, minus .tokutek.com if it's there
macro ( hostname out )
execute_process (
C O M M A N D h o s t n a m e
O U T P U T _ V A R I A B L E f u l l h o s t n a m e
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX REPLACE "\\.tokutek\\.com$" "" ${ out } ${ fullhostname } )
endmacro ( hostname )
2013-04-17 00:00:25 -04:00
## gather machine info
uname ( "-m" machine_type )
2013-04-17 00:00:59 -04:00
real_executable_name ( "${CMAKE_CXX_COMPILER}" real_cxx_compiler )
2013-04-17 00:00:25 -04:00
get_filename_component ( branchname "${CMAKE_CURRENT_SOURCE_DIR}" NAME )
2013-04-17 00:00:31 -04:00
hostname ( host )
whoami ( user )
2013-04-17 00:00:25 -04:00
2013-04-17 00:00:31 -04:00
## construct SITE, seems to have to happen before include(CTest)
set ( SITE "${user}@${host}" )
2013-04-17 00:01:03 -04:00
if ( USE_GCOV )
set ( buildname_build_type "Coverage" )
else ( USE_GCOV )
set ( buildname_build_type "${CMAKE_BUILD_TYPE}" )
endif ( USE_GCOV )
2013-04-17 00:00:27 -04:00
## construct BUILDNAME, seems to have to happen before include(CTest)
2013-04-17 00:01:03 -04:00
set ( BUILDNAME "${branchname} ${buildname_build_type} ${CMAKE_SYSTEM} ${machine_type} ${CMAKE_CXX_COMPILER_ID} ${real_cxx_compiler} ${CMAKE_CXX_COMPILER_VERSION}" CACHE STRING "CTest build name" FORCE )
2013-04-17 00:00:25 -04:00
include ( CTest )
2013-04-17 00:01:36 -04:00
set ( TOKUDB_DATA "${TokuDB_SOURCE_DIR}/../tokudb.data" CACHE FILEPATH "Path to data files for tests" )
2013-04-17 00:01:11 -04:00
if ( BUILD_TESTING OR BUILD_FT_TESTS OR BUILD_SRC_TESTS )
2013-04-18 15:56:36 -04:00
set ( WARNED_ABOUT_DATA 0 )
if ( NOT EXISTS "${TOKUDB_DATA}/" AND NOT WARNED_ABOUT_DATA )
message ( WARNING "Test data files are missing from ${TOKUDB_DATA}, which will cause some tests to fail. Please put them there or modify TOKUDB_DATA to avoid this." )
set ( WARNED_ABOUT_DATA 1 )
endif ( )
2013-04-17 00:00:25 -04:00
## set up full valgrind suppressions file (concatenate the suppressions files)
2013-04-17 00:00:35 -04:00
file ( READ ft/valgrind.suppressions valgrind_suppressions )
2013-04-17 00:00:27 -04:00
file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${valgrind_suppressions}" )
2013-04-17 00:00:25 -04:00
file ( READ src/tests/bdb.suppressions bdb_suppressions )
file ( APPEND "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${bdb_suppressions}" )
file ( READ bash.suppressions bash_suppressions )
file ( APPEND "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${bash_suppressions}" )
2013-04-17 00:01:10 -04:00
include ( CMakeDependentOption )
set ( helgrind_drd_depend_conditions "" )
2013-04-17 00:01:11 -04:00
## Helgrind and DRD explicitly state that they only run with the Linux
## glibc-2.3 NPTL threading implementation [1,2]. If this ever changes
## we can enable helgrind and drd on other systems.
## [1]: http://valgrind.org/docs/manual/hg-manual.html#hg-manual.effective-use
## [2]: http://valgrind.org/docs/manual/drd-manual.html#drd-manual.limitations
list ( APPEND helgrind_drd_depend_conditions "CMAKE_SYSTEM_NAME STREQUAL Linux" )
2013-04-17 00:01:10 -04:00
## no point doing it with gcov
list ( APPEND helgrind_drd_depend_conditions "NOT USE_GCOV" )
cmake_dependent_option ( RUN_DRD_TESTS "Run some tests under drd." ON
" $ { h e l g r i n d _ d r d _ d e p e n d _ c o n d i t i o n s } " O F F )
cmake_dependent_option ( RUN_HELGRIND_TESTS "Run some tests under helgrind." ON
" $ { h e l g r i n d _ d r d _ d e p e n d _ c o n d i t i o n s } " O F F )
2013-04-17 00:01:28 -04:00
macro ( setup_toku_test_properties test str )
set_tests_properties ( ${ test } PROPERTIES ENVIRONMENT "TOKU_TEST_FILENAME=${str}.ctest-data" )
set_property ( DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${str}.ctest-data" )
endmacro ( setup_toku_test_properties )
macro ( add_toku_test_aux pfx name bin )
add_test ( ${ pfx } / ${ name } ${ bin } ${ ARGN } )
setup_toku_test_properties ( ${ pfx } / ${ name } ${ name } )
endmacro ( add_toku_test_aux )
macro ( add_toku_test pfx bin )
add_toku_test_aux ( ${ pfx } ${ bin } ${ bin } ${ ARGN } )
endmacro ( add_toku_test )
2013-04-17 00:00:25 -04:00
## setup a function to write tests that will run with helgrind
2013-04-17 00:01:21 -04:00
set ( CMAKE_HELGRIND_COMMAND_STRING "valgrind --quiet --tool=helgrind --error-exitcode=1 --soname-synonyms=somalloc=*tokuportability* --suppressions=${TokuDB_SOURCE_DIR}/src/tests/helgrind.suppressions --trace-children=yes --trace-children-skip=sh,*/sh,basename,*/basename,dirname,*/dirname,rm,*/rm,cp,*/cp,mv,*/mv,cat,*/cat,diff,*/diff,grep,*/grep,date,*/date,test,*/tokudb_dump* --trace-children-skip-by-arg=--only_create,--test,--no-shutdown,novalgrind" )
2013-04-17 00:01:28 -04:00
function ( add_helgrind_test pfx name )
2013-04-17 00:01:10 -04:00
separate_arguments ( CMAKE_HELGRIND_COMMAND_STRING )
add_test (
2013-04-17 00:01:28 -04:00
N A M E $ { p f x } / $ { n a m e }
2013-04-17 00:01:10 -04:00
C O M M A N D $ { C M A K E _ H E L G R I N D _ C O M M A N D _ S T R I N G } $ { A R G N }
)
2013-04-17 00:01:28 -04:00
setup_toku_test_properties ( ${ pfx } / ${ name } ${ name } )
2013-04-17 00:00:25 -04:00
endfunction ( add_helgrind_test )
## setup a function to write tests that will run with drd
2013-04-17 00:01:21 -04:00
set ( CMAKE_DRD_COMMAND_STRING "valgrind --quiet --tool=drd --error-exitcode=1 --soname-synonyms=somalloc=*tokuportability* --suppressions=${TokuDB_SOURCE_DIR}/src/tests/drd.suppressions --trace-children=yes --trace-children-skip=sh,*/sh,basename,*/basename,dirname,*/dirname,rm,*/rm,cp,*/cp,mv,*/mv,cat,*/cat,diff,*/diff,grep,*/grep,date,*/date,test,*/tokudb_dump* --trace-children-skip-by-arg=--only_create,--test,--no-shutdown,novalgrind" )
2013-04-17 00:01:28 -04:00
function ( add_drd_test pfx name )
2013-04-17 00:01:10 -04:00
separate_arguments ( CMAKE_DRD_COMMAND_STRING )
add_test (
2013-04-17 00:01:28 -04:00
N A M E $ { p f x } / $ { n a m e }
2013-04-17 00:01:10 -04:00
C O M M A N D $ { C M A K E _ D R D _ C O M M A N D _ S T R I N G } $ { A R G N }
)
2013-04-17 00:01:28 -04:00
setup_toku_test_properties ( ${ pfx } / ${ name } ${ name } )
2013-04-17 00:00:25 -04:00
endfunction ( add_drd_test )
option ( RUN_LONG_TESTS "If set, run all tests, even the ones that take a long time to complete." OFF )
option ( RUN_STRESS_TESTS "If set, run the stress tests." OFF )
option ( RUN_PERF_TESTS "If set, run the perf tests." OFF )
configure_file ( CTestCustom.cmake . @ONLY )
2013-04-17 00:01:11 -04:00
endif ( BUILD_TESTING OR BUILD_FT_TESTS OR BUILD_SRC_TESTS )