@@ -65,6 +65,7 @@ option(TONLIB_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TonLib API.")
6565option (TON_USE_ASAN "Use \" ON\" to enable AddressSanitizer." OFF )
6666option (TON_USE_TSAN "Use \" ON\" to enable ThreadSanitizer." OFF )
6767option (TON_USE_UBSAN "Use \" ON\" to enable UndefinedBehaviorSanitizer." OFF )
68+ option (TON_USE_COVERAGE "Use \" ON\" to enable code coverage with gcov." OFF )
6869set (TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=" )
6970
7071option (TON_PRINT_BACKTRACE_ON_CRASH "Attempt to print a backtrace when a fatal signal is caught" ON )
@@ -266,7 +267,7 @@ elseif (CLANG OR GCC)
266267 set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL" )
267268 endif ()
268269 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
269- if (NOT TON_USE_ASAN AND NOT TON_USE_TSAN AND NOT MEMPROF)
270+ if (NOT TON_USE_ASAN AND NOT TON_USE_TSAN AND NOT TON_USE_COVERAGE AND NOT MEMPROF)
270271 if (NOT USE_EMSCRIPTEN)
271272 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--exclude-libs,ALL" )
272273 endif ()
@@ -350,6 +351,23 @@ if (TON_USE_UBSAN)
350351 add_compile_options (-fsanitize=undefined)
351352 add_link_options (-fsanitize=undefined)
352353endif ()
354+ if (TON_USE_COVERAGE)
355+ add_cxx_compiler_flag("-fprofile-arcs" )
356+ add_cxx_compiler_flag("-ftest-coverage" )
357+ add_cxx_compiler_flag("--coverage" )
358+ add_cxx_compiler_flag("-O0" )
359+ add_cxx_compiler_flag("-g" )
360+ add_cxx_compiler_flag("-fno-inline" )
361+ add_cxx_compiler_flag("-fno-inline-small-functions" )
362+ add_cxx_compiler_flag("-fno-default-inline" )
363+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage --coverage" )
364+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage --coverage" )
365+ endif ()
366+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
367+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
368+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
369+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
370+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finstrument-functions")
353371
354372#Compilation database
355373set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
@@ -562,6 +580,7 @@ add_test(test-cells test-cells ${TEST_OPTIONS})
562580add_test (test -smartcont test -smartcont)
563581add_test (test -net test -net)
564582add_test (test -actors test -tdactor)
583+ add_test (test -actors-coro tdactor/test /test -coro)
565584add_test (test -emulator test -emulator)
566585
567586#BEGIN tonlib
0 commit comments