1# Copyright (c) 2020-2021 Intel Corporation 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15option(TBB_VALGRIND_MEMCHECK "Enable scan for memory leaks using Valgrind" OFF) 16 17if (NOT TBB_VALGRIND_MEMCHECK) 18 return() 19endif() 20 21add_custom_target(memcheck-all 22 COMMENT "Run memcheck on all tests") 23 24find_program(VALGRIND_EXE valgrind) 25 26if (NOT VALGRIND_EXE) 27 message(FATAL_ERROR "Valgrind executable is not found, add tool to PATH or turn off TBB_VALGRIND_MEMCHECK") 28else() 29 message(STATUS "Found Valgrind to run memory leak scan") 30endif() 31 32file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/memcheck) 33 34function(_tbb_run_memcheck test_target) 35 set(target_name memcheck-${test_target}) 36 add_custom_target(${target_name} 37 COMMAND ${VALGRIND_EXE} --leak-check=full --show-leak-kinds=all --log-file=${CMAKE_BINARY_DIR}/memcheck/${target_name}.log -v $<TARGET_FILE:${test_target}>) 38 add_dependencies(memcheck-all ${target_name}) 39endfunction() 40 41add_custom_target(memcheck-short 42 COMMENT "Run memcheck scan on specified list") 43 44# List of reasonable and quick enough tests to use in automated memcheck 45add_dependencies(memcheck-short 46 memcheck-test_allocators 47 memcheck-test_arena_constraints 48 memcheck-test_dynamic_link 49 memcheck-test_concurrent_lru_cache 50 memcheck-conformance_concurrent_unordered_map 51 memcheck-conformance_concurrent_unordered_set 52 memcheck-conformance_concurrent_map 53 memcheck-conformance_concurrent_set 54 memcheck-conformance_concurrent_priority_queue 55 memcheck-conformance_concurrent_vector 56 memcheck-conformance_concurrent_queue 57 memcheck-conformance_concurrent_hash_map 58 memcheck-test_parallel_for 59 memcheck-test_parallel_for_each 60 memcheck-test_parallel_reduce 61 memcheck-test_parallel_sort 62 memcheck-test_parallel_invoke 63 memcheck-test_parallel_scan 64 memcheck-test_parallel_pipeline 65 memcheck-test_eh_algorithms 66 memcheck-test_task_group 67 memcheck-test_task_arena 68 memcheck-test_enumerable_thread_specific 69 memcheck-test_resumable_tasks 70 memcheck-conformance_mutex 71 memcheck-test_function_node 72 memcheck-test_multifunction_node 73 memcheck-test_broadcast_node 74 memcheck-test_buffer_node 75 memcheck-test_composite_node 76 memcheck-test_continue_node 77 memcheck-test_eh_flow_graph 78 memcheck-test_flow_graph 79 memcheck-test_flow_graph_priorities 80 memcheck-test_flow_graph_whitebox 81 memcheck-test_indexer_node 82 memcheck-test_join_node 83 memcheck-test_join_node_key_matching 84 memcheck-test_join_node_msg_key_matching 85 memcheck-test_priority_queue_node 86 memcheck-test_sequencer_node 87 memcheck-test_split_node 88 memcheck-test_tagged_msg 89 memcheck-test_overwrite_node 90 memcheck-test_write_once_node 91 memcheck-test_async_node 92 memcheck-test_input_node 93 memcheck-test_profiling 94 memcheck-test_concurrent_queue_whitebox 95 memcheck-test_intrusive_list 96 memcheck-test_semaphore 97 memcheck-test_environment_whitebox 98 memcheck-test_handle_perror 99 memcheck-test_hw_concurrency 100 memcheck-test_eh_thread 101 memcheck-test_global_control 102 memcheck-test_task 103 memcheck-test_concurrent_monitor 104) 105