Committing TBB 2019 Update 9 source code
[platform/upstream/tbb.git] / build / Makefile.test
1 # Copyright (c) 2005-2019 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
15 #------------------------------------------------------------------------------
16 # Define rules for making the TBB tests.
17 #------------------------------------------------------------------------------
18 .PHONY: default test_tbb_plain test_tbb_openmp test_tbb_cilk test_tbb_old clean
19
20 default: test_tbb_plain test_tbb_openmp test_tbb_cilk test_tbb_old
21
22 tbb_root ?= $(TBBROOT)
23 BUILDING_PHASE=1
24 TEST_RESOURCE = $(TBB.RES)
25 TESTFILE=test
26 include $(tbb_root)/build/common.inc
27 DEBUG_SUFFIX=$(findstring _debug,$(call cross_cfg,_$(cfg)))
28
29 #------------------------------------------------------------
30 # Define static pattern rules dealing with .cpp source files
31 #------------------------------------------------------------
32
33 VPATH = $(tbb_root)/src/tbb/$(ASSEMBLY_SOURCE) $(tbb_root)/src/tbb $(tbb_root)/src/rml/client $(tbb_root)/src/old $(tbb_root)/src/test $(tbb_root)/src/perf
34 CPLUS_FLAGS += $(if $(crosstest),$(DEFINE_KEY)__TBB_NO_IMPLICIT_LINKAGE=1) \
35                $(if $(no_exceptions),$(DEFINE_KEY)__TBB_TEST_NO_EXCEPTIONS=1) \
36                $(if $(LINK_TBB.LIB),$(DEFINE_KEY)TEST_USES_TBB=1)
37
38 TEST_PREREQUISITE+=$(TBB.LIB)
39 LINK_FILES+=$(LINK_TBB.LIB)
40
41 ifdef use_proxy
42     USE_PROXY_FLAG = $(DEFINE_KEY)HARNESS_USE_RUNTIME_LOADER
43     CPLUS_FLAGS += $(USE_PROXY_FLAG)
44     LINK_TBB.LIB = $(PROXY.LIB)
45     LIBS += $(LIBDL)
46 endif
47
48 TEST_SUFFIXES=secondary compiler_builtins pic
49 include $(tbb_root)/build/common_rules.inc
50
51 # Rules for the tests, which use TBB in a dynamically loadable library
52 test_model_plugin.$(TEST_EXT): LINK_TBB.LIB =
53 test_model_plugin.$(TEST_EXT): CPLUS_FLAGS := $(CPLUS_FLAGS:$(USE_PROXY_FLAG)=)
54 test_model_plugin.$(TEST_EXT): LIBS += $(LIBDL)
55 ifneq (,$(DYLIB_KEY))
56 test_model_plugin.$(TEST_EXT): test_model_plugin_dll.$(DLL)
57 endif
58
59 # tbb_misc.$(OBJ) has to be specified here (instead of harness_inject_scheduler.h) because it carries dependency on version_string.ver
60 SCHEDULER_DEPENDENCIES = $(TBB_ASM.OBJ) tbb_misc.$(OBJ)
61
62 # These executables don't depend on the TBB library, but include core .cpp files directly
63 SCHEDULER_DIRECTLY_INCLUDED = test_task_leaks.$(TEST_EXT) \
64     test_task_assertions.$(TEST_EXT) \
65     test_fast_random.$(TEST_EXT) \
66     test_global_control_whitebox.$(TEST_EXT) \
67     test_concurrent_queue_whitebox.$(TEST_EXT)
68
69 # Necessary to locate version_string.ver referenced from directly included tbb_misc.cpp
70 INCLUDES += $(INCLUDE_KEY). $(INCLUDE_TEST_HEADERS)
71
72 $(SCHEDULER_DIRECTLY_INCLUDED): CPLUS_FLAGS += $(DSE_KEY)
73 $(SCHEDULER_DIRECTLY_INCLUDED): WARNING_KEY += $(WARNING_SUPPRESS)
74 $(SCHEDULER_DIRECTLY_INCLUDED): LIBS += $(LIBDL)
75 #tbb.lib must not be linked to scheduler white box tests in order to not violate ODR
76 $(SCHEDULER_DIRECTLY_INCLUDED): LINK_TBB.LIB =
77 $(SCHEDULER_DIRECTLY_INCLUDED): LINK_FILES += $(SCHEDULER_DEPENDENCIES)
78 $(SCHEDULER_DIRECTLY_INCLUDED): $(SCHEDULER_DEPENDENCIES)
79
80 # test_tbb_header detects "multiple definition" linker error using the test that covers the whole library
81 TWICE_LINKED_TESTS = test_tbb_header.$(TEST_EXT) \
82                      test_concurrent_unordered_set.$(TEST_EXT)
83
84 %_secondary.$(OBJ): CPLUS_FLAGS+=$(DEFINE_KEY)__TBB_TEST_SECONDARY=1
85
86 # Detecting "multiple definition" linker error using the test that covers the whole library
87 $(TWICE_LINKED_TESTS): %.$(TEST_EXT): %.$(OBJ) %_secondary.$(OBJ)
88 $(TWICE_LINKED_TESTS): LINK_FILES+=$(@:.$(TEST_EXT)=_secondary.$(OBJ))
89
90 # Checks that TBB works correctly in position independent code
91 %_pic.$(OBJ): CPLUS_FLAGS+=$(PIC_KEY)
92 %_pic.$(OBJ): CPLUS_FLAGS+=$(DEFINE_KEY)__TBB_TEST_PIC=1
93
94 # Test of generic gcc port and icc intrinsics port
95 %_compiler_builtins.$(TEST_EXT): LINK_TBB.LIB =
96 %_compiler_builtins.$(OBJ): CPLUS_FLAGS+=$(DEFINE_KEY)__TBB_TEST_BUILTINS=1 $(DEFINE_KEY)TBB_USE_ASSERT=0
97
98 # dynamic_link tests don't depend on the TBB library
99 test_dynamic_link%.$(TEST_EXT): LINK_TBB.LIB =
100 test_dynamic_link.$(TEST_EXT): LIBS += $(LIBDL)
101
102 # Resolving issue with the number of sections that an object file can contain
103 ifneq (,$(BIGOBJ_KEY))
104 TEST_BIGOBJ = test_opencl_node.$(TEST_EXT)      \
105     test_atomic.$(TEST_EXT)                     \
106     test_concurrent_hash_map.$(TEST_EXT)        \
107     test_concurrent_set.$(TEST_EXT)             \
108     test_concurrent_map.$(TEST_EXT)             \
109     test_concurrent_unordered_set.$(TEST_EXT)   \
110     test_concurrent_unordered_map.$(TEST_EXT)   \
111     test_join_node_key_matching.$(TEST_EXT)     \
112     test_join_node_msg_key_matching.$(TEST_EXT) \
113     test_join_node.$(TEST_EXT)
114 $(TEST_BIGOBJ): override CXXFLAGS += $(BIGOBJ_KEY)
115 endif
116
117 # TODO: remove repetition of .$(TEST_EXT) in the list below
118 # The main list of TBB tests
119 TEST_TBB_PLAIN.EXE = test_assembly.$(TEST_EXT)   \
120         test_global_control.$(TEST_EXT)              \
121         test_tbb_fork.$(TEST_EXT)                    \
122         test_assembly_compiler_builtins.$(TEST_EXT)  \
123         test_aligned_space.$(TEST_EXT)               \
124         test_atomic.$(TEST_EXT)                      \
125         test_atomic_pic.$(TEST_EXT)                  \
126         test_atomic_compiler_builtins.$(TEST_EXT)    \
127         test_blocked_range.$(TEST_EXT)               \
128         test_blocked_range2d.$(TEST_EXT)             \
129         test_blocked_range3d.$(TEST_EXT)             \
130         test_blocked_rangeNd.$(TEST_EXT)             \
131         test_concurrent_queue.$(TEST_EXT)            \
132         test_concurrent_vector.$(TEST_EXT)           \
133         test_concurrent_unordered_set.$(TEST_EXT)    \
134         test_concurrent_unordered_map.$(TEST_EXT)    \
135         test_concurrent_hash_map.$(TEST_EXT)         \
136         test_concurrent_set.$(TEST_EXT)              \
137         test_concurrent_map.$(TEST_EXT)              \
138         test_enumerable_thread_specific.$(TEST_EXT)  \
139         test_handle_perror.$(TEST_EXT)               \
140         test_halt.$(TEST_EXT)                        \
141         test_model_plugin.$(TEST_EXT)                \
142         test_mutex.$(TEST_EXT)                       \
143         test_mutex_native_threads.$(TEST_EXT)        \
144         test_rwm_upgrade_downgrade.$(TEST_EXT)       \
145         test_cache_aligned_allocator.$(TEST_EXT)     \
146         test_cache_aligned_allocator_STL.$(TEST_EXT) \
147         test_parallel_for.$(TEST_EXT)                \
148         test_parallel_reduce.$(TEST_EXT)             \
149         test_parallel_sort.$(TEST_EXT)               \
150         test_parallel_scan.$(TEST_EXT)               \
151         test_parallel_while.$(TEST_EXT)              \
152         test_parallel_do.$(TEST_EXT)                 \
153         test_pipeline.$(TEST_EXT)                    \
154         test_pipeline_with_tbf.$(TEST_EXT)           \
155         test_parallel_pipeline.$(TEST_EXT)           \
156         test_lambda.$(TEST_EXT)                      \
157         test_task_scheduler_init.$(TEST_EXT)         \
158         test_task_scheduler_observer.$(TEST_EXT)     \
159         test_task.$(TEST_EXT)                        \
160         test_tbb_thread.$(TEST_EXT)                  \
161         test_std_thread.$(TEST_EXT)                  \
162         test_tick_count.$(TEST_EXT)                  \
163         test_inits_loop.$(TEST_EXT)                  \
164         test_yield.$(TEST_EXT)                       \
165         test_eh_tasks.$(TEST_EXT)                    \
166         test_eh_algorithms.$(TEST_EXT)               \
167         test_eh_flow_graph.$(TEST_EXT)               \
168         test_parallel_invoke.$(TEST_EXT)             \
169         test_task_group.$(TEST_EXT)                  \
170         test_ittnotify.$(TEST_EXT)                   \
171         test_parallel_for_each.$(TEST_EXT)           \
172         test_tbb_header.$(TEST_EXT)                  \
173         test_combinable.$(TEST_EXT)                  \
174         test_task_auto_init.$(TEST_EXT)              \
175         test_task_arena.$(TEST_EXT)                  \
176         test_concurrent_monitor.$(TEST_EXT)          \
177         test_semaphore.$(TEST_EXT)                   \
178         test_critical_section.$(TEST_EXT)            \
179         test_reader_writer_lock.$(TEST_EXT)          \
180         test_tbb_condition_variable.$(TEST_EXT)      \
181         test_intrusive_list.$(TEST_EXT)              \
182         test_concurrent_priority_queue.$(TEST_EXT)   \
183         test_task_priority.$(TEST_EXT)               \
184         test_task_enqueue.$(TEST_EXT)                \
185         test_task_steal_limit.$(TEST_EXT)            \
186         test_hw_concurrency.$(TEST_EXT)              \
187         test_fp.$(TEST_EXT)                          \
188         test_tuple.$(TEST_EXT)                       \
189         test_flow_graph.$(TEST_EXT)                  \
190         test_broadcast_node.$(TEST_EXT)              \
191         test_continue_node.$(TEST_EXT)               \
192         test_function_node.$(TEST_EXT)               \
193         test_limiter_node.$(TEST_EXT)                \
194         test_join_node.$(TEST_EXT)                   \
195         test_join_node_key_matching.$(TEST_EXT)      \
196         test_join_node_msg_key_matching.$(TEST_EXT)  \
197         test_buffer_node.$(TEST_EXT)                 \
198         test_queue_node.$(TEST_EXT)                  \
199         test_priority_queue_node.$(TEST_EXT)         \
200         test_sequencer_node.$(TEST_EXT)              \
201         test_source_node.$(TEST_EXT)                 \
202         test_overwrite_node.$(TEST_EXT)              \
203         test_write_once_node.$(TEST_EXT)             \
204         test_indexer_node.$(TEST_EXT)                \
205         test_multifunction_node.$(TEST_EXT)          \
206         test_split_node.$(TEST_EXT)                  \
207         test_static_assert.$(TEST_EXT)               \
208         test_aggregator.$(TEST_EXT)                  \
209         test_concurrent_lru_cache.$(TEST_EXT)        \
210         test_examples_common_utility.$(TEST_EXT)     \
211         test_dynamic_link.$(TEST_EXT)                \
212         test_parallel_for_vectorization.$(TEST_EXT)  \
213         test_tagged_msg.$(TEST_EXT)                  \
214         test_partitioner_whitebox.$(TEST_EXT)        \
215         test_flow_graph_whitebox.$(TEST_EXT)         \
216         test_composite_node.$(TEST_EXT)              \
217         test_async_node.$(TEST_EXT)                  \
218         test_async_msg.$(TEST_EXT)                   \
219         test_resumable_tasks.$(TEST_EXT)             \
220         test_tbb_version.$(TEST_EXT)                 # insert new files right above
221
222 # These tests depend on other technologies
223 TEST_TBB_SPECIAL.EXE = test_openmp.$(TEST_EXT) \
224     test_cilk_interop.$(TEST_EXT)              \
225     test_opencl_node.$(TEST_EXT)
226
227 # skip mode_plugin for now
228 skip_tests += test_model_plugin
229
230 ifdef OPENMP_FLAG
231 test_openmp.$(TEST_EXT): CPLUS_FLAGS += $(OPENMP_FLAG)
232
233 test_tbb_openmp: $(TEST_PREREQUISITE) test_openmp.$(TEST_EXT)
234         $(run_cmd) ./test_openmp.$(TEST_EXT) 1:4
235 else
236 test_tbb_openmp:
237         @echo "OpenMP is not available"
238 endif
239
240 ifdef CILK_AVAILABLE
241 # Workaround on cilkrts linkage known issue (see Intel(R) C++ Composer XE 2011 Release Notes)
242 # The issue reveals itself if a version of binutils is prior to 2.17
243 ifeq (linux_icc,$(tbb_os)_$(compiler))
244 test_cilk_interop.$(TEST_EXT): LIBS += -lcilkrts
245 endif
246 test_tbb_cilk: test_cilk_interop.$(TEST_EXT)
247         $(run_cmd) ./test_cilk_interop.$(TEST_EXT) $(args)
248 else
249 test_tbb_cilk:
250         @echo "Intel(R) Cilk(TM) Plus is not available"
251 endif
252
253 test_opencl_node.$(TEST_EXT): LIBS += $(OPENCL.LIB)
254
255 $(TEST_TBB_PLAIN.EXE) $(TEST_TBB_SPECIAL.EXE): WARNING_KEY += $(TEST_WARNING_KEY)
256
257 # Run tests that are in SCHEDULER_DIRECTLY_INCLUDED and TEST_TBB_PLAIN.EXE but not in skip_tests (which is specified by user)
258 TESTS_TO_RUN := $(filter-out $(addsuffix .$(TEST_EXT),$(skip_tests)),$(TEST_TBB_PLAIN.EXE) $(SCHEDULER_DIRECTLY_INCLUDED))
259
260 # This definition intentionally consists of two blank lines
261 define eol
262
263
264 endef
265
266 # First build the targets, then run them
267 # Form a list of commands separated with end of line
268 # Note that usually run_cmd is empty, and tests run directly
269
270 test_tbb_plain: $(TEST_PREREQUISITE) $(TESTS_TO_RUN)
271         $(foreach test, $(TESTS_TO_RUN), $(run_cmd) ./$(test) $(args) $(eol))
272
273
274 # For deprecated files, we don't mind warnings etc., thus compilation rules are most relaxed
275 CPLUS_FLAGS_DEPRECATED = $(DEFINE_KEY)__TBB_TEST_DEPRECATED=1 $(subst $(WARNING_KEY),,$(CPLUS_FLAGS)) $(WARNING_SUPPRESS) $(INCLUDE_KEY)$(tbb_root)/src/test
276 TEST_TBB_OLD.OBJ = test_concurrent_vector_v2.$(OBJ) test_concurrent_queue_v2.$(OBJ) test_mutex_v2.$(OBJ) test_task_scheduler_observer_v3.$(OBJ)
277
278 $(TEST_TBB_OLD.OBJ): CPLUS_FLAGS := $(CPLUS_FLAGS_DEPRECATED)
279
280 TEST_TBB_OLD.EXE = $(subst .$(OBJ),.$(TEST_EXT),$(TEST_TBB_OLD.OBJ))
281
282 ifeq (,$(NO_LEGACY_TESTS))
283 test_tbb_old: $(TEST_PREREQUISITE) $(TEST_TBB_OLD.EXE)
284         $(run_cmd) ./test_concurrent_vector_v2.$(TEST_EXT) $(args) 1:4
285         $(run_cmd) ./test_concurrent_queue_v2.$(TEST_EXT) $(args) 1:4
286         $(run_cmd) ./test_mutex_v2.$(TEST_EXT) $(args) 1
287         $(run_cmd) ./test_mutex_v2.$(TEST_EXT) $(args) 2
288         $(run_cmd) ./test_mutex_v2.$(TEST_EXT) $(args) 4
289         $(run_cmd) ./test_task_scheduler_observer_v3.$(TEST_EXT) $(args) 1:4
290 else
291 test_tbb_old:
292         @echo Legacy tests skipped
293 endif
294
295 ifneq (,$(codecov))
296 codecov_gen:
297         profmerge
298         codecov $(if $(findstring -,$(codecov)),$(codecov),) -demang -comp $(tbb_root)/build/codecov.txt
299 endif
300
301 time_%: time_%.$(TEST_EXT) $(TEST_PREREQUISITE)
302         $(run_cmd) ./$< $(args)
303
304
305 # for some reason, "perf_%.$(TEST_EXT): perf_dll.$(DLL)" does not work TODO: find out how to apply pattern here
306 perf_sched.$(TEST_EXT): perf_dll.$(DLL)
307 perf_%.$(TEST_EXT): TEST_LIBS = perf_dll.$(LIBEXT)
308 perf_%: perf_%.$(TEST_EXT) $(TEST_PREREQUISITE)
309         $(run_cmd) ./$< $(args)
310
311 clean_%:
312         $(RM) $*.$(OBJ) $*.exe $*.$(DLL) $*.$(LIBEXT) $*.res $*.map $*.ilk $*.pdb $*.exp $*.*manifest $*.tmp $*.d *.ver
313
314 clean:
315         $(RM) *.$(OBJ) *.exe *.$(DLL) *.$(LIBEXT) *.res *.map *.ilk *.pdb *.exp *.manifest *.tmp *.d pgopti.* *.dyn core core.*[0-9][0-9] *.ver
316
317 # Include automatically generated dependencies
318 -include *.d