test/threads: add unit test
[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(
9         'commands.c',
10         'packet_burst_generator.c',
11         'test.c',
12         'test_acl.c',
13         'test_alarm.c',
14         'test_atomic.c',
15         'test_barrier.c',
16         'test_bitops.c',
17         'test_bitmap.c',
18         'test_bpf.c',
19         'test_byteorder.c',
20         'test_cksum.c',
21         'test_cmdline.c',
22         'test_cmdline_cirbuf.c',
23         'test_cmdline_etheraddr.c',
24         'test_cmdline_ipaddr.c',
25         'test_cmdline_lib.c',
26         'test_cmdline_num.c',
27         'test_cmdline_portlist.c',
28         'test_cmdline_string.c',
29         'test_common.c',
30         'test_cpuflags.c',
31         'test_crc.c',
32         'test_cryptodev.c',
33         'test_cryptodev_asym.c',
34         'test_cryptodev_blockcipher.c',
35         'test_cryptodev_security_ipsec.c',
36         'test_cryptodev_security_pdcp.c',
37         'test_cycles.c',
38         'test_debug.c',
39         'test_devargs.c',
40         'test_distributor.c',
41         'test_distributor_perf.c',
42         'test_dmadev.c',
43         'test_dmadev_api.c',
44         'test_eal_flags.c',
45         'test_eal_fs.c',
46         'test_efd.c',
47         'test_efd_perf.c',
48         'test_errno.c',
49         'test_ethdev_link.c',
50         'test_event_crypto_adapter.c',
51         'test_event_eth_rx_adapter.c',
52         'test_event_ring.c',
53         'test_event_timer_adapter.c',
54         'test_eventdev.c',
55         'test_external_mem.c',
56         'test_fbarray.c',
57         'test_fib.c',
58         'test_fib_perf.c',
59         'test_fib6.c',
60         'test_fib6_perf.c',
61         'test_func_reentrancy.c',
62         'test_graph.c',
63         'test_graph_perf.c',
64         'test_hash.c',
65         'test_hash_functions.c',
66         'test_hash_multiwriter.c',
67         'test_hash_readwrite.c',
68         'test_hash_perf.c',
69         'test_hash_readwrite_lf_perf.c',
70         'test_interrupts.c',
71         'test_ipfrag.c',
72         'test_ipsec.c',
73         'test_ipsec_sad.c',
74         'test_ipsec_perf.c',
75         'test_kni.c',
76         'test_kvargs.c',
77         'test_lcores.c',
78         'test_logs.c',
79         'test_lpm.c',
80         'test_lpm6.c',
81         'test_lpm6_perf.c',
82         'test_lpm_perf.c',
83         'test_malloc.c',
84         'test_malloc_perf.c',
85         'test_mbuf.c',
86         'test_member.c',
87         'test_member_perf.c',
88         'test_memcpy.c',
89         'test_memcpy_perf.c',
90         'test_memory.c',
91         'test_mempool.c',
92         'test_mempool_perf.c',
93         'test_memzone.c',
94         'test_meter.c',
95         'test_mcslock.c',
96         'test_mp_secondary.c',
97         'test_per_lcore.c',
98         'test_pflock.c',
99         'test_pmd_perf.c',
100         'test_power.c',
101         'test_power_cpufreq.c',
102         'test_power_kvm_vm.c',
103         'test_prefetch.c',
104         'test_rand_perf.c',
105         'test_rawdev.c',
106         'test_rcu_qsbr.c',
107         'test_rcu_qsbr_perf.c',
108         'test_reciprocal_division.c',
109         'test_reciprocal_division_perf.c',
110         'test_red.c',
111         'test_pie.c',
112         'test_reorder.c',
113         'test_rib.c',
114         'test_rib6.c',
115         'test_ring.c',
116         'test_ring_mpmc_stress.c',
117         'test_ring_hts_stress.c',
118         'test_ring_mt_peek_stress.c',
119         'test_ring_mt_peek_stress_zc.c',
120         'test_ring_perf.c',
121         'test_ring_rts_stress.c',
122         'test_ring_st_peek_stress.c',
123         'test_ring_st_peek_stress_zc.c',
124         'test_ring_stress.c',
125         'test_rwlock.c',
126         'test_sched.c',
127         'test_security.c',
128         'test_service_cores.c',
129         'test_spinlock.c',
130         'test_stack.c',
131         'test_stack_perf.c',
132         'test_string_fns.c',
133         'test_tailq.c',
134         'test_thash.c',
135         'test_thash_perf.c',
136         'test_threads.c',
137         'test_timer.c',
138         'test_timer_perf.c',
139         'test_timer_racecond.c',
140         'test_timer_secondary.c',
141         'test_ticketlock.c',
142         'test_trace.c',
143         'test_trace_register.c',
144         'test_trace_perf.c',
145         'test_version.c',
146         'virtual_pmd.c',
147 )
148
149 test_deps = enabled_libs
150 # as well as libs, the pci and vdev bus drivers are needed for a lot of tests
151 test_deps += ['bus_pci', 'bus_vdev']
152
153 # Each test is marked with flags:
154 # - the first flag indicates whether the test can run in no-huge mode,
155 # - the second flag indicates whether the test can run with ASan enabled,
156 fast_tests = [
157         ['acl_autotest', true, true],
158         ['atomic_autotest', false, true],
159         ['bitmap_autotest', true, true],
160         ['bpf_autotest', true, true],
161         ['bpf_convert_autotest', true, true],
162         ['bitops_autotest', true, true],
163         ['byteorder_autotest', true, true],
164         ['cksum_autotest', true, true],
165         ['cmdline_autotest', true, true],
166         ['common_autotest', true, true],
167         ['cpuflags_autotest', true, true],
168         ['debug_autotest', true, true],
169         ['devargs_autotest', true, true],
170         ['eal_flags_c_opt_autotest', false, false],
171         ['eal_flags_main_opt_autotest', false, false],
172         ['eal_flags_n_opt_autotest', false, false],
173         ['eal_flags_hpet_autotest', false, false],
174         ['eal_flags_no_huge_autotest', false, false],
175         ['eal_flags_a_opt_autotest', false, false],
176         ['eal_flags_b_opt_autotest', false, false],
177         ['eal_flags_vdev_opt_autotest', false, false],
178         ['eal_flags_r_opt_autotest', false, false],
179         ['eal_flags_mem_autotest', false, false],
180         ['eal_flags_file_prefix_autotest', false, false],
181         ['eal_flags_misc_autotest', false, false],
182         ['eal_fs_autotest', true, true],
183         ['errno_autotest', true, true],
184         ['ethdev_link_status', true, true],
185         ['event_ring_autotest', true, true],
186         ['fib_autotest', true, true],
187         ['fib6_autotest', true, true],
188         ['func_reentrancy_autotest', false, true],
189         ['hash_autotest', true, true],
190         ['interrupt_autotest', true, true],
191         ['ipfrag_autotest', false, true],
192         ['lcores_autotest', true, true],
193         ['logs_autotest', true, true],
194         ['lpm_autotest', true, true],
195         ['lpm6_autotest', true, true],
196         ['malloc_autotest', false, true],
197         ['mbuf_autotest', false, true],
198         ['mcslock_autotest', false, true],
199         ['memcpy_autotest', true, true],
200         ['memory_autotest', false, true],
201         ['mempool_autotest', false, true],
202         ['memzone_autotest', false, true],
203         ['meter_autotest', true, true],
204         ['multiprocess_autotest', false, false],
205         ['per_lcore_autotest', true, true],
206         ['pflock_autotest', true, true],
207         ['prefetch_autotest', true, true],
208         ['rcu_qsbr_autotest', true, true],
209         ['pie_autotest', true, true],
210         ['rib_autotest', true, true],
211         ['rib6_autotest', true, true],
212         ['ring_autotest', true, true],
213         ['rwlock_test1_autotest', true, true],
214         ['rwlock_rda_autotest', true, true],
215         ['rwlock_rds_wrm_autotest', true, true],
216         ['rwlock_rde_wro_autotest', true, true],
217         ['sched_autotest', true, true],
218         ['security_autotest', false, true],
219         ['spinlock_autotest', true, true],
220         ['stack_autotest', false, true],
221         ['stack_lf_autotest', false, true],
222         ['string_autotest', true, true],
223         ['tailq_autotest', true, true],
224         ['ticketlock_autotest', true, true],
225         ['timer_autotest', false, true],
226         ['user_delay_us', true, true],
227         ['version_autotest', true, true],
228         ['crc_autotest', true, true],
229         ['distributor_autotest', false, true],
230         ['eventdev_common_autotest', true, true],
231         ['fbarray_autotest', true, true],
232         ['hash_readwrite_func_autotest', false, true],
233         ['ipsec_autotest', true, true],
234         ['kni_autotest', false, true],
235         ['kvargs_autotest', true, true],
236         ['member_autotest', true, true],
237         ['power_cpufreq_autotest', false, true],
238         ['power_autotest', true, true],
239         ['power_kvm_vm_autotest', false, true],
240         ['reorder_autotest', true, true],
241         ['service_autotest', true, true],
242         ['thash_autotest', true, true],
243         ['threads_autotest', true, true],
244         ['trace_autotest', true, true],
245 ]
246
247 # Tests known to have issues or which don't belong in other tests lists.
248 extra_test_names = [
249         'alarm_autotest', # ee00af60170b ("test: remove strict timing requirements some tests")
250         'cycles_autotest', # ee00af60170b ("test: remove strict timing requirements some tests")
251         'delay_us_sleep_autotest', # ee00af60170b ("test: remove strict timing requirements some tests")
252         'red_autotest', # https://bugs.dpdk.org/show_bug.cgi?id=826
253 ]
254
255 perf_test_names = [
256         'ring_perf_autotest',
257         'malloc_perf_autotest',
258         'mempool_perf_autotest',
259         'memcpy_perf_autotest',
260         'hash_perf_autotest',
261         'timer_perf_autotest',
262         'reciprocal_division',
263         'reciprocal_division_perf',
264         'lpm_perf_autotest',
265         'rib_slow_autotest',
266         'fib_slow_autotest',
267         'fib_perf_autotest',
268         'red_all',
269         'pie_all',
270         'barrier_autotest',
271         'hash_multiwriter_autotest',
272         'timer_racecond_autotest',
273         'efd_autotest',
274         'hash_functions_autotest',
275         'member_perf_autotest',
276         'efd_perf_autotest',
277         'lpm6_perf_autotest',
278         'rib6_slow_autotest',
279         'fib6_slow_autotest',
280         'fib6_perf_autotest',
281         'rcu_qsbr_perf_autotest',
282         'red_perf',
283         'pie_perf',
284         'distributor_perf_autotest',
285         'pmd_perf_autotest',
286         'stack_perf_autotest',
287         'stack_lf_perf_autotest',
288         'rand_perf_autotest',
289         'hash_readwrite_perf_autotest',
290         'hash_readwrite_lf_perf_autotest',
291         'trace_perf_autotest',
292         'ipsec_perf_autotest',
293         'thash_perf_autotest',
294 ]
295
296 driver_test_names = []
297
298 dump_test_names = []
299
300 if not is_windows
301     driver_test_names += [
302             'cryptodev_aesni_mb_autotest',
303             'cryptodev_aesni_gcm_autotest',
304             'cryptodev_cn9k_autotest',
305             'cryptodev_cn10k_autotest',
306             'cryptodev_dpaa_sec_autotest',
307             'cryptodev_dpaa2_sec_autotest',
308             'cryptodev_null_autotest',
309             'cryptodev_openssl_autotest',
310             'cryptodev_openssl_asym_autotest',
311             'cryptodev_qat_autotest',
312             'cryptodev_sw_armv8_autotest',
313             'cryptodev_sw_kasumi_autotest',
314             'cryptodev_sw_mvsam_autotest',
315             'cryptodev_sw_snow3g_autotest',
316             'cryptodev_sw_zuc_autotest',
317             'dmadev_autotest',
318             'eventdev_selftest_octeontx',
319             'eventdev_selftest_sw',
320             'rawdev_autotest',
321     ]
322
323     dump_test_names += [
324             'dump_struct_sizes',
325             'dump_mempool',
326             'dump_malloc_stats',
327             'dump_devargs',
328             'dump_log_types',
329             'dump_ring',
330             'dump_physmem',
331             'dump_memzone',
332     ]
333 endif
334
335 # The following linkages are an exception to allow running the
336 # unit tests without requiring that the developer install the
337 # DPDK libraries.  Explicit linkage of drivers (plugin libraries)
338 # in applications should not be used.
339 if dpdk_conf.has('RTE_MEMPOOL_RING')
340     test_deps += 'mempool_ring'
341 endif
342 if dpdk_conf.has('RTE_MEMPOOL_STACK')
343     test_deps += 'mempool_stack'
344 endif
345 if dpdk_conf.has('RTE_EVENT_SKELETON')
346     test_deps += 'event_skeleton'
347 endif
348
349 if dpdk_conf.has('RTE_LIB_FLOW_CLASSIFY')
350     test_sources += 'test_flow_classify.c'
351     fast_tests += [['flow_classify_autotest', false, true]]
352 endif
353 if dpdk_conf.has('RTE_LIB_METRICS')
354     test_sources += ['test_metrics.c']
355     fast_tests += [['metrics_autotest', true, true]]
356 endif
357 if not is_windows and dpdk_conf.has('RTE_LIB_TELEMETRY')
358     test_sources += ['test_telemetry_json.c', 'test_telemetry_data.c']
359     fast_tests += [['telemetry_json_autotest', true, true]]
360     fast_tests += [['telemetry_data_autotest', true, true]]
361 endif
362 if dpdk_conf.has('RTE_LIB_PIPELINE')
363 # pipeline lib depends on port and table libs, so those must be present
364 # if pipeline library is.
365     test_sources += [
366             'test_table.c',
367             'test_table_acl.c',
368             'test_table_combined.c',
369             'test_table_pipeline.c',
370             'test_table_ports.c',
371             'test_table_tables.c',
372     ]
373     fast_tests += [['table_autotest', true, true]]
374 endif
375
376 # The following linkages of drivers are required because
377 # they are used via a driver-specific API.
378 if dpdk_conf.has('RTE_NET_BOND')
379     test_deps += 'net_bond'
380     test_sources += ['test_link_bonding.c', 'test_link_bonding_rssconf.c']
381     driver_test_names += ['link_bonding_autotest', 'link_bonding_rssconf_autotest']
382     if dpdk_conf.has('RTE_NET_RING')
383         test_sources += 'test_link_bonding_mode4.c'
384         driver_test_names += 'link_bonding_mode4_autotest'
385     endif
386 endif
387 if dpdk_conf.has('RTE_NET_RING')
388     test_deps += 'net_ring'
389     test_sources += 'test_pmd_ring_perf.c'
390     test_sources += 'test_pmd_ring.c'
391     test_sources += 'test_event_eth_tx_adapter.c'
392     test_sources += 'sample_packet_forward.c'
393     fast_tests += [['ring_pmd_autotest', true, true]]
394     perf_test_names += 'ring_pmd_perf_autotest'
395     fast_tests += [['event_eth_tx_adapter_autotest', false, true]]
396     if dpdk_conf.has('RTE_LIB_BITRATESTATS')
397         test_sources += 'test_bitratestats.c'
398         fast_tests += [['bitratestats_autotest', true, true]]
399     endif
400     if dpdk_conf.has('RTE_LIB_LATENCYSTATS')
401         test_sources += 'test_latencystats.c'
402         fast_tests += [['latencystats_autotest', true, true]]
403     endif
404     if dpdk_conf.has('RTE_LIB_PDUMP')
405         test_sources += 'test_pdump.c'
406         fast_tests += [['pdump_autotest', true, false]]
407     endif
408 endif
409 if dpdk_conf.has('RTE_NET_NULL')
410     test_deps += 'net_null'
411     test_sources += 'test_vdev.c'
412     fast_tests += [['vdev_autotest', true, true]]
413 endif
414
415 if dpdk_conf.has('RTE_HAS_LIBPCAP')
416     ext_deps += pcap_dep
417     if dpdk_conf.has('RTE_LIB_PCAPNG')
418         test_sources += 'test_pcapng.c'
419     endif
420 endif
421
422 if cc.has_argument('-Wno-format-truncation')
423     cflags += '-Wno-format-truncation'
424 endif
425
426 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
427 cflags += '-fno-strict-aliasing'
428
429 # Enable using internal APIs in unit tests
430 cflags += ['-DALLOW_INTERNAL_API']
431
432 test_dep_objs = []
433 if dpdk_conf.has('RTE_LIB_COMPRESSDEV')
434     compress_test_dep = dependency('zlib', required: false, method: 'pkg-config')
435     if compress_test_dep.found()
436         test_dep_objs += compress_test_dep
437         test_sources += 'test_compressdev.c'
438         fast_tests += [['compressdev_autotest', false, true]]
439     endif
440 endif
441
442 if dpdk_conf.has('RTE_CRYPTO_SCHEDULER')
443     driver_test_names += 'cryptodev_scheduler_autotest'
444     test_deps += 'crypto_scheduler'
445 endif
446
447 foreach d:test_deps
448     def_lib = get_option('default_library')
449     test_dep_objs += get_variable(def_lib + '_rte_' + d)
450 endforeach
451
452 link_libs = []
453 if get_option('default_library') == 'static'
454     link_libs = dpdk_static_libraries + dpdk_drivers
455 endif
456
457 dpdk_test = executable('dpdk-test',
458         test_sources,
459         link_whole: link_libs,
460         dependencies: test_dep_objs + ext_deps,
461         c_args: cflags,
462         install_rpath: join_paths(get_option('prefix'),
463              driver_install_path),
464         install: true)
465
466 has_hugepage = run_command(py3, 'has_hugepage.py', check: true).stdout().strip() != '0'
467 message('hugepage availability: @0@'.format(has_hugepage))
468
469 # some perf tests (eg: memcpy perf autotest)take very long
470 # to complete, so timeout to 10 minutes
471 timeout_seconds = 600
472 timeout_seconds_fast = 10
473
474 foreach arg : fast_tests
475     test_args = []
476     run_test = true
477     if not has_hugepage
478         if arg[1]
479             test_args += ['--no-huge', '-m', '2048']
480         else
481             run_test = false
482         endif
483     endif
484
485     if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address,undefined'
486         if not arg[2]
487             run_test = false
488         endif
489     endif
490
491     if (get_option('default_library') == 'shared' and
492         arg[0] == 'event_eth_tx_adapter_autotest')
493         foreach drv:dpdk_drivers
494             test_args += ['-d', drv.full_path().split('.a')[0] + '.so']
495         endforeach
496     endif
497     if is_linux
498         test_args += ['--file-prefix=@0@'.format(arg[0])]
499     endif
500
501     if run_test
502         test(arg[0], dpdk_test,
503                 env : ['DPDK_TEST=' + arg[0]],
504                 args : test_args,
505                 timeout : timeout_seconds_fast,
506                 is_parallel : false,
507                 suite : 'fast-tests')
508     endif
509 endforeach
510
511 foreach arg : perf_test_names
512     test(arg, dpdk_test,
513             env : ['DPDK_TEST=' + arg],
514             timeout : timeout_seconds,
515             is_parallel : false,
516             suite : 'perf-tests')
517 endforeach
518
519 foreach arg : driver_test_names
520     test(arg, dpdk_test,
521             env : ['DPDK_TEST=' + arg],
522             timeout : timeout_seconds,
523             is_parallel : false,
524             suite : 'driver-tests')
525 endforeach
526
527 foreach arg : dump_test_names
528     test(arg, dpdk_test,
529             env : ['DPDK_TEST=' + arg],
530             timeout : timeout_seconds,
531             is_parallel : false,
532             suite : 'debug-tests')
533 endforeach
534
535 foreach arg : extra_test_names
536     test(arg, dpdk_test,
537             env : ['DPDK_TEST=' + arg],
538             timeout : timeout_seconds,
539             is_parallel : false,
540             suite : 'extra-tests')
541 endforeach