tests: skip unit tests for dependency-less elements that have been disabled
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-good / tests / check / meson.build
1 valgrind_dep = dependency('valgrind', required: false).partial_dependency(compile_args : true)
2 if valgrind_dep.found()
3   cdata.set('HAVE_VALGRIND', 1)
4 endif
5
6 # internal helper lib for unit testing audio parsers
7 libparser = static_library('libparser', 'elements/parser.c',
8   c_args : gst_plugins_good_args + ['-DGST_USE_UNSTABLE_API'],
9   include_directories : [configinc],
10   dependencies : [gstcheck_dep],
11   install : false)
12
13 libparser_dep = declare_dependency(link_with : libparser,
14   dependencies : gstcheck_dep)
15
16 # name, condition when to skip the test and extra dependencies
17 good_tests = [
18   [ 'elements/audioamplify', get_option('audiofx').disabled(), [gstfft_dep] ],
19   [ 'elements/audiochebband', get_option('audiofx').disabled(), [gstfft_dep] ],
20   [ 'elements/audiocheblimit', get_option('audiofx').disabled(), [gstfft_dep] ],
21   [ 'elements/audiodynamic', get_option('audiofx').disabled(), [gstfft_dep] ],
22   [ 'elements/audioecho', get_option('audiofx').disabled(), [gstfft_dep] ],
23   [ 'elements/audiofirfilter', get_option('audiofx').disabled(), [gstfft_dep] ],
24   [ 'elements/audioiirfilter', get_option('audiofx').disabled(), [gstfft_dep] ],
25   [ 'elements/audioinvert', get_option('audiofx').disabled(), [gstfft_dep] ],
26   [ 'elements/audiopanorama', get_option('audiofx').disabled(), [gstfft_dep] ],
27   [ 'elements/audiowsincband', get_option('audiofx').disabled(), [gstfft_dep] ],
28   [ 'elements/audiowsinclimit', get_option('audiofx').disabled(), [gstfft_dep] ],
29   [ 'elements/alphacolor', get_option('alpha').disabled()],
30   [ 'elements/alpha', get_option('alpha').disabled()],
31   [ 'elements/avimux', get_option('avi').disabled(), [gstriff_dep] ],
32   [ 'elements/avisubtitle', get_option('avi').disabled(), [gstriff_dep] ],
33   [ 'elements/capssetter', get_option('debugutils').disabled()],
34   [ 'elements/aacparse', get_option('audioparsers').disabled(), [libparser_dep] ],
35   [ 'elements/ac3parse', get_option('audioparsers').disabled(), [libparser_dep] ],
36   [ 'elements/amrparse', get_option('audioparsers').disabled(), [libparser_dep] ],
37   [ 'elements/flacparse', get_option('audioparsers').disabled(), [libparser_dep] ],
38   [ 'elements/mpegaudioparse', get_option('audioparsers').disabled(), [libparser_dep] ],
39   [ 'elements/autodetect', get_option('autodetect').disabled()],
40   [ 'elements/deinterlace', get_option('deinterlace').disabled()],
41   [ 'elements/dtmf', get_option('dtmf').disabled()],
42   [ 'elements/flvdemux', get_option('flv').disabled()],
43   [ 'elements/flvmux', get_option('flv').disabled()],
44   [ 'elements/hlsdemux_m3u8' , not hls_dep.found() or not adaptivedemux2_dep.found(), [hls_dep, adaptivedemux2_dep] ],
45   [ 'elements/mulawdec', get_option('law').disabled()],
46   [ 'elements/mulawenc', get_option('law').disabled()],
47   [ 'elements/icydemux', get_option('icydemux').disabled()],
48   [ 'elements/id3demux', get_option('id3demux').disabled()],
49   [ 'elements/imagefreeze', get_option('imagefreeze').disabled()],
50   [ 'elements/deinterleave', get_option('interleave').disabled()],
51   [ 'elements/interleave', get_option('interleave').disabled()],
52   [ 'elements/level', get_option('level').disabled()],
53   [ 'elements/matroskademux', get_option('matroska').disabled(), [gstriff_dep] ],
54   [ 'elements/matroskamux', get_option('matroska').disabled(), [gstriff_dep] ],
55   [ 'elements/matroskaparse', get_option('matroska').disabled(), [gstriff_dep] ],
56   [ 'elements/multifile', get_option('multifile').disabled()],
57   [ 'elements/splitmuxsink', get_option('multifile').disabled()],
58   [ 'elements/splitmuxsinktimecode', get_option('multifile').disabled()],
59   [ 'elements/splitmuxsrc', get_option('multifile').disabled()],
60   [ 'elements/qtmux', get_option('isomp4').disabled(), [gstriff_dep, zlib_dep] ],
61   [ 'elements/qtdemux', get_option('isomp4').disabled(), [gstriff_dep, zlib_dep] ],
62   [ 'elements/rganalysis', get_option('replaygain').disabled()],
63   [ 'elements/rglimiter', get_option('replaygain').disabled()],
64   [ 'elements/rgvolume', get_option('replaygain').disabled()],
65   [ 'elements/spectrum', get_option('spectrum').disabled(), [gstfft_dep] ],
66   [ 'elements/shapewipe', get_option('shapewipe').disabled()],
67   [ 'elements/udpsink', get_option('udp').disabled()],
68   [ 'elements/udpsrc', get_option('udp').disabled()],
69   [ 'elements/videobox', get_option('videobox').disabled()],
70   [ 'elements/videocrop', get_option('videocrop').disabled()],
71   [ 'elements/videofilter', get_option('videofilter').disabled()],
72   [ 'elements/videoflip', get_option('videofilter').disabled()],
73   [ 'elements/videomixer', get_option('videomixer').disabled()],
74   [ 'elements/aspectratiocrop', get_option('videocrop').disabled()],
75   [ 'pipelines/wavenc', get_option('wavenc').disabled()],
76   [ 'elements/wavparse', get_option('wavparse').disabled(), [gstriff_dep] ],
77   [ 'elements/wavpackparse', get_option('audioparsers').disabled()],
78   [ 'elements/y4menc', get_option('y4m').disabled()],
79   [ 'pipelines/effectv', get_option('effectv').disabled()],
80   [ 'elements/equalizer', get_option('equalizer').disabled()],
81   [ 'pipelines/simple-launch-lines' ],
82   [ 'pipelines/tagschecking' ],
83   [ 'generic/states' ],
84 ]
85
86 if not get_option('rtp').disabled() and not get_option('rtpmanager').disabled()
87   good_tests += [
88     [ 'elements/rtphdrext-colorspace' ],
89     [ 'elements/rtph261', ],
90     [ 'elements/rtph263' ],
91     [ 'elements/rtph264' ],
92     [ 'elements/rtph265' ],
93     [ 'elements/rtpopus' ],
94     [ 'elements/rtpvp8' ],
95     [ 'elements/rtpvp9' ],
96     [ 'elements/rtpbin' ],
97     [ 'elements/rtpbin_buffer_list' ],
98     [ 'elements/rtpcollision' ],
99     [ 'elements/rtpfunnel' ],
100     [ 'elements/rtphdrextclientaudiolevel', false, [gstsdp_dep, gstaudio_dep] ],
101     [ 'elements/rtphdrextsdes', false, [gstrtp_dep, gstsdp_dep] ],
102     [ 'elements/rtpjitterbuffer' ],
103     [ 'elements/rtpjpeg' ],
104
105     [ 'elements/rtptimerqueue', false, [gstrtp_dep],
106       ['../../gst/rtpmanager/rtptimerqueue.c']],
107
108     [ 'elements/rtpmux' ],
109     [ 'elements/rtpptdemux' ],
110     [ 'elements/rtprtx' ],
111     [ 'elements/rtpsession' ],
112     [ 'elements/rtpstorage', false, [],  ['../../gst/rtp/gstrtpstorage.c',
113                                         '../../gst/rtp/gstrtpelement.c',
114                                         '../../gst/rtp/gstrtputils.c',
115                                         '../../gst/rtp/rtpstorage.c',
116                                         '../../gst/rtp/rtpstoragestream.c']],
117     [ 'elements/rtpred' ],
118     [ 'elements/rtpulpfec' ],
119     [ 'elements/rtpssrcdemux' ],
120     [ 'elements/rtp-payloading' ],
121     [ 'elements/rtpst2022-1-fecdec' ],
122     [ 'elements/rtpst2022-1-fecenc' ],
123   ]
124 endif
125
126 # FIXME: valgrind elements/rtp-payloading - needs fixing
127 # elements/videocrop should be disabled since it takes way too long in valgrind
128
129 libsoup2_dep = dependency('libsoup-2.4', version : '>=2.48',
130                           required : false, fallback : ['libsoup', 'libsoup_dep'],
131                           default_options: ['sysprof=disabled'])
132 libsoup3_dep = dependency('libsoup-3.0', required : false,
133                            fallback : ['libsoup3', 'libsoup_dep'])
134
135 # FIXME: unistd dependency or not tested yet on windows
136 if host_machine.system() != 'windows'
137   good_tests += [
138     [ 'elements/dash_mpd', not adaptivedemux2_dep.found(), [adaptivedemux2_dep] ],
139     [ 'pipelines/flacdec', not flac_dep.found() ],
140     [ 'elements/gdkpixbufsink', not gdkpixbuf_dep.found(), [gdkpixbuf_dep] ],
141     [ 'elements/gdkpixbufoverlay', not gdkpixbuf_dep.found() ],
142     [ 'elements/jpegdec', not jpeglib.found() ],
143     [ 'elements/jpegenc', not jpeglib.found() ],
144     [ 'elements/mpg123audiodec', not mpg123_dep.found(), [gstfft_dep]],
145     [ 'elements/souphttpsrc', not libsoup2_dep.found(), [libsoup2_dep], [], 'elements/souphttpsrc2'],
146     [ 'elements/souphttpsrc', not libsoup3_dep.found(), [libsoup3_dep], [], 'elements/souphttpsrc3'],
147     [ 'elements/id3v2mux', not taglib_dep.found() ],
148     [ 'elements/apev2mux', not taglib_dep.found() ],
149     [ 'elements/vp8enc', not vpx_dep.found() or not have_vp8_encoder ],
150     [ 'elements/vp8dec', not vpx_dep.found() or not have_vp8_decoder ],
151     [ 'elements/vp9enc', not vpx_dep.found() or not have_vp9_encoder ],
152     [ 'pipelines/lame', not lame_dep.found() ],
153     [ 'elements/wavpackdec', not wavpack_dep.found() ],
154     [ 'elements/wavpackenc', not wavpack_dep.found() ],
155     [ 'pipelines/wavpack', not wavpack_dep.found() ],
156   ]
157 endif
158
159 foo='''
160 if HAVE_ORC
161 check_orc = orc/deinterlace orc/videomixer orc/videobox
162 else
163 check_orc =
164 endif
165 '''
166
167 test_defines = [
168   '-UG_DISABLE_ASSERT',
169   '-UG_DISABLE_CAST_CHECKS',
170   '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_PLUGIN_LOADING_WHITELIST"',
171   '-DGST_TEST_FILES_PATH="' + meson.current_source_dir() + '/../files"',
172   '-DGST_USE_UNSTABLE_API',
173 ]
174
175 pluginsdirs = []
176 if gst_dep.type_name() == 'pkgconfig'
177   pbase = dependency('gstreamer-plugins-base-' + api_version, required: true)
178   pluginsdirs = [gst_dep.get_variable('pluginsdir'),
179                  pbase.get_variable('pluginsdir')]
180   gst_plugin_scanner_dir = gst_dep.get_variable('pluginscannerdir')
181 else
182   gst_plugin_scanner_dir = subproject('gstreamer').get_variable('gst_scanner_dir')
183 endif
184 gst_plugin_scanner_path = join_paths(gst_plugin_scanner_dir, 'gst-plugin-scanner')
185
186 # fake device drivers: we could run hardware element tests against dummy drivers
187 # v4l2: vivo (part of normal kernel)
188 #   modprobe vivo;
189 #   gst-launch v4l2src device="/dev/video1" ! xvimagesink;
190 #   rmmod vivo
191 #
192 # alsa: snd-dummy (part of normal alsa, not removable)
193 #   modprobe snd-dummy;
194 #   gst-launch alsasrc device="hw:2" ! fakesink
195 #   gst-launch fakesrc ! alsasink device="hw:2"
196 #
197 # need a way to figure out value for the device property
198 state_ignore_elements = '''aasink autoaudiosrc autoaudiosink autovideosrc
199  autovideosink cacasink cairotextoverlay gtkglsink gtksink jackaudiosrc
200  jackaudiosink osssrc osssink osxaudiosink osxaudiosrc osxvideosrc osxvideosink
201  pulsesink pulsesrc pulsemixer v4l2src'''
202
203 # FIXME: check, also + PTHREAD_CFLAGS
204 test_deps = [gst_dep, gstbase_dep, gstnet_dep, gstcheck_dep, gstaudio_dep,
205   gstvideo_dep, gstpbutils_dep, gstrtp_dep, gstrtsp_dep, gsttag_dep,
206   gstapp_dep, gio_dep, valgrind_dep]
207
208 # FIXME: add valgrind suppression common/gst.supp gst-plugins-good.supp
209 foreach t : good_tests
210   fname = '@0@.c'.format(t.get(0))
211   test_name = t.get(4, t.get(0)).underscorify()
212   extra_sources = t.get(3, [ ])
213   extra_deps = t.get(2, [ ])
214   skip_test = t.get(1, false)
215   if not skip_test
216     env = environment()
217     env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '')
218     env.set('GST_STATE_IGNORE_ELEMENTS', state_ignore_elements)
219     env.set('CK_DEFAULT_TIMEOUT', '20')
220     env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer', 'gst-plugins-base',
221       'timecode', 'gst-plugins-good@' + meson.project_build_root())
222     env.set('GST_PLUGIN_PATH_1_0', [meson.global_build_root()] + pluginsdirs)
223     env.set('GSETTINGS_BACKEND', 'memory')
224
225     env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name)))
226     env.set('GST_PLUGIN_SCANNER_1_0', gst_plugin_scanner_path)
227     exe = executable(test_name, fname, extra_sources,
228       include_directories : [configinc, libsinc],
229       c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines,
230       dependencies : [libm] + test_deps + extra_deps,
231     )
232     test(test_name, exe, env: env, timeout: 3 * 60)
233   endif
234 endforeach
235
236 # orc tests
237 orc_tests = [
238   ['orc_deinterlace', files('../../gst/deinterlace/tvtime.orc')],
239   ['orc_videomixer', files('../../gst/videomixer/videomixerorc.orc')],
240   ['orc_videobox', files('../../gst/videobox/gstvideoboxorc.orc')],
241 ]
242
243 orc_test_dep = dependency('', required : false)
244 if have_orcc
245   # FIXME: there should really just be a separate orc-test-0.4.pc file for this
246   if orc_dep.type_name() == 'pkgconfig'
247     orc_test_dep = cc.find_library('orc-test-0.4', required : false)
248   else
249     orc_test_dep = dependency('', fallback: ['orc', 'orc_test_dep'], required: false)
250   endif
251 endif
252
253 if have_orcc and orc_test_dep.found()
254   foreach t : orc_tests
255     tname = t[0]
256     torcfile = t[1]
257     tcfilename = '@0@.c'.format(tname)
258     test_c = custom_target(tcfilename,
259       output: tcfilename,
260       input: torcfile,
261       command: [orcc, '--include', 'stdint.h', '--test', '-o', '@OUTPUT@', '@INPUT@'])
262     test_exe = executable(tname, test_c, dependencies: [orc_dep, orc_test_dep])
263     test(tname, test_exe)
264   endforeach
265 endif