tests: skip unit tests for dependency-less elements that have been disabled
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / tests / check / meson.build
1 have_registry = true # FIXME get_option('registry')
2
3 libparser = static_library('parser',
4   'elements/parser.c',
5   install : false,
6   dependencies : [gst_dep, gstcheck_dep],
7 )
8
9 libparser_dep = declare_dependency(link_with: libparser,
10   sources: ['elements/parser.h'])
11
12 # FIXME: automagic
13 exif_dep = dependency('libexif', version : '>= 0.6.16', required : false)
14
15 # Since nalutils API is internal, need to build it again
16 nalutils_dep = gstcodecparsers_dep.partial_dependency (compile_args: true, includes: true)
17
18 enable_gst_play_tests = get_option('gst_play_tests')
19 libsoup_dep = dependency('libsoup-2.4', version : '>=2.48', required : enable_gst_play_tests,
20   fallback : ['libsoup', 'libsoup_dep'])
21
22 # name, condition when to skip the test and extra dependencies
23 base_tests = [
24   [['elements/aesenc.c'], not aes_dep.found(), [aes_dep]],
25   [['elements/aesdec.c'], not aes_dep.found(), [aes_dep]],
26   [['elements/aiffparse.c'], get_option('aiff').disabled()],
27   [['elements/asfmux.c'], get_option('asfmux').disabled()],
28   [['elements/autoconvert.c'], get_option('autoconvert').disabled()],
29   [['elements/autovideoconvert.c'], get_option('autoconvert').disabled()],
30   [['elements/avwait.c'], get_option('timecode').disabled()],
31   [['elements/camerabin.c'], get_option('camerabin2').disabled()],
32   [['elements/ccconverter.c'], not closedcaption_dep.found(), [gstvideo_dep]],
33   [['elements/cccombiner.c'], not closedcaption_dep.found(), ],
34   [['elements/ccextractor.c'], not closedcaption_dep.found(), ],
35   [['elements/cudaconvert.c'], false, [gstgl_dep, gmodule_dep]],
36   [['elements/cudafilter.c'], false, [gstgl_dep, gmodule_dep]],
37   [['elements/d3d11colorconvert.c'], host_machine.system() != 'windows', ],
38   [['elements/gdpdepay.c'], get_option('gdp').disabled()],
39   [['elements/gdppay.c'], get_option('gdp').disabled()],
40   [['elements/h263parse.c'], false, [libparser_dep, gstcodecparsers_dep]],
41   [['elements/h264parse.c'], false, [libparser_dep, gstcodecparsers_dep]],
42   [['elements/h265parse.c'], false, [libparser_dep, gstcodecparsers_dep]],
43   [['elements/hlsdemux_m3u8.c'], not hls_dep.found(), [hls_dep]],
44   [['elements/id3mux.c'], get_option('id3tag').disabled()],
45   [['elements/interlace.c'], get_option('interlace').disabled()],
46   [['elements/jpeg2000parse.c'], false, [libparser_dep, gstcodecparsers_dep]],
47   [['elements/line21.c'], not closedcaption_dep.found(), ],
48   [['elements/mfvideosrc.c'], host_machine.system() != 'windows', ],
49   [['elements/mpegtsdemux.c'], get_option('mpegtsdemux').disabled(), [gstmpegts_dep]],
50   [['elements/mpegtsmux.c'], get_option('mpegtsmux').disabled(), [gstmpegts_dep]],
51   [['elements/mpeg4videoparse.c'], false, [libparser_dep, gstcodecparsers_dep]],
52   [['elements/mpegvideoparse.c'], false, [libparser_dep, gstcodecparsers_dep]],
53   [['elements/msdkh264enc.c'], not have_msdk, [msdk_dep]],
54   [['elements/mxfdemux.c'], get_option('mxf').disabled()],
55   [['elements/mxfmux.c'], get_option('mxf').disabled()],
56   [['elements/nvenc.c'], false, [gstgl_dep, gmodule_dep]],
57   [['elements/nvdec.c'], not gstgl_dep.found(), [gstgl_dep, gmodule_dep]],
58   [['elements/svthevcenc.c'], not svthevcenc_dep.found(), [svthevcenc_dep]],
59    [['elements/openjpeg.c'], not openjpeg_dep.found(), [openjpeg_dep]],
60   [['elements/pcapparse.c'], false, [libparser_dep]],
61   [['elements/pnm.c'], get_option('pnm').disabled()],
62   [['elements/ristrtpext.c']],
63   [['elements/rtponvifparse.c'], get_option('onvif').disabled()],
64   [['elements/rtponviftimestamp.c'], get_option('onvif').disabled()],
65   [['elements/rtpsrc.c'], get_option('rtp').disabled()],
66   [['elements/rtpsink.c'], get_option('rtp').disabled()],
67   [['elements/srtp.c'], not srtp_dep.found(), [srtp_dep]],
68   [['elements/switchbin.c'], get_option('switchbin').disabled()],
69   [['elements/videoframe-audiolevel.c'], get_option('videoframe_audiolevel').disabled()],
70   [['elements/viewfinderbin.c']],
71   [['elements/vp9parse.c'], false, [gstcodecparsers_dep]],
72   [['elements/av1parse.c'], false, [gstcodecparsers_dep]],
73   [['elements/wasapi.c'], host_machine.system() != 'windows', ],
74   [['elements/wasapi2.c'], host_machine.system() != 'windows', ],
75   [['libs/h264parser.c'], false, [gstcodecparsers_dep]],
76   [['libs/h265parser.c'], false, [gstcodecparsers_dep]],
77   [['libs/insertbin.c'], false, [gstinsertbin_dep]],
78   [['libs/isoff.c'], false, [gstisoff_dep]],
79   [['libs/nalutils.c', '../../gst-libs/gst/codecparsers/nalutils.c'], false, [nalutils_dep]],
80   [['libs/mpegts.c'], false, [gstmpegts_dep]],
81   [['libs/mpegvideoparser.c'], false, [gstcodecparsers_dep]],
82   [['libs/planaraudioadapter.c'], false, [gstbadaudio_dep]],
83   [['libs/play.c'], not enable_gst_play_tests, [gstplay_dep, libsoup_dep]],
84   [['libs/vc1parser.c'], false, [gstcodecparsers_dep]],
85   [['libs/vp8parser.c'], false, [gstcodecparsers_dep]],
86   [['libs/vp9parser.c'], false, [gstcodecparsers_dep]],
87   [['libs/av1parser.c'], false, [gstcodecparsers_dep]],
88   [['libs/h264bitwriter.c'], false, [gstcodecparsers_dep]],
89   [['libs/h265bitwriter.c'], false, [gstcodecparsers_dep]],
90   [['libs/vkmemory.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
91   [['elements/vkcolorconvert.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
92   [['libs/vkwindow.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
93   [['libs/vkdevice.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
94   [['elements/vkdeviceprovider.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
95   [['libs/vkcommandpool.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
96   [['libs/vkimage.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
97   [['libs/vkinstance.c'], not gstvulkan_dep.found(), [gstvulkan_dep]],
98   [['libs/d3d11device.cpp'], not gstd3d11_dep.found(), [gstd3d11_dep]],
99 ]
100
101 # FIXME: unistd dependency, unstable or not tested yet on windows
102 if host_machine.system() != 'windows'
103   base_tests += [
104     [['elements/assrender.c'], not ass_dep.found(), [ass_dep]],
105     [['elements/avtpaafpay.c'], not avtp_dep.found(), [avtp_dep]],
106     [['elements/avtpaafdepay.c'], not avtp_dep.found(), [avtp_dep]],
107     [['elements/avtpcrfbase.c'], not avtp_dep.found(), [avtp_dep]],
108     [['elements/avtpcrfcheck.c'], not avtp_dep.found(), [avtp_dep], ['../../ext/avtp/gstavtpcrfutil.c']],
109     [['elements/avtpcrfsync.c'], not avtp_dep.found(), [avtp_dep], ['../../ext/avtp/gstavtpcrfutil.c', '../../ext/avtp/gstavtpcrfbase.c']],
110     [['elements/avtpcrfutil.c'], not avtp_dep.found(), [avtp_dep], ['../../ext/avtp/gstavtpcrfutil.c', '../../ext/avtp/gstavtpcrfbase.c']],
111     [['elements/avtpcvfpay.c'], not avtp_dep.found(), [avtp_dep]],
112     [['elements/avtpcvfdepay.c'], not avtp_dep.found(), [avtp_dep]],
113     [['elements/avtpsink.c'], not avtp_dep.found(), [avtp_dep]],
114     [['elements/avtpsrc.c'], not avtp_dep.found(), [avtp_dep]],
115     [['elements/clockselect.c'], get_option('debugutils').disabled()],
116     [['elements/curlhttpsink.c'], not curl_dep.found(), [curl_dep]],
117     [['elements/curlhttpsrc.c'], not curl_dep.found(), [curl_dep, gio_dep]],
118     [['elements/curlfilesink.c'],
119         not curl_dep.found() or not cdata.has('HAVE_UNISTD_H'), [curl_dep]],
120     [['elements/curlftpsink.c'], not curl_dep.found(), [curl_dep]],
121     [['elements/curlsmtpsink.c'], not curl_dep.found(), [curl_dep]],
122     [['elements/dash_mpd.c'], not xml2_dep.found(), [xml2_dep]],
123     [['elements/dtls.c'], not libcrypto_dep.found(), [libcrypto_dep]],
124     [['elements/faac.c'],
125         not faac_dep.found() or not cc.has_header_symbol('faac.h', 'faacEncOpen') or not cdata.has('HAVE_UNISTD_H'),
126         [faac_dep]],
127     [['elements/faad.c'],
128         not faad_dep.found() or not have_faad_2_7 or not cdata.has('HAVE_UNISTD_H'),
129         [faad_dep]],
130     [['elements/jifmux.c'],
131         not exif_dep.found() or not cdata.has('HAVE_UNISTD_H'), [exif_dep]],
132     [['elements/jpegparse.c'], not cdata.has('HAVE_UNISTD_H')],
133     [['elements/kate.c'],
134         not kate_dep.found() or not cdata.has('HAVE_UNISTD_H'), [kate_dep]],
135     [['elements/netsim.c']],
136     [['elements/shm.c'], not shm_enabled, shm_deps],
137     [['elements/voaacenc.c'],
138         not voaac_dep.found() or not cdata.has('HAVE_UNISTD_H'), [voaac_dep]],
139     [['elements/webrtcbin.c'], not libnice_dep.found(), [gstwebrtc_dep]],
140     [['elements/x265enc.c'], not x265_dep.found(), [x265_dep]],
141     [['elements/zbar.c'], not zbar_dep.found(), [zbar_dep]],
142     [['elements/zxing.c'], not zxing_dep.found(), [zxing_dep]],
143   ]
144 endif
145
146 # linux only tests
147 if host_machine.system() == 'linux'
148   base_tests += [
149     [['elements/vapostproc.c'], not gstva_dep.found(), [gstva_dep]],
150     [['elements/vacompositor.c'], not gstva_dep.found(), [gstva_dep]],
151   ]
152 endif
153
154 test_defines = [
155   '-UG_DISABLE_ASSERT',
156   '-UG_DISABLE_CAST_CHECKS',
157   '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"',
158   '-DGST_TEST_FILES_PATH="' + meson.current_source_dir() + '/../files"',
159   '-DTEST_PATH="' + meson.current_build_dir() + '/media"',
160   '-DDASH_MPD_DATADIR=' + meson.current_source_dir() + '/elements/dash_mpd_data',
161   '-DGST_USE_UNSTABLE_API',
162 ]
163
164 test_deps = [gst_dep, gstapp_dep, gstbase_dep,
165              gstbasecamerabin_dep, gstphotography_dep,
166              gstpbutils_dep, gstcontroller_dep, gstaudio_dep,
167              gstvideo_dep, gstrtp_dep, gsturidownloader_dep,
168              gstcheck_dep, gio_dep, gsttag_dep]
169
170 pluginsdirs = [  ]
171
172 if gst_dep.type_name() == 'pkgconfig'
173   pbase = dependency('gstreamer-plugins-base-' + api_version)
174
175   pluginsdirs = [gst_dep.get_variable('pluginsdir'),
176                  pbase.get_variable('pluginsdir')]
177   gst_plugin_scanner_dir = gst_dep.get_variable('pluginscannerdir')
178 else
179   gst_plugin_scanner_dir = subproject('gstreamer').get_variable('gst_scanner_dir')
180 endif
181 gst_plugin_scanner_path = join_paths(gst_plugin_scanner_dir, 'gst-plugin-scanner')
182
183 extra_args = []
184 # XXX: our MinGW 32bits toolchain complians when ComPtr is in use
185 if host_system == 'windows' and cc.get_id() != 'msvc'
186   mingw_args = cc.get_supported_arguments([
187     '-Wno-redundant-decls',
188   ])
189
190   extra_args += mingw_args
191 endif
192
193 foreach t : base_tests
194   fnames = t.get(0)
195   test_name = fnames[0].split('.').get(0).underscorify()
196   skip_test = false
197   extra_deps = [ ]
198
199   if t.length() >= 3
200     extra_deps = t.get(2)
201   endif
202
203   if t.length() >= 2
204     skip_test = t.get(1)
205   endif
206
207   extra_sources = t.get(3, [ ])
208
209   if not skip_test
210     exe = executable(test_name, fnames, extra_sources,
211       include_directories : [configinc],
212       c_args : gst_plugins_bad_args + test_defines + extra_args,
213       cpp_args : gst_plugins_bad_args + test_defines + extra_args,
214       dependencies : [libm] + test_deps + extra_deps,
215     )
216
217     env = environment()
218     env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '')
219     env.set('CK_DEFAULT_TIMEOUT', '20')
220     env.set('GST_STATE_IGNORE_ELEMENTS', '')
221     env.set('GST_PLUGIN_PATH_1_0', [meson.global_build_root()] + pluginsdirs)
222     env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name)))
223     env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer', 'gst-plugins-base',
224       'gst-plugins-good', 'gst-plugins-ugly','gst-libav', 'libnice',
225       'gst-plugins-bad@' + meson.project_build_root())
226     env.set('GST_PLUGIN_SCANNER_1_0', gst_plugin_scanner_path)
227     test(test_name, exe, env: env, timeout: 3 * 60)
228   endif
229 endforeach
230
231 # orc tests
232 orc_tests = [
233   ['orc_bayer', files('../../gst/bayer/gstbayerorc.orc')],
234 ]
235
236 orc_test_dep = dependency('', required : false)
237 if have_orcc
238   # FIXME: there should really just be a separate orc-test-0.4.pc file for this
239   if orc_dep.type_name() == 'pkgconfig'
240     orc_test_dep = cc.find_library('orc-test-0.4', required : false)
241   else
242     orc_test_dep = dependency('', fallback: ['orc', 'orc_test_dep'], required: false)
243   endif
244 endif
245
246 if have_orcc and orc_test_dep.found()
247   foreach t : orc_tests
248     tname = t[0]
249     torcfile = t[1]
250     tcfilename = '@0@.c'.format(tname)
251     test_c = custom_target(tcfilename,
252       output: tcfilename,
253       input: torcfile,
254       command: [orcc, '--include', 'stdint.h', '--test', '-o', '@OUTPUT@', '@INPUT@'])
255     test_exe = executable(tname, test_c, dependencies: [orc_dep, orc_test_dep])
256     test(tname, test_exe)
257   endforeach
258 endif
259
260 if enable_gst_play_tests
261   subdir ('media')
262 endif