[Meson/Test] testcases for datarepo
[platform/upstream/nnstreamer.git] / tests / meson.build
1 # Build nnstreamer subplugins and apps for test cases
2 subdir('nnstreamer_example')
3
4 # Set unittest install dir
5 unittest_install_dir = join_paths(unittest_base_dir, 'tests')
6
7 # Build and copy exe for ssat
8 copy = find_program('cp', required: true)
9 libpng_dep = dependency('libpng', required: false)
10 if libpng_dep.found()
11   b2p = executable('bmp2png',
12     'bmp2png.c',
13     dependencies: [libpng_dep, glib_dep],
14     install: get_option('install-test'),
15     install_dir: unittest_install_dir
16   )
17
18   custom_target('copy-bmp2png',
19     input: b2p,
20     output: 'b2p',
21     depends: b2p,
22     command: [copy, '@INPUT@', '@CURRENT_SOURCE_DIR@'],
23     build_by_default: true,
24     build_always_stale: true,
25   )
26 endif
27
28 # ssat repo_dynamic
29 subdir('nnstreamer_repo_dynamicity')
30
31 # filter_reload (Currently, the reload test for tensor filter requires tflite)
32 if tflite_support_is_available
33   subdir('nnstreamer_filter_reload')
34 endif
35
36 # gtest
37 gtest_dep = dependency('gtest', required: false)
38 if gtest_dep.found()
39   lesser_code_quality_accepted_for_unittest_code = declare_dependency(compile_args: ['-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-maybe-uninitialized'])
40
41   # Shared library of internal APIs for nnstreamer-gtest
42   unittest_util_shared = shared_library('nnstreamer_unittest_util',
43     join_paths(meson.current_source_dir(), 'unittest_util.c'),
44     dependencies: nnstreamer_dep,
45     include_directories: nnstreamer_inc,
46     install: get_option('install-test'),
47     install_dir: nnstreamer_libdir
48   )
49   unittest_util_dep = declare_dependency(link_with: unittest_util_shared,
50     dependencies: nnstreamer_dep,
51     compile_args: ['-DFAKEDLOG=1'],
52     include_directories: include_directories('.')
53   )
54
55   nnstreamer_unittest_deps = [
56     unittest_util_dep,
57     glib_dep,
58     gst_dep,
59     gst_app_dep,
60     gst_check_dep,
61     gtest_dep,
62     lesser_code_quality_accepted_for_unittest_code
63   ]
64
65   # Run unittest_common
66   unittest_common = executable('unittest_common',
67     join_paths('common', 'unittest_common.cc'),
68     dependencies: [nnstreamer_unittest_deps],
69     install: get_option('install-test'),
70     install_dir: unittest_install_dir
71   )
72
73   test('unittest_common', unittest_common, env: testenv)
74
75   # Run unittest_sink
76   gst18_dep = dependency('gstreamer-' + gst_api_verision, version : '>=1.8', required : false)
77   if gst18_dep.found()
78     unittest_sink = executable('unittest_sink',
79       join_paths('nnstreamer_sink', 'unittest_sink.cc'),
80       dependencies: [nnstreamer_unittest_deps],
81       install: get_option('install-test'),
82       install_dir: unittest_install_dir
83     )
84
85     test('unittest_sink', unittest_sink, timeout: 120, env: testenv)
86
87     # Run unittest_plugins
88     unittest_plugins = executable('unittest_plugins',
89       join_paths('nnstreamer_plugins', 'unittest_plugins.cc'),
90       dependencies: [nnstreamer_unittest_deps, nnstreamer_internal_deps],
91       install: get_option('install-test'),
92       install_dir: unittest_install_dir
93     )
94
95     test('unittest_plugins', unittest_plugins, env: testenv)
96
97     # Run unittest_if
98     unittest_if = executable('unittest_if',
99       join_paths('nnstreamer_if', 'unittest_if.cc'),
100       dependencies: [nnstreamer_unittest_deps],
101       install: get_option('install-test'),
102       install_dir: unittest_install_dir
103     )
104
105     test('unittest_if', unittest_if, env: testenv)
106
107     # Run unittest_rate
108     unittest_rate = executable('unittest_rate',
109       join_paths('nnstreamer_rate', 'unittest_rate.cc'),
110       dependencies: [nnstreamer_unittest_deps],
111       install: get_option('install-test'),
112       install_dir: unittest_install_dir
113     )
114
115     test('unittest_rate', unittest_rate, env: testenv)
116
117     # Run unittest_latency
118     unittest_latency = executable('unittest_latency',
119       join_paths('nnstreamer_latency', 'unittest_latency.cc'),
120       dependencies: [nnstreamer_unittest_deps],
121       install: get_option('install-test'),
122       install_dir: unittest_install_dir
123     )
124
125     test('unittest_latency', unittest_latency, env: testenv)
126
127     # Run unittest_filter_single
128     unittest_filter_single = executable('unittest_filter_single',
129       join_paths('nnstreamer_filter_single', 'unittest_filter_single.cc'),
130       dependencies: [nnstreamer_single_dep, gtest_dep, lesser_code_quality_accepted_for_unittest_code],
131       install: get_option('install-test'),
132       install_dir: unittest_install_dir
133     )
134
135     test('unittest_filter_single', unittest_filter_single, env: testenv)
136
137     # Run unittest_join
138     unittest_join = executable('unittest_join',
139       join_paths('gstreamer_join', 'unittest_join.cc'),
140       dependencies: [nnstreamer_unittest_deps, join_dep],
141       install: get_option('install-test'),
142       install_dir: unittest_install_dir
143     )
144
145     test('unittest_join', unittest_join, env: testenv)
146
147     # Run unittest_mqtt
148     if mqtt_support_is_available
149       unittest_mqtt_w_helper = executable('unittest_mqtt_w_helper',
150           join_paths('gstreamer_mqtt', 'unittest_mqtt_w_helper.cc'),
151           dependencies: [gstmqtt_dep, nnstreamer_unittest_deps],
152           install: get_option('install-test'),
153           install_dir: unittest_install_dir)
154
155       test('unittest_mqtt_w_helper', unittest_mqtt_w_helper, env: testenv)
156
157       unittest_mqtt = executable('unittest_mqtt',
158           join_paths('gstreamer_mqtt', 'unittest_mqtt.cc'),
159           dependencies: [nnstreamer_unittest_deps],
160           install: get_option('install-test'),
161           install_dir: unittest_install_dir)
162
163       test('unittest_mqtt', unittest_mqtt, env: testenv)
164
165       # ntp util test
166       gmock_dep = dependency('gmock', required: false)
167       if get_option('enable-tizen') and gmock_dep.found()
168         gstreamer_ntp_util_mock = executable('unittest_ntp_util',
169             join_paths('gstreamer_mqtt', 'unittest_ntp_util_mock.cc'),
170             dependencies: [nnstreamer_unittest_deps, gmock_dep, gstmqtt_dep],
171             install: get_option('install-test'),
172             install_dir: unittest_install_dir)
173
174         test('gstreamer_ntp_util_mock', gstreamer_ntp_util_mock, env: testenv)
175       endif
176     endif
177
178     # Run unittest_src_iio
179     if tensor_src_iio_build
180       unittest_src_iio = executable('unittest_src_iio',
181         join_paths('nnstreamer_source', 'unittest_src_iio.cc'),
182         dependencies: [nnstreamer_unittest_deps],
183         install: get_option('install-test'),
184         install_dir: unittest_install_dir
185       )
186
187       test('unittest_src_iio', unittest_src_iio, timeout: 120, env: testenv)
188     endif
189
190     # Run unittest_converter
191     if flatbuf_support_is_available and have_python3
192       unittest_converter = executable('unittest_converter',
193         join_paths('nnstreamer_converter', 'unittest_converter.cc'),
194         dependencies: [nnstreamer_unittest_deps, flatbuf_dep, nnstreamer_python3_helper_dep],
195         install: get_option('install-test'),
196         install_dir: unittest_install_dir
197       )
198
199       test('unittest_converter', unittest_converter, env: testenv)
200     endif
201   endif
202
203   # Armnn unittest
204   if armnn_support_is_available
205     unittest_filter_armnn = executable('unittest_filter_armnn',
206       join_paths('nnstreamer_filter_armnn', 'unittest_filter_armnn.cc'),
207       dependencies: [nnstreamer_unittest_deps, armnn_plugin_dep],
208       install: get_option('install-test'),
209       install_dir: unittest_install_dir
210     )
211
212     test('unittest_filter_armnn', unittest_filter_armnn, env: testenv)
213   endif
214
215   # Lua unittest
216   if lua_support_is_available
217     unittest_filter_lua = executable('unittest_filter_lua',
218       join_paths('nnstreamer_filter_lua', 'unittest_filter_lua.cc'),
219       dependencies: [nnstreamer_unittest_deps],
220       install: get_option('install-test'),
221       install_dir: unittest_install_dir
222     )
223
224     test('unittest_filter_lua', unittest_filter_lua, env: testenv)
225   endif
226
227   # SNPE unittest
228   if snpe_support_is_available
229     unittest_filter_snpe = executable('unittest_filter_snpe',
230       join_paths('nnstreamer_filter_snpe', 'unittest_filter_snpe.cc'),
231       dependencies: [nnstreamer_unittest_deps],
232       install: get_option('install-test'),
233       install_dir: unittest_install_dir
234     )
235
236     test('unittest_filter_snpe', unittest_filter_snpe, env: testenv)
237   endif
238
239   # tensorflow2-lite unittest
240   if tflite2_support_is_available
241     unittest_filter_tensorflow2_lite = executable('unittest_filter_tensorflow2_lite',
242       join_paths('nnstreamer_filter_tensorflow2_lite', 'unittest_filter_tensorflow2_lite.cc'),
243       dependencies: [nnstreamer_unittest_deps],
244       install: get_option('install-test'),
245       install_dir: unittest_install_dir
246     )
247
248     test('unittest_filter_tensorflow2_lite', unittest_filter_tensorflow2_lite, env: testenv)
249   endif
250
251   # Run unittest_decoder
252   if flatbuf_support_is_available
253     unittest_decoder = executable('unittest_decoder',
254       join_paths('nnstreamer_decoder', 'unittest_decoder.cc'),
255       dependencies: [nnstreamer_unittest_deps, flatbuf_dep],
256       install: get_option('install-test'),
257       install_dir: unittest_install_dir
258     )
259
260     test('unittest_decoder', unittest_decoder, env: testenv)
261   endif
262
263   # gRPC unittest
264   if grpc_support_is_available
265     unittest_grpc = executable('unittest_grpc',
266       join_paths('nnstreamer_grpc', 'unittest_grpc.cc'),
267       dependencies: nnstreamer_unittest_deps,
268       install: get_option('install-test'),
269       install_dir: unittest_install_dir
270     )
271
272     test('unittest_grpc', unittest_grpc, env: testenv)
273   endif
274
275   # Tizen sensor-src
276   if get_option('enable-tizen-sensor')
277     subdir('tizen_sensor')
278   endif
279
280   # Tensor filter extensions basic test cases
281   subdir('nnstreamer_filter_extensions_common')
282
283   # Tizen NNFW runtime
284   if nnfw_runtime_support_is_available
285     subdir('tizen_nnfw_runtime')
286   endif
287
288   if (tflite_support_is_available or tflite2_support_is_available) and get_option('enable-edgetpu')
289     subdir('nnstreamer_filter_edgetpu')
290   endif
291
292   if mvncsdk2_support_is_available
293     subdir('nnstreamer_filter_mvncsdk2')
294   endif
295
296   if tvm_support_is_available
297     subdir('nnstreamer_filter_tvm')
298   endif
299
300   if get_option('enable-cppfilter')
301     subdir('cpp_methods')
302   endif
303
304   if get_option('enable-openvino')
305     subdir('nnstreamer_filter_openvino')
306   endif
307
308   if mxnet_support_is_available
309     subdir('nnstreamer_filter_mxnet')
310   endif
311
312   if nnstreamer_edge_support_is_available
313     subdir('nnstreamer_edge')
314   endif
315
316   if tflite_support_is_available or tflite2_support_is_available
317     unittest_filter_shared_model = executable('unittest_filter_shared_model',
318       join_paths('nnstreamer_filter_shared_model', 'unittest_filter_shared_model.cc'),
319       dependencies: [nnstreamer_unittest_deps, unittest_util_dep],
320       install: get_option('install-test'),
321       install_dir: unittest_install_dir
322     )
323
324     test('unittest_filter_shared_model', unittest_filter_shared_model, timeout: 30, env: testenv)
325   endif
326
327   if get_option('enable-datarepo')
328     subdir('nnstreamer_datarepo')
329   endif
330
331   # Run unittest_trainer
332   unittest_trainer = executable('unittest_trainer',
333     join_paths('nnstreamer_trainer', 'unittest_trainer.cc'),
334     dependencies: [nnstreamer_unittest_deps],
335     install: get_option('install-test'),
336     install_dir: unittest_install_dir
337   )
338
339   test('unittest_trainer', unittest_trainer, env: testenv)
340
341 endif # gtest_dep.found()
342
343 tensor_filter_ext_enabled = tflite_support_is_available or \
344     tflite2_support_is_available or \
345     tf_support_is_available or \
346     have_python3 or \
347     pytorch_support_is_available or caffe2_support_is_available or \
348     nnfw_runtime_support_is_available or get_option('enable-edgetpu') or \
349     mvncsdk2_support_is_available or get_option('enable-openvino') or \
350     mxnet_support_is_available
351 if get_option('install-test') and tensor_filter_ext_enabled
352   install_subdir('test_models', install_dir: unittest_install_dir)
353 endif
354
355
356 # Install Unittest
357 if get_option('install-test')
358   install_data('gen24bBMP.py', install_dir: unittest_install_dir)
359   install_data('test_utils.py', install_dir: unittest_install_dir)
360   install_subdir('nnstreamer_converter', install_dir: unittest_install_dir)
361   install_subdir('nnstreamer_merge', install_dir: unittest_install_dir)
362   install_subdir('nnstreamer_decoder', install_dir: unittest_install_dir)
363   install_subdir('nnstreamer_decoder_boundingbox', install_dir: unittest_install_dir)
364   install_subdir('nnstreamer_decoder_pose', install_dir: unittest_install_dir)
365   install_subdir('nnstreamer_demux', install_dir: unittest_install_dir)
366   install_subdir('nnstreamer_filter_custom', install_dir: unittest_install_dir)
367   if tflite_support_is_available
368     install_subdir('nnstreamer_filter_tensorflow_lite', install_dir: unittest_install_dir)
369     install_subdir('nnstreamer_decoder_image_labeling', install_dir: unittest_install_dir)
370     install_subdir('nnstreamer_decoder_image_segment', install_dir: unittest_install_dir)
371     install_subdir('nnstreamer_filter_reload', install_dir: unittest_install_dir)
372   endif
373   if tflite2_support_is_available
374     install_subdir('nnstreamer_filter_tensorflow2_lite', install_dir: unittest_install_dir)
375   endif
376   if have_python3
377     if flatbuf_support_is_available
378       install_subdir('nnstreamer_converter_python3', install_dir: unittest_install_dir)
379       install_subdir('nnstreamer_decoder_python3', install_dir: unittest_install_dir)
380     endif
381     install_subdir('nnstreamer_filter_python3', install_dir: unittest_install_dir)
382   endif
383   if tf_support_is_available
384     install_subdir('nnstreamer_filter_tensorflow', install_dir: unittest_install_dir)
385   endif
386   if pytorch_support_is_available
387     install_subdir('nnstreamer_filter_pytorch', install_dir: unittest_install_dir)
388   endif
389   if caffe2_support_is_available
390     install_subdir('nnstreamer_filter_caffe2', install_dir: unittest_install_dir)
391   endif
392   if deepview_rt_support_is_available
393     install_subdir('nnstreamer_filter_deepview_rt', install_dir: unittest_install_dir)
394   endif
395   if flatbuf_support_is_available
396     install_subdir('nnstreamer_flatbuf', install_dir: unittest_install_dir)
397     install_subdir('nnstreamer_flexbuf', install_dir: unittest_install_dir)
398   endif
399   if protobuf_support_is_available
400     install_subdir('nnstreamer_protobuf', install_dir: unittest_install_dir)
401   endif
402   if mxnet_support_is_available
403     install_subdir('unittest_filter_mxnet', install_dir: unittest_install_dir)
404   endif
405   install_subdir('nnstreamer_mux', install_dir: unittest_install_dir)
406   install_subdir('nnstreamer_rate', install_dir: unittest_install_dir)
407   install_subdir('nnstreamer_repo', install_dir: unittest_install_dir)
408   install_subdir('nnstreamer_repo_dynamicity', install_dir: unittest_install_dir)
409   install_subdir('nnstreamer_repo_lstm', install_dir: unittest_install_dir)
410   install_subdir('nnstreamer_repo_rnn', install_dir: unittest_install_dir)
411   install_subdir('nnstreamer_split', install_dir: unittest_install_dir)
412   install_subdir('transform_arithmetic', install_dir: unittest_install_dir)
413   install_subdir('transform_clamp', install_dir: unittest_install_dir)
414   install_subdir('transform_dimchg', install_dir: unittest_install_dir)
415   install_subdir('transform_stand', install_dir: unittest_install_dir)
416   install_subdir('transform_transpose', install_dir: unittest_install_dir)
417   install_subdir('transform_typecast', install_dir: unittest_install_dir)
418 endif