-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
51 lines (45 loc) · 2.91 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
### Build contracts with cdt if available ###
include(ExternalProject)
set(SPEC_TEST_WASM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/wasms")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/wasm_spec_tests.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/include/wasm_spec_tests.hpp ESCAPE_QUOTES)
### BUILD UNIT TEST EXECUTABLE ###
file(GLOB WASM_TESTS "*.cpp") # find all unit test suites
add_executable( wasm_spec_test ${WASM_TESTS}) # build unit tests as one executable
target_link_libraries( wasm_spec_test eosio_chain_wrap chainbase eosio_testing fc appbase ${PLATFORM_SPECIFIC_LIBS} )
target_compile_options(wasm_spec_test PUBLIC -DDISABLE_EOSLIB_SERIALIZE)
target_include_directories( wasm_spec_test PUBLIC
${CMAKE_SOURCE_DIR}/libraries/testing/include
${CMAKE_CURRENT_BINARY_DIR}/include )
### MARK TEST SUITES FOR EXECUTION ###
foreach(TEST_SUITE ${WASM_TESTS}) # create an independent target for each test suite
execute_process(COMMAND bash -c "grep -Eo 'BOOST_DATA_TEST_CASE\\(\\w*' '${TEST_SUITE}' | cut -c 22-" OUTPUT_VARIABLE SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # get the test suite name from the *.cpp file
if (NOT "" STREQUAL "${SUITE_NAME}") # ignore empty lines
string(REPLACE "\n" ";" SN_LIST ${SUITE_NAME})
foreach(SN ${SN_LIST})
foreach(RUNTIME ${EOSIO_WASM_RUNTIMES})
get_test_property(${SN}_unit_test_${RUNTIME} LABELS TEST_LABEL)
if ("NOTFOUND" STREQUAL "${TEST_LABEL}") # prevent duplicates
add_wasmspec_test(NAME ${SN}_unit_test_${RUNTIME} COMMAND wasm_spec_test --run_test=${SN} --report_level=detailed --color_output -- --${RUNTIME})
# build list of tests to run during coverage testing
if(ctest_tests)
string(APPEND ctest_tests "|")
endif()
string(APPEND ctest_tests "${SN}_unit_test_${RUNTIME}")
endif()
endforeach()
endforeach(SN)
endif()
endforeach(TEST_SUITE)
set(ctest_tests "'${ctest_tests}' -j8") # surround test list string in apostrophies
# The following tests are known to take the longest, bump up their cost (priority) so that they'll run first
# even on fresh first time test runs before ctest auto-detects costs
foreach(RUNTIME ${EOSIO_WASM_RUNTIMES})
set_tests_properties(memory_trap_1_check_throw_1_unit_test_${RUNTIME} PROPERTIES COST 4000)
set_tests_properties(memory_trap_1_check_throw_2_unit_test_${RUNTIME} PROPERTIES COST 4000)
set_tests_properties(conversions_0_check_throw_unit_test_${RUNTIME} PROPERTIES COST 2500)
set_tests_properties(unreachable_0_check_throw_unit_test_${RUNTIME} PROPERTIES COST 2500)
set_tests_properties(f64_0_pass_unit_test_${RUNTIME} PROPERTIES COST 2500)
set_tests_properties(f32_0_pass_unit_test_${RUNTIME} PROPERTIES COST 2500)
set_tests_properties(f32_cmp_0_pass_unit_test_${RUNTIME} PROPERTIES COST 2500)
set_tests_properties(f64_cmp_0_pass_unit_test_${RUNTIME} PROPERTIES COST 2500)
endforeach()