test: allow running shared build without installing
[dpdk.git] / app / test / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation
3
4 if not get_option('tests')
5         subdir_done()
6 endif
7
8 test_sources = files('commands.c',
9         'packet_burst_generator.c',
10         'sample_packet_forward.c',
11         'test.c',
12         'test_acl.c',
13         'test_alarm.c',
14         'test_atomic.c',
15         'test_barrier.c',
16         'test_bitratestats.c',
17         'test_bpf.c',
18         'test_byteorder.c',
19         'test_cmdline.c',
20         'test_cmdline_cirbuf.c',
21         'test_cmdline_etheraddr.c',
22         'test_cmdline_ipaddr.c',
23         'test_cmdline_lib.c',
24         'test_cmdline_num.c',
25         'test_cmdline_portlist.c',
26         'test_cmdline_string.c',
27         'test_common.c',
28         'test_cpuflags.c',
29         'test_crc.c',
30         'test_cryptodev.c',
31         'test_cryptodev_asym.c',
32         'test_cryptodev_blockcipher.c',
33         'test_cycles.c',
34         'test_debug.c',
35         'test_distributor.c',
36         'test_distributor_perf.c',
37         'test_eal_flags.c',
38         'test_eal_fs.c',
39         'test_efd.c',
40         'test_efd_perf.c',
41         'test_errno.c',
42         'test_event_crypto_adapter.c',
43         'test_event_eth_rx_adapter.c',
44         'test_event_ring.c',
45         'test_event_eth_tx_adapter.c',
46         'test_event_timer_adapter.c',
47         'test_eventdev.c',
48         'test_external_mem.c',
49         'test_fbarray.c',
50         'test_func_reentrancy.c',
51         'test_flow_classify.c',
52         'test_hash.c',
53         'test_hash_functions.c',
54         'test_hash_multiwriter.c',
55         'test_hash_readwrite.c',
56         'test_hash_perf.c',
57         'test_hash_readwrite_lf.c',
58         'test_interrupts.c',
59         'test_ipsec.c',
60         'test_kni.c',
61         'test_kvargs.c',
62         'test_latencystats.c',
63         'test_link_bonding.c',
64         'test_link_bonding_mode4.c',
65         'test_link_bonding_rssconf.c',
66         'test_logs.c',
67         'test_lpm.c',
68         'test_lpm6.c',
69         'test_lpm6_perf.c',
70         'test_lpm_perf.c',
71         'test_malloc.c',
72         'test_mbuf.c',
73         'test_member.c',
74         'test_member_perf.c',
75         'test_memcpy.c',
76         'test_memcpy_perf.c',
77         'test_memory.c',
78         'test_mempool.c',
79         'test_mempool_perf.c',
80         'test_memzone.c',
81         'test_meter.c',
82         'test_metrics.c',
83         'test_mcslock.c',
84         'test_mp_secondary.c',
85         'test_pdump.c',
86         'test_per_lcore.c',
87         'test_pmd_perf.c',
88         'test_pmd_ring.c',
89         'test_pmd_ring_perf.c',
90         'test_power.c',
91         'test_power_cpufreq.c',
92         'test_power_kvm_vm.c',
93         'test_prefetch.c',
94         'test_rand_perf.c',
95         'test_rawdev.c',
96         'test_rcu_qsbr.c',
97         'test_rcu_qsbr_perf.c',
98         'test_reciprocal_division.c',
99         'test_reciprocal_division_perf.c',
100         'test_red.c',
101         'test_reorder.c',
102         'test_ring.c',
103         'test_ring_perf.c',
104         'test_rwlock.c',
105         'test_sched.c',
106         'test_service_cores.c',
107         'test_spinlock.c',
108         'test_stack.c',
109         'test_stack_perf.c',
110         'test_string_fns.c',
111         'test_table.c',
112         'test_table_acl.c',
113         'test_table_combined.c',
114         'test_table_pipeline.c',
115         'test_table_ports.c',
116         'test_table_tables.c',
117         'test_tailq.c',
118         'test_thash.c',
119         'test_timer.c',
120         'test_timer_perf.c',
121         'test_timer_racecond.c',
122         'test_timer_secondary.c',
123         'test_ticketlock.c',
124         'test_version.c',
125         'virtual_pmd.c'
126 )
127
128 test_deps = ['acl',
129         'bitratestats',
130         'bpf',
131         'cfgfile',
132         'cmdline',
133         'cryptodev',
134         'distributor',
135         'efd',
136         'ethdev',
137         'eventdev',
138         'flow_classify',
139         'hash',
140         'ipsec',
141         'latencystats',
142         'lpm',
143         'member',
144         'metrics',
145         'pipeline',
146         'port',
147         'rawdev',
148         'rcu',
149         'reorder',
150         'ring',
151         'stack',
152         'timer'
153 ]
154
155 fast_test_names = [
156         'acl_autotest',
157         'alarm_autotest',
158         'atomic_autotest',
159         'byteorder_autotest',
160         'cmdline_autotest',
161         'common_autotest',
162         'cpuflags_autotest',
163         'cycles_autotest',
164         'debug_autotest',
165         'eal_flags_c_opt_autotest',
166         'eal_flags_master_opt_autotest',
167         'eal_flags_n_opt_autotest',
168         'eal_flags_hpet_autotest',
169         'eal_flags_no_huge_autotest',
170         'eal_flags_w_opt_autotest',
171         'eal_flags_b_opt_autotest',
172         'eal_flags_vdev_opt_autotest',
173         'eal_flags_r_opt_autotest',
174         'eal_flags_mem_autotest',
175         'eal_flags_file_prefix_autotest',
176         'eal_flags_misc_autotest',
177         'eal_fs_autotest',
178         'errno_autotest',
179         'event_ring_autotest',
180         'func_reentrancy_autotest',
181         'flow_classify_autotest',
182         'hash_autotest',
183         'interrupt_autotest',
184         'logs_autotest',
185         'lpm_autotest',
186         'lpm6_autotest',
187         'malloc_autotest',
188         'mbuf_autotest',
189         'mcslock_autotest',
190         'memcpy_autotest',
191         'memory_autotest',
192         'mempool_autotest',
193         'memzone_autotest',
194         'meter_autotest',
195         'multiprocess_autotest',
196         'per_lcore_autotest',
197         'prefetch_autotest',
198         'rcu_qsbr_autotest',
199         'red_autotest',
200         'ring_autotest',
201         'ring_pmd_autotest',
202         'rwlock_test1_autotest',
203         'rwlock_rda_autotest',
204         'rwlock_rds_wrm_autotest',
205         'rwlock_rde_wro_autotest',
206         'sched_autotest',
207         'spinlock_autotest',
208         'stack_autotest',
209         'stack_lf_autotest',
210         'string_autotest',
211         'table_autotest',
212         'tailq_autotest',
213         'timer_autotest',
214         'user_delay_us',
215         'version_autotest',
216         'bitratestats_autotest',
217         'crc_autotest',
218         'delay_us_sleep_autotest',
219         'distributor_autotest',
220         'eventdev_common_autotest',
221         'fbarray_autotest',
222         'hash_readwrite_autotest',
223         'hash_readwrite_lf_autotest',
224         'ipsec_autotest',
225         'kni_autotest',
226         'kvargs_autotest',
227         'latencystats_autotest',
228         'member_autotest',
229         'metrics_autotest',
230         'pdump_autotest',
231         'power_cpufreq_autotest',
232         'power_autotest',
233         'power_kvm_vm_autotest',
234         'reorder_autotest',
235         'service_autotest',
236         'thash_autotest',
237 ]
238
239 perf_test_names = [
240         'ring_perf_autotest',
241         'mempool_perf_autotest',
242         'memcpy_perf_autotest',
243         'hash_perf_autotest',
244         'timer_perf_autotest',
245         'reciprocal_division',
246         'reciprocal_division_perf',
247         'lpm_perf_autotest',
248         'red_all',
249         'barrier_autotest',
250         'hash_multiwriter_autotest',
251         'timer_racecond_autotest',
252         'efd_autotest',
253         'hash_functions_autotest',
254         'member_perf_autotest',
255         'efd_perf_autotest',
256         'lpm6_perf_autotest',
257         'rcu_qsbr_perf_autotest',
258         'red_perf',
259         'distributor_perf_autotest',
260         'ring_pmd_perf_autotest',
261         'pmd_perf_autotest',
262         'stack_perf_autotest',
263         'stack_lf_perf_autotest',
264         'rand_perf_autotest',
265 ]
266
267 driver_test_names = [
268         'cryptodev_aesni_mb_autotest',
269         'cryptodev_aesni_gcm_autotest',
270         'cryptodev_dpaa_sec_autotest',
271         'cryptodev_dpaa2_sec_autotest',
272         'cryptodev_null_autotest',
273         'cryptodev_openssl_autotest',
274         'cryptodev_openssl_asym_autotest',
275         'cryptodev_qat_autotest',
276         'cryptodev_sw_armv8_autotest',
277         'cryptodev_sw_kasumi_autotest',
278         'cryptodev_sw_mvsam_autotest',
279         'cryptodev_sw_snow3g_autotest',
280         'cryptodev_sw_zuc_autotest',
281         'eventdev_selftest_octeontx',
282         'eventdev_selftest_sw',
283         'link_bonding_autotest',
284         'link_bonding_mode4_autotest',
285         'link_bonding_rssconf_autotest',
286         'rawdev_autotest',
287 ]
288
289 dump_test_names = [
290         'dump_struct_sizes',
291         'dump_mempool',
292         'dump_malloc_stats',
293         'dump_devargs',
294         'dump_log_types',
295         'dump_ring',
296         'dump_physmem',
297         'dump_memzone',
298 ]
299
300 # The following linkages are an exception to allow running the
301 # unit tests without requiring that the developer install the
302 # DPDK libraries.  Explicit linkage of drivers (plugin libraries)
303 # in applications should not be used.
304 if dpdk_conf.has('RTE_LIBRTE_RING_MEMPOOL')
305         test_deps += 'mempool_ring'
306 endif
307 if dpdk_conf.has('RTE_LIBRTE_STACK_MEMPOOL')
308         test_deps += 'mempool_stack'
309 endif
310 if dpdk_conf.has('RTE_LIBRTE_SKELETON_EVENTDEV_PMD')
311         test_deps += 'pmd_skeleton_event'
312 endif
313
314 # The following linkages of drivers are required because
315 # they are used via a driver-specific API.
316 if dpdk_conf.has('RTE_LIBRTE_BOND_PMD')
317         test_deps += 'pmd_bond'
318 endif
319 if dpdk_conf.has('RTE_LIBRTE_RING_PMD')
320         test_deps += 'pmd_ring'
321 endif
322
323 if dpdk_conf.has('RTE_LIBRTE_POWER')
324         test_deps += 'power'
325 endif
326 if dpdk_conf.has('RTE_LIBRTE_KNI')
327         test_deps += 'kni'
328 endif
329 if dpdk_conf.has('RTE_LIBRTE_PDUMP')
330         test_deps += 'pdump'
331 endif
332
333 cflags = machine_args
334 if cc.has_argument('-Wno-format-truncation')
335     cflags += '-Wno-format-truncation'
336 endif
337
338 # specify -D_GNU_SOURCE unconditionally
339 cflags += '-D_GNU_SOURCE'
340
341 test_dep_objs = []
342 if dpdk_conf.has('RTE_LIBRTE_COMPRESSDEV')
343         compress_test_dep = dependency('zlib', required: false)
344         if compress_test_dep.found()
345                 test_dep_objs += compress_test_dep
346                 test_sources += 'test_compressdev.c'
347                 test_deps += 'compressdev'
348                 fast_test_names += 'compressdev_autotest'
349         endif
350 endif
351
352 if dpdk_conf.has('RTE_LIBRTE_PMD_CRYPTO_SCHEDULER')
353         driver_test_names += 'cryptodev_scheduler_autotest'
354 endif
355
356 foreach d:test_deps
357         def_lib = get_option('default_library')
358         test_dep_objs += get_variable(def_lib + '_rte_' + d)
359 endforeach
360 test_dep_objs += cc.find_library('execinfo', required: false)
361
362 link_libs = []
363 if get_option('default_library') == 'static'
364         link_libs = dpdk_drivers
365 endif
366
367 dpdk_test = executable('dpdk-test',
368         test_sources,
369         link_whole: link_libs,
370         dependencies: test_dep_objs,
371         c_args: [cflags, '-DALLOW_EXPERIMENTAL_API'],
372         install_rpath: driver_install_path,
373         install: true)
374
375 # some perf tests (eg: memcpy perf autotest)take very long
376 # to complete, so timeout to 10 minutes
377 timeout_seconds = 600
378 timeout_seconds_fast = 10
379
380 # Retrieve the number of CPU cores, defaulting to 4.
381 num_cores = '0-3'
382 if host_machine.system() == 'linux'
383         num_cores = run_command('cat',
384                                 '/sys/devices/system/cpu/present'
385                                ).stdout().strip()
386 elif host_machine.system() == 'freebsd'
387         snum_cores = run_command('/sbin/sysctl', '-n',
388                                  'hw.ncpu').stdout().strip()
389         inum_cores = snum_cores.to_int() - 1
390         num_cores = '0-@0@'.format(inum_cores)
391 endif
392
393 num_cores_arg = '-l ' + num_cores
394
395 test_args = [num_cores_arg]
396 foreach arg : fast_test_names
397         if host_machine.system() == 'linux'
398                 test(arg, dpdk_test,
399                           env : ['DPDK_TEST=' + arg],
400                           args : test_args +
401                                  ['--file-prefix=@0@'.format(arg)],
402                 timeout : timeout_seconds_fast,
403                 is_parallel : false,
404                 suite : 'fast-tests')
405         else
406                 test(arg, dpdk_test,
407                         env : ['DPDK_TEST=' + arg],
408                         args : test_args,
409                 timeout : timeout_seconds_fast,
410                 is_parallel : false,
411                 suite : 'fast-tests')
412         endif
413 endforeach
414
415 foreach arg : perf_test_names
416         test(arg, dpdk_test,
417         env : ['DPDK_TEST=' + arg],
418         args : test_args,
419         timeout : timeout_seconds,
420         is_parallel : false,
421         suite : 'perf-tests')
422 endforeach
423
424 foreach arg : driver_test_names
425         test(arg, dpdk_test,
426                 env : ['DPDK_TEST=' + arg],
427                 args : test_args,
428                 timeout : timeout_seconds,
429                 is_parallel : false,
430                 suite : 'driver-tests')
431 endforeach
432
433 foreach arg : dump_test_names
434         test(arg, dpdk_test,
435                 env : ['DPDK_TEST=' + arg],
436                 args : test_args,
437                 timeout : timeout_seconds,
438                 is_parallel : false,
439                 suite : 'debug-tests')
440 endforeach
441