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