forked from EOS-Mainnet/eos
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EOSIO#215 from enumivo/stage112
Stage112
- Loading branch information
Showing
38 changed files
with
996 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
cmake_minimum_required( VERSION 3.5 ) | ||
|
||
set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@) | ||
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@) | ||
|
||
set(ENUMIVO_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@") | ||
|
||
enable_testing() | ||
|
||
find_package( Gperftools QUIET ) | ||
if( GPERFTOOLS_FOUND ) | ||
message( STATUS "Found gperftools; compiling tests with TCMalloc") | ||
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) | ||
endif() | ||
|
||
find_package(LLVM 4.0 REQUIRED CONFIG) | ||
|
||
link_directories(${LLVM_LIBRARY_DIR}) | ||
|
||
set( CMAKE_CXX_STANDARD 14 ) | ||
set( CMAKE_CXX_EXTENSIONS ON ) | ||
set( CXX_STANDARD_REQUIRED ON ) | ||
|
||
if ( APPLE ) | ||
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" ) | ||
set( BOOST_ROOT "/usr/local/boost" ) | ||
else ( APPLE ) | ||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") | ||
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") | ||
set( BOOST_ROOT "~/opt/boost" ) | ||
endif ( APPLE ) | ||
|
||
set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) | ||
find_package(Boost 1.67 REQUIRED COMPONENTS | ||
date_time | ||
filesystem | ||
system | ||
chrono | ||
iostreams | ||
unit_test_framework) | ||
|
||
find_library(libtester enumivo_testing @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libchain enumivo_chain @CMAKE_INSTALL_FULL_LIBDIR@) | ||
if ( "${CMAKE_BUILD_TYPE}" EQUAL "Debug" ) | ||
find_library(libfc fc_debug @CMAKE_INSTALL_FULL_LIBDIR@) | ||
else() | ||
find_library(libfc fc @CMAKE_INSTALL_FULL_LIBDIR@) | ||
endif() | ||
|
||
find_library(libbinaryen binaryen @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libwasm WASM @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libwast WAST @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libir IR @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libplatform Platform @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(liblogging Logging @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libruntime Runtime @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libsoftfloat softfloat @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib) | ||
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib) | ||
find_library(libchainbase chainbase @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libbuiltins builtins @CMAKE_INSTALL_FULL_LIBDIR@) | ||
find_library(libsecp256k1 secp256k1 @Secp256k1_ROOT_DIR@/lib) | ||
|
||
macro(add_enumivo_test test_name) | ||
add_executable( ${test_name} ${ARGN} ) | ||
target_link_libraries( ${test_name} | ||
${LLVM} | ||
${libtester} | ||
${libchain} | ||
${libfc} | ||
${libbinaryen} | ||
${libwast} | ||
${libwasm} | ||
${libruntime} | ||
${libplatform} | ||
${libir} | ||
${libsoftfloat} | ||
${liboscrypto} | ||
${libosssl} | ||
${liblogging} | ||
${libchainbase} | ||
${libbuiltins} | ||
${libsecp256k1} | ||
|
||
LLVMX86Disassembler | ||
LLVMX86AsmParser | ||
LLVMX86AsmPrinter | ||
LLVMX86CodeGen | ||
|
||
LLVMSelectionDAG | ||
|
||
LLVMDebugInfoDWARF | ||
LLVMAsmPrinter | ||
LLVMMCParser | ||
LLVMX86Info | ||
|
||
LLVMOrcJIT | ||
LLVMExecutionEngine | ||
|
||
LLVMCodeGen | ||
LLVMScalarOpts | ||
LLVMTransformUtils | ||
|
||
LLVMipo | ||
LLVMAnalysis | ||
LLVMTarget | ||
LLVMMC | ||
LLVMCore | ||
LLVMSupport | ||
${Boost_FILESYSTEM_LIBRARY} | ||
${Boost_SYSTEM_LIBRARY} | ||
${Boost_CHRONO_LIBRARY} | ||
${Boost_IOSTREAMS_LIBRARY} | ||
${Boost_DATE_TIME_LIBRARY} | ||
${PLATFORM_SPECIFIC_LIBS} | ||
) | ||
|
||
#### TODO /usr/local/include is a hack for fc and some other includes | ||
target_include_directories( ${test_name} PUBLIC | ||
${Boost_INCLUDE_DIRS} | ||
@OPENSSL_INCLUDE_DIR@ | ||
@CMAKE_INSTALL_PREFIX@ | ||
@CMAKE_INSTALL_FULL_INCLUDEDIR@ | ||
@CMAKE_INSTALL_FULL_INCLUDEDIR@/wasm-jit | ||
@CMAKE_INSTALL_FULL_INCLUDEDIR@/softfloat ) | ||
|
||
#Manually run unit_test for all supported runtimes | ||
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose | ||
add_test(NAME ${test_name}_binaryen COMMAND ${test_name} | ||
--report_level=detailed --color_output -- --binaryen) | ||
add_test(NAME ${test_name}_wavm COMMAND ${test_name} | ||
--report_level=detailed --color_output --catch_system_errors=no -- --wavm) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
cmake_minimum_required( VERSION 3.5 ) | ||
|
||
set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@) | ||
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@) | ||
|
||
set(ENUMIVO_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@") | ||
|
||
enable_testing() | ||
|
||
find_package( Gperftools QUIET ) | ||
if( GPERFTOOLS_FOUND ) | ||
message( STATUS "Found gperftools; compiling tests with TCMalloc") | ||
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) | ||
endif() | ||
|
||
find_package(LLVM 4.0 REQUIRED CONFIG) | ||
|
||
link_directories(${LLVM_LIBRARY_DIR}) | ||
|
||
set( CMAKE_CXX_STANDARD 14 ) | ||
set( CMAKE_CXX_EXTENSIONS ON ) | ||
set( CXX_STANDARD_REQUIRED ON ) | ||
|
||
if ( APPLE ) | ||
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" ) | ||
set( BOOST_ROOT "/usr/local/boost" ) | ||
else ( APPLE ) | ||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") | ||
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") | ||
set( BOOST_ROOT "~/opt/boost" ) | ||
endif ( APPLE ) | ||
|
||
set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) | ||
find_package(Boost 1.67 REQUIRED COMPONENTS | ||
date_time | ||
filesystem | ||
system | ||
chrono | ||
iostreams | ||
unit_test_framework) | ||
|
||
find_library(libtester enumivo_testing @CMAKE_BINARY_DIR@/libraries/testing) | ||
find_library(libchain enumivo_chain @CMAKE_BINARY_DIR@/libraries/chain) | ||
if ( "${CMAKE_BUILD_TYPE}" EQUAL "Debug" ) | ||
find_library(libfc fc_debug @CMAKE_BINARY_DIR@/libraries/fc) | ||
else() | ||
find_library(libfc fc @CMAKE_BINARY_DIR@/libraries/fc) | ||
endif() | ||
|
||
find_library(libbinaryen binaryen @CMAKE_BINARY_DIR@/externals/binaryen/lib) | ||
find_library(libwasm WASM @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WASM) | ||
find_library(libwast WAST @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WAST) | ||
find_library(libir IR @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/IR) | ||
find_library(libplatform Platform @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Platform) | ||
find_library(liblogging Logging @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Logging) | ||
find_library(libruntime Runtime @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Runtime) | ||
find_library(libsoftfloat softfloat @CMAKE_BINARY_DIR@/libraries/softfloat) | ||
find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib) | ||
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib) | ||
find_library(libchainbase chainbase @CMAKE_BINARY_DIR@/libraries/chainbase) | ||
find_library(libbuiltins builtins @CMAKE_BINARY_DIR@/libraries/builtins) | ||
find_library(libsecp256k1 secp256k1 @Secp256k1_ROOT_DIR@/lib) | ||
|
||
macro(add_enumivo_test test_name) | ||
add_executable( ${test_name} ${ARGN} ) | ||
target_link_libraries( ${test_name} | ||
${LLVM} | ||
${libtester} | ||
${libchain} | ||
${libfc} | ||
${libbinaryen} | ||
${libwast} | ||
${libwasm} | ||
${libruntime} | ||
${libplatform} | ||
${libir} | ||
${libsoftfloat} | ||
${liboscrypto} | ||
${libosssl} | ||
${liblogging} | ||
${libchainbase} | ||
${libbuiltins} | ||
${libsecp256k1} | ||
|
||
LLVMX86Disassembler | ||
LLVMX86AsmParser | ||
LLVMX86AsmPrinter | ||
LLVMX86CodeGen | ||
|
||
LLVMSelectionDAG | ||
|
||
LLVMDebugInfoDWARF | ||
LLVMAsmPrinter | ||
LLVMMCParser | ||
LLVMX86Info | ||
|
||
LLVMOrcJIT | ||
LLVMExecutionEngine | ||
|
||
LLVMCodeGen | ||
LLVMScalarOpts | ||
LLVMTransformUtils | ||
|
||
LLVMipo | ||
LLVMAnalysis | ||
LLVMTarget | ||
LLVMMC | ||
LLVMCore | ||
LLVMSupport | ||
${Boost_FILESYSTEM_LIBRARY} | ||
${Boost_SYSTEM_LIBRARY} | ||
${Boost_CHRONO_LIBRARY} | ||
${Boost_IOSTREAMS_LIBRARY} | ||
${Boost_DATE_TIME_LIBRARY} | ||
${PLATFORM_SPECIFIC_LIBS} | ||
) | ||
|
||
target_include_directories( ${test_name} PUBLIC | ||
${Boost_INCLUDE_DIRS} | ||
@OPENSSL_INCLUDE_DIR@ | ||
@CMAKE_SOURCE_DIR@/libraries/chain/include | ||
@CMAKE_BINARY_DIR@/libraries/chain/include | ||
@CMAKE_SOURCE_DIR@/libraries/fc/include | ||
@CMAKE_SOURCE_DIR@/libraries/softfloat/source/include | ||
@CMAKE_SOURCE_DIR@/libraries/appbase/include | ||
@CMAKE_SOURCE_DIR@/libraries/chainbase/include | ||
@CMAKE_SOURCE_DIR@/libraries/testing/include | ||
@CMAKE_SOURCE_DIR@/libraries/wasm-jit/Include ) | ||
# | ||
#Manually run unit_test for all supported runtimes | ||
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose | ||
add_test(NAME ${test_name}_binaryen COMMAND ${test_name} | ||
--report_level=detailed --color_output -- --binaryen) | ||
add_test(NAME ${test_name}_wavm COMMAND ${test_name} | ||
--report_level=detailed --color_output --catch_system_errors=no -- --wavm) | ||
endmacro() | ||
|
||
if(ENABLE_COVERAGE_TESTING) | ||
|
||
set(Coverage_NAME ${PROJECT_NAME}_ut_coverage) | ||
|
||
if(NOT LCOV_PATH) | ||
message(FATAL_ERROR "lcov not found! Aborting...") | ||
endif() # NOT LCOV_PATH | ||
|
||
if(NOT LLVMCOV_PATH) | ||
message(FATAL_ERROR "llvm-cov not found! Aborting...") | ||
endif() # NOT LCOV_PATH | ||
|
||
if(NOT GENHTML_PATH) | ||
message(FATAL_ERROR "genhtml not found! Aborting...") | ||
endif() # NOT GENHTML_PATH | ||
|
||
# no spaces allowed within tests list | ||
set(ctest_tests 'unit_test_binaryen|unit_test_wavm') | ||
set(ctest_exclude_tests '') | ||
|
||
# Setup target | ||
add_custom_target(${Coverage_NAME} | ||
|
||
# Cleanup lcov | ||
COMMAND ${LCOV_PATH} --directory . --zerocounters | ||
|
||
# Run tests | ||
COMMAND ./tools/ctestwrapper.sh -R ${ctest_tests} -E ${ctest_exclude_tests} | ||
|
||
COMMAND ${LCOV_PATH} --directory . --capture --gcov-tool ./tools/llvm-gcov.sh --output-file ${Coverage_NAME}.info | ||
|
||
COMMAND ${LCOV_PATH} -remove ${Coverage_NAME}.info '*/boost/*' '/usr/lib/*' '/usr/include/*' '*/externals/*' '*/fc/*' '*/wasm-jit/*' --output-file ${Coverage_NAME}_filtered.info | ||
|
||
COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}_filtered.info | ||
|
||
COMMAND if [ "$CI" != "true" ]\; then ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.info ${Coverage_NAME}_filtered.info ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned ${PROJECT_BINARY_DIR}/${Coverage_NAME}_filtered.info.cleaned\; fi | ||
|
||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} | ||
COMMENT "Resetting code coverage counters to zero. Processing code coverage counters and generating report. Report published in ./${Coverage_NAME}" | ||
) | ||
|
||
# Show info where to find the report | ||
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD | ||
COMMAND ; | ||
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report." | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.