1have_registry = true # FIXME get_option('registry')
2
3# name, condition when to skip the test and extra dependencies
4base_tests = [
5  [ 'gst/typefindfunctions.c', not have_registry ],
6  [ 'libs/audio.c' ],
7  [ 'libs/audiocdsrc.c' ],
8  [ 'libs/audiodecoder.c' ],
9  [ 'libs/audioencoder.c' ],
10  [ 'libs/baseaudiovisualizer.c' ],
11  [ 'libs/discoverer.c' ],
12  [ 'libs/fft.c' ],
13  [ 'libs/libsabi.c' ],
14  [ 'libs/mikey.c' ],
15  [ 'libs/navigation.c' ],
16  [ 'libs/pbutils.c' ],
17  [ 'libs/profile.c' ],
18  [ 'libs/rtp.c' ],
19  [ 'libs/rtpbasedepayload.c' ],
20  [ 'libs/rtpbasepayload.c' ],
21  [ 'libs/rtsp.c' ],
22  [ 'libs/sdp.c' ],
23  [ 'libs/tag.c' ],
24  [ 'libs/video.c' ],
25  [ 'libs/videoanc.c' ],
26  [ 'libs/videoencoder.c' ],
27  [ 'libs/videodecoder.c' ],
28  [ 'libs/videotimecode.c' ],
29  [ 'libs/xmpwriter.c' ],
30  [ 'elements/adder.c' ],
31  [ 'elements/appsink.c' ],
32  [ 'elements/appsrc.c' ],
33  [ 'elements/audioconvert.c' ],
34  [ 'elements/audiointerleave.c' ],
35  [ 'elements/audiomixer.c', false, [ gst_controller_dep ] ],
36  [ 'elements/audiorate.c' ],
37  [ 'elements/audiotestsrc.c' ],
38  [ 'elements/audioresample.c' ],
39  [ 'elements/compositor.c' ],
40  [ 'elements/decodebin.c' ],
41  [ 'elements/overlaycomposition.c' ],
42  [ 'elements/playbin.c' ],
43  [ 'elements/playsink.c' ],
44  [ 'elements/streamsynchronizer.c' ],
45  [ 'elements/subparse.c' ],
46  [ 'elements/urisourcebin.c' ],
47  [ 'elements/videoconvert.c' ],
48  [ 'elements/videorate.c' ],
49  [ 'elements/videoscale.c' ],
50  [ 'elements/videotestsrc.c' ],
51  [ 'elements/volume.c', false, [ gst_controller_dep ] ],
52  [ 'generic/clock-selection.c' ],
53  [ 'generic/states.c', false, [ gmodule_dep ] ],
54  [ 'pipelines/simple-launch-lines.c' ],
55  [ 'pipelines/basetime.c' ],
56  [ 'pipelines/capsfilter-renegotiation.c' ],
57  [ 'pipelines/gio.c' ],
58  [ 'pipelines/streamsynchronizer.c' ],
59]
60
61# FIXME: unistd dependency, unstable or not tested yet on windows
62if host_machine.system() != 'windows'
63  base_tests += [
64    [ 'libs/allocators.c', host_machine.system() != 'linux' ],
65    [ 'libs/rtspconnection.c' ],
66    [ 'elements/libvisual.c', not is_variable('libvisual_dep') or not libvisual_dep.found() ],
67    [ 'elements/encodebin.c', not theoraenc_dep.found() or not vorbisenc_dep.found() ],
68    [ 'elements/multifdsink.c', not core_conf.has('HAVE_SYS_SOCKET_H') or not core_conf.has('HAVE_UNISTD_H') ],
69    # FIXME: multisocketsink test on windows/msvc
70    [ 'elements/multisocketsink.c', not core_conf.has('HAVE_SYS_SOCKET_H') or not core_conf.has('HAVE_UNISTD_H') ],
71    [ 'elements/playbin-complex.c', not ogg_dep.found() ],
72    [ 'elements/textoverlay.c', not pango_dep.found() ],
73    [ 'elements/vorbisdec.c', not vorbis_dep.found(), [ vorbis_dep, vorbisenc_dep ] ],
74    [ 'elements/vorbistag.c', not vorbisenc_dep.found(), [ vorbis_dep, vorbisenc_dep ] ],
75    [ 'pipelines/oggmux.c', not ogg_dep.found(), [ ogg_dep, ] ],
76    # FIXME: tcp test on windows/msvc
77    [ 'pipelines/tcp.c', not core_conf.has('HAVE_SYS_SOCKET_H') or not core_conf.has('HAVE_UNISTD_H'), [giounix_dep] ],
78    [ 'pipelines/theoraenc.c', not theoraenc_dep.found(), [ theoraenc_dep ] ],
79    [ 'pipelines/vorbisenc.c', not vorbisenc_dep.found() ],
80    [ 'pipelines/vorbisdec.c', not vorbisenc_dep.found() ],
81  ]
82endif
83
84# FIXME: Unstable on Windows
85if build_gstgl and host_machine.system() != 'windows'
86  base_tests += [
87    [ 'libs/gstglcolorconvert.c', not build_gstgl, [gstgl_dep]],
88    [ 'libs/gstglcontext.c', not build_gstgl, [gstgl_dep]],
89    [ 'libs/gstglfeature.c', not build_gstgl, [gstgl_dep]],
90    [ 'libs/gstglformat.c', not build_gstgl, [gstgl_dep]],
91    [ 'libs/gstglheaders.c', not build_gstgl, [gstgl_dep]],
92    [ 'libs/gstglmatrix.c', not build_gstgl, [gstgl_dep]],
93    [ 'libs/gstglmemory.c', not build_gstgl, [gstgl_dep]],
94    [ 'libs/gstglquery.c', not build_gstgl, [gstgl_dep]],
95    [ 'libs/gstglshader.c', not build_gstgl, [gstgl_dep]],
96    [ 'libs/gstglsl.c', not build_gstgl, [gstgl_dep]],
97    [ 'libs/gstglslstage.c', not build_gstgl, [gstgl_dep]],
98    [ 'libs/gstglupload.c', not build_gstgl, [gstgl_dep]],
99    [ 'elements/glimagesink.c', not build_gstgl, [gstgl_dep]],
100    [ 'elements/glbin.c', not build_gstgl ],
101    [ 'pipelines/gl-launch-lines.c', not build_gstgl ],
102  ]
103endif
104
105# Make sure our headers are C++ clean
106if have_cxx
107  base_tests += [
108    [ 'libs/gstlibscpp.cc', false, [  ] ],
109  ]
110endif
111
112test_defines = [
113  '-UG_DISABLE_ASSERT',
114  '-UG_DISABLE_CAST_CHECKS',
115  '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_PLUGIN_LOADING_WHITELIST"',
116  '-DGST_TEST_FILES_PATH="' + meson.current_source_dir() + '/../files"',
117  '-DGST_TEST_FILE="' + meson.current_source_dir() + '/../files/partialframe.mjpeg"', # for libs/discoverer
118  '-DGST_USE_UNSTABLE_API',
119]
120
121test_deps = [gst_dep, gst_base_dep, gst_net_dep, gst_check_dep, audio_dep,
122  video_dep, pbutils_dep, rtp_dep, rtsp_dep, tag_dep, allocators_dep, app_dep,
123  fft_dep, riff_dep, sdp_dep, gio_dep] + glib_deps
124
125pluginsdirs = [  ]
126if gst_dep.type_name() == 'pkgconfig'
127  pluginsdirs = [gst_dep.get_pkgconfig_variable('pluginsdir')]
128endif
129
130foreach t : base_tests
131  fname = t.get(0)
132  test_name = fname.split('.').get(0).underscorify()
133  skip_test = false
134  extra_deps = [ ]
135
136  if t.length() >= 3
137    extra_deps = t.get(2)
138  endif
139
140  if t.length() >= 2
141    skip_test = t.get(1)
142  endif
143
144  if not skip_test
145    exe = executable(test_name, fname,
146      include_directories : [configinc],
147      c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines,
148      cpp_args : gst_plugins_base_args,
149      dependencies : [libm] + test_deps + extra_deps,
150    )
151
152    env = environment()
153    env.set('GST_PLUGIN_PATH_1_0',
154        meson.build_root(), join_paths(get_option('prefix'), plugins_install_dir),
155        pluginsdirs)
156    env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '')
157    env.set('GST_STATE_IGNORE_ELEMENTS', 'cdio cdparanoiasrc libvisual_ alsasrc alsasink')
158    env.set('CK_DEFAULT_TIMEOUT', '20')
159    env.set('GST_TAG_LICENSE_TRANSLATIONS_DICT', join_paths(gst_tag_dir, 'license-translations.dict'))
160    env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer',
161        'gst-plugins-base@' + meson.build_root())
162    env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name)))
163    test(test_name, exe, env: env, timeout: 3 * 60)
164  endif
165endforeach
166
167# videoscale tests (split in groups)
168foreach group : [1, 2, 3, 4, 5, 6]
169  vscale_test_name = 'elements-videoscale-@0@'.format(group)
170  exe = executable(vscale_test_name, join_paths('elements', 'videoscale.c'),
171      include_directories : [configinc],
172      c_args : ['-DHAVE_CONFIG_H=1', '-DVSCALE_TEST_GROUP=@0@'.format(group) ] + test_defines,
173      dependencies : [libm] + test_deps + extra_deps)
174
175  # TODO Use env.copy when it is in meson
176  env = environment()
177  env.set('GST_PLUGIN_PATH_1_0',
178      meson.build_root(), join_paths(get_option('prefix'), plugins_install_dir),
179      pluginsdirs)
180  env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '')
181  env.set('GST_STATE_IGNORE_ELEMENTS', 'cdio cdparanoiasrc libvisual_ alsasrc alsasink')
182  env.set('CK_DEFAULT_TIMEOUT', '20')
183  env.set('GST_TAG_LICENSE_TRANSLATIONS_DICT', join_paths(gst_tag_dir, 'license-translations.dict'))
184  env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer',
185      'gst-plugins-base@' + meson.build_root())
186  env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name)))
187
188  test(vscale_test_name, exe, env: env, timeout: 3 * 60)
189endforeach
190
191# orc tests
192orc_tests = [
193  ['orc_audio', files('../../gst-libs/gst/audio/gstaudiopack.orc')],
194  ['orc_video', files('../../gst-libs/gst/video/video-orc.orc')],
195  ['orc_adder', files('../../gst/adder/gstadderorc.orc')],
196  ['orc_audiomixer', files('../../gst/audiomixer/gstaudiomixerorc.orc')],
197  ['orc_compositor', files('../../gst/compositor/compositororc.orc')],
198  ['orc_volume', files('../../gst/volume/gstvolumeorc.orc')],
199  ['orc_videotestsrc', files('../../gst/videotestsrc/gstvideotestsrcorc.orc')],
200]
201
202orc_test_dep = dependency('', required : false)
203if have_orcc
204  # FIXME: there should really just be a separate orc-test-0.4.pc file for this
205  if orc_dep.type_name() == 'pkgconfig'
206    orc_test_dep = cc.find_library('orc-test-0.4', required : false)
207  endif
208  if not orc_test_dep.found()
209    orc_test_dep = dependency('', fallback: ['orc', 'orc_test_dep'], required: false)
210  endif
211endif
212
213if have_orcc and orc_test_dep.found()
214  foreach t : orc_tests
215    tname = t[0]
216    torcfile = t[1]
217    tcfilename = '@0@.c'.format(tname)
218    test_c = custom_target(tcfilename,
219      output: tcfilename,
220      input: torcfile,
221      command: [orcc, '--include', 'stdint.h', '--test', '-o', '@OUTPUT@', '@INPUT@'])
222    test_exe = executable(tname, test_c, dependencies: [orc_dep, orc_test_dep])
223    test(tname, test_exe)
224  endforeach
225endif
226