|
| 1 | +cmake_policy(SET CMP0015 NEW) |
| 2 | + |
| 3 | +aux_source_directory(. SRC_LIST) |
| 4 | + |
| 5 | +macro (add_sources) |
| 6 | + file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}/test" "${CMAKE_CURRENT_SOURCE_DIR}") |
| 7 | + foreach (_src ${ARGN}) |
| 8 | + if (_relPath) |
| 9 | + list (APPEND SRC "${_relPath}/${_src}") |
| 10 | + else() |
| 11 | + list (APPEND SRC "${_src}") |
| 12 | + endif() |
| 13 | + endforeach() |
| 14 | + if (_relPath) |
| 15 | + # propagate SRCS to parent directory |
| 16 | + set (SRC ${SRC} PARENT_SCOPE) |
| 17 | + endif() |
| 18 | +endmacro() |
| 19 | + |
| 20 | +add_subdirectory(fuzzTesting) |
| 21 | +add_subdirectory(libdevcore) |
| 22 | +add_subdirectory(libdevcrypto) |
| 23 | +add_subdirectory(libethcore) |
| 24 | +add_subdirectory(libethereum) |
| 25 | +add_subdirectory(libevm) |
| 26 | +add_subdirectory(libnatspec) |
| 27 | +add_subdirectory(libp2p) |
| 28 | +add_subdirectory(external-dependencies) |
| 29 | + |
| 30 | +if (JSCONSOLE) |
| 31 | + add_subdirectory(libjsengine) |
| 32 | +endif() |
| 33 | + |
| 34 | +if (SOLIDITY) |
| 35 | + add_subdirectory(libsolidity) |
| 36 | + add_subdirectory(contracts) |
| 37 | +endif () |
| 38 | +if (JSONRPC) |
| 39 | +add_subdirectory(libweb3jsonrpc) |
| 40 | +endif () |
| 41 | +add_subdirectory(libwhisper) |
| 42 | + |
| 43 | +set(SRC_LIST ${SRC_LIST} ${SRC}) |
| 44 | + |
| 45 | +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) |
| 46 | +include_directories(BEFORE ..) |
| 47 | +include_directories(${Boost_INCLUDE_DIRS}) |
| 48 | +include_directories(${CRYPTOPP_INCLUDE_DIRS}) |
| 49 | +include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) |
| 50 | + |
| 51 | +if (JSCONSOLE) |
| 52 | + include_directories(${V8_INCLUDE_DIRS}) |
| 53 | +endif() |
| 54 | + |
| 55 | +# search for test names and create ctest tests |
| 56 | +enable_testing() |
| 57 | +foreach(file ${SRC_LIST}) |
| 58 | + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${file} test_list_raw REGEX "BOOST_.*TEST_(SUITE|CASE)") |
| 59 | + set(TestSuite "DEFAULT") |
| 60 | + foreach(test_raw ${test_list_raw}) |
| 61 | + string(REGEX REPLACE ".*TEST_(SUITE|CASE)\\(([^ ,\\)]*).*" "\\1 \\2" test ${test_raw}) |
| 62 | + if(test MATCHES "^SUITE .*") |
| 63 | + string(SUBSTRING ${test} 6 -1 TestSuite) |
| 64 | + elseif(test MATCHES "^CASE .*") |
| 65 | + string(SUBSTRING ${test} 5 -1 TestCase) |
| 66 | + add_test(NAME ${TestSuite}/${TestCase} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth -t ${TestSuite}/${TestCase}) |
| 67 | + endif(test MATCHES "^SUITE .*") |
| 68 | + endforeach(test_raw) |
| 69 | +endforeach(file) |
| 70 | + |
| 71 | +file(GLOB HEADERS "*.h") |
| 72 | +add_executable(testeth ${SRC_LIST} ${HEADERS}) |
| 73 | + |
| 74 | +target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) |
| 75 | +target_link_libraries(testeth ${CURL_LIBRARIES}) |
| 76 | +target_link_libraries(testeth ${CRYPTOPP_LIBRARIES}) |
| 77 | +target_link_libraries(testeth ethereum) |
| 78 | +target_link_libraries(testeth ethcore) |
| 79 | +if (NOT WIN32) |
| 80 | + target_link_libraries(testeth secp256k1) |
| 81 | +endif () |
| 82 | + |
| 83 | +if (JSCONSOLE) |
| 84 | + target_link_libraries(testeth jsengine) |
| 85 | +endif() |
| 86 | + |
| 87 | +if (SOLIDITY) |
| 88 | + target_link_libraries(testeth solidity) |
| 89 | +endif () |
| 90 | + |
| 91 | +target_link_libraries(testeth testutils) |
| 92 | + |
| 93 | +if (GUI AND NOT JUSTTESTS) |
| 94 | + target_link_libraries(testeth webthree) |
| 95 | + target_link_libraries(testeth natspec) |
| 96 | +endif() |
| 97 | + |
| 98 | +if (JSONRPC) |
| 99 | + target_link_libraries(testeth web3jsonrpc) |
| 100 | + target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES}) |
| 101 | +endif() |
| 102 | + |
| 103 | +enable_testing() |
| 104 | +set(CTEST_OUTPUT_ON_FAILURE TRUE) |
| 105 | + |
| 106 | +include(EthUtils) |
| 107 | + |
| 108 | +eth_add_test(ClientBase |
| 109 | + ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=1 |
| 110 | + ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=3 |
| 111 | + ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=10 |
| 112 | + ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=1 |
| 113 | + ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=3 |
| 114 | + ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=10 |
| 115 | +) |
| 116 | + |
| 117 | +eth_add_test(JsonRpc |
| 118 | + ARGS --eth_testfile=BlockTests/bcJS_API_Test |
| 119 | + ARGS --eth_testfile=BlockTests/bcValidBlockTest |
| 120 | +) |
| 121 | + |
0 commit comments