From 787f47604d7a1903b95e108fa977a6d7596219e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 26 Sep 2016 14:30:00 +0100 Subject: [PATCH] meson: add unit tests Only works properly in an installed setup currently, most likely won't work with a subprojects setup yet. --- ext/vpx/meson.build | 3 + meson.build | 7 +- tests/check/getpluginsdir | 25 +++++ tests/check/meson.build | 227 +++++++++++++++++++++++++++++++++++--- 4 files changed, 243 insertions(+), 19 deletions(-) create mode 100644 tests/check/getpluginsdir diff --git a/ext/vpx/meson.build b/ext/vpx/meson.build index f19e8db97c..9651b95550 100644 --- a/ext/vpx/meson.build +++ b/ext/vpx/meson.build @@ -33,9 +33,12 @@ if vpx_dep.found() if cc.links(link_code, args : ['-lvpx']) vpx_args += extra_define message('libvpx provides @0@ interface (@1@)'.format(f.get(3),f.get(1))) + have_vpx_feature = true else message('libvpx does not provide @0@ interface (@1@)'.format(f.get(3),f.get(1))) + have_vpx_feature = false endif + set_variable('have_' + f.get(3).to_lower().underscorify(), have_vpx_feature) endforeach if vpx_args.length() == 0 diff --git a/meson.build b/meson.build index fe6b3b9dde..c15c82d7d7 100644 --- a/meson.build +++ b/meson.build @@ -130,6 +130,7 @@ cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version)) cdata.set('GST_LICENSE', '"LGPL"') cdata.set('PACKAGE', '"gst-plugins-good"') cdata.set('GETTEXT_PACKAGE', '"gst-plugins-good-1.0"') +cdata.set('PACKAGE_NAME', '"GStreamer Good Plug-ins"') cdata.set('GST_PACKAGE_NAME', '"GStreamer Good Plug-ins"') cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"') # FIXME: make configurable @@ -149,6 +150,8 @@ gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req, fallback : ['gst-plugins-base', 'pbutils_dep']) gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req, fallback : ['gst-plugins-base', 'allocators_dep']) +gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req, + fallback : ['gst-plugins-base', 'app_dep']) gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req, fallback : ['gst-plugins-base', 'audio_dep']) gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req, @@ -211,10 +214,6 @@ foreach d : deps endif endforeach -if cc.has_header('valgrind.h') - cdata.set('HAVE_VALGRIND', 1) -endif - gst_plugins_good_args = ['-DHAVE_CONFIG_H'] configinc = include_directories('.') libsinc = include_directories('gst-libs') diff --git a/tests/check/getpluginsdir b/tests/check/getpluginsdir new file mode 100644 index 0000000000..102e3c8230 --- /dev/null +++ b/tests/check/getpluginsdir @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +builddir = os.environ['MESON_BUILD_ROOT'] + +res = '' +args = sys.argv[1:] +for i in range(0, len(args), 2): + project = args[i] + pkg_name = args[i + 1] + path = os.path.join(builddir, 'subprojects', project) + if os.path.exists(path): + res += ':' + path + else: + try: + res += ':' + subprocess.check_output(['pkg-config', + '--variable=pluginsdir', + pkg_name]).decode() + except subprocess.CalledProcessError: + exit(1) + +print(res.strip(":")) diff --git a/tests/check/meson.build b/tests/check/meson.build index 1030cc102b..672184c195 100644 --- a/tests/check/meson.build +++ b/tests/check/meson.build @@ -1,21 +1,218 @@ -libparser = library('libparser', - 'elements/parser.c', +# FIXME: use dependency('valgrind') once we have a method to get the includes +if cc.has_header('valgrind/valgrind.h') + cdata.set('HAVE_VALGRIND', 1) +endif + +# internal helper lib for unit testing audio parsers +libparser = static_library('libparser', 'elements/parser.c', c_args : gst_plugins_good_args + ['-DGST_USE_UNSTABLE_API'], include_directories : [configinc], dependencies : [gstcheck_dep], -) + install : false) -# Only a few so far to sketch the waters. +libparser_dep = declare_dependency(link_with : libparser, + dependencies : gstcheck_dep) -test('generic/states', executable('states', - 'generic/states.c', - c_args : gst_plugins_good_args, - include_directories : [configinc], - dependencies : [gstcheck_dep],) -) +# name, condition when to skip the test and extra dependencies +good_tests = [ + [ 'elements/audioamplify' ], + [ 'elements/audiochebband' ], + [ 'elements/audiocheblimit' ], + [ 'elements/audiodynamic' ], + [ 'elements/audioecho' ], + [ 'elements/audiofirfilter' ], + [ 'elements/audioiirfilter' ], + [ 'elements/audioinvert' ], + [ 'elements/audiopanorama' ], + [ 'elements/audiowsincband' ], + [ 'elements/audiowsinclimit' ], + [ 'elements/alphacolor' ], + [ 'elements/alpha' ], + [ 'elements/aacparse', false, [libparser_dep] ], + [ 'elements/ac3parse', false, [libparser_dep] ], + [ 'elements/amrparse', false, [libparser_dep] ], + [ 'elements/flacparse', false, [libparser_dep] ], + [ 'elements/mpegaudioparse', false, [libparser_dep] ], + [ 'elements/wavpackparse' ], + [ 'elements/autodetect' ], + [ 'elements/avimux' ], + [ 'elements/avisubtitle' ], + [ 'elements/capssetter' ], + [ 'elements/deinterlace' ], + [ 'elements/dtmf' ], + [ 'pipelines/flacdec', not flac_dep.found() ], + [ 'elements/flvdemux' ], + [ 'elements/flvmux' ], + [ 'elements/qtmux' ], + [ 'elements/qtdemux' ], + [ 'elements/mulawdec' ], + [ 'elements/mulawenc' ], + [ 'elements/gdkpixbufsink', not gdkpixbuf_dep.found(), [gdkpixbuf_dep] ], + [ 'elements/gdkpixbufoverlay', not gdkpixbuf_dep.found() ], + [ 'elements/icydemux' ], + [ 'elements/id3demux' ], + [ 'elements/imagefreeze' ], + [ 'elements/deinterleave' ], + [ 'elements/interleave' ], + [ 'elements/jpegdec', not jpeglib.found() ], + [ 'elements/jpegenc', not jpeglib.found() ], + [ 'elements/level' ], + [ 'elements/matroskademux' ], + [ 'elements/matroskamux' ], + [ 'elements/matroskaparse' ], + [ 'elements/multifile' ], + [ 'elements/splitmux' ], + [ 'elements/rganalysis' ], + [ 'elements/rglimiter' ], + [ 'elements/rgvolume' ], + [ 'elements/rtp-payloading' ], + [ 'elements/rtph261' ], + [ 'elements/rtph263' ], + [ 'elements/rtpvp9' ], + [ 'elements/rtpaux' ], + [ 'elements/rtpbin' ], + [ 'elements/rtpbin_buffer_list' ], + [ 'elements/rtpcollision' ], + [ 'elements/rtpjitterbuffer' ], + [ 'elements/rtpmux' ], + [ 'elements/rtprtx' ], + [ 'elements/rtpsession' ], + [ 'elements/souphttpsrc', not libsoup_dep.found(), [libsoup_dep] ], + [ 'elements/spectrum' ], +# [ 'elements/sunaudio' ], + [ 'elements/shapewipe' ], + [ 'elements/id3v2mux', not taglib_dep.found() ], + [ 'elements/apev2mux', not taglib_dep.found() ], + [ 'elements/udpsink' ], + [ 'elements/udpsrc' ], + [ 'elements/videobox' ], + [ 'elements/aspectratiocrop' ], + [ 'elements/videocrop' ], + [ 'elements/videofilter' ], + [ 'elements/videomixer' ], + [ 'elements/vp8enc', not have_vp8_encoder ], + [ 'elements/vp8dec', not have_vp8_decoder ], + [ 'elements/vp9enc', not have_vp9_encoder ], + [ 'pipelines/wavenc' ], + [ 'elements/wavpackdec', not wavpack_dep.found() ], + [ 'elements/wavpackenc', not wavpack_dep.found() ], + [ 'pipelines/wavpack', not wavpack_dep.found() ], + [ 'elements/wavparse' ], + [ 'elements/y4menc' ], + [ 'pipelines/effectv' ], + [ 'elements/equalizer' ], + [ 'generic/states' ], + [ 'pipelines/simple-launch-lines' ], + [ 'pipelines/tagschecking' ], +] -# FIXME, set up registry and envvars -test('alphacolor', - executable('alphacolor', 'elements/alphacolor.c', - dependencies : [gstcheck_dep, gstvideo_dep]) -) +# FIXME: valgrind elements/rtp-payloading - needs fixing +# elements/videocrop should be disabled since it takes way too long in valgrind + +foo=''' +if HAVE_ORC +check_orc = orc/deinterlace orc/videomixer orc/videobox +else +check_orc = +endif +''' + +test_defines = [ + '-UG_DISABLE_ASSERT', + '-UG_DISABLE_CAST_CHECKS', + '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_PLUGIN_LOADING_WHITELIST"', + '-DGST_TEST_FILES_PATH="' + meson.source_root() + '/tests/files"', + '-DGST_USE_UNSTABLE_API', +] + +getpluginsdir = find_program('getpluginsdir') +runcmd = run_command(getpluginsdir, 'gstreamer', 'gstreamer-1.0') +if runcmd.returncode() == 0 + other_plugins_dir = runcmd.stdout().strip() + message('Using GStreamer plug-ins in ' + other_plugins_dir) +else + error('Could not determine GStreamer plugins directory for unit tests.') +endif + +# fake device drivers: we could run hardware element tests against dummy drivers +# v4l2: vivo (part of normal kernel) +# modprobe vivo; +# gst-launch v4l2src device="/dev/video1" ! xvimagesink; +# rmmod vivo +# +# alsa: snd-dummy (part of normal alsa, not removable) +# modprobe snd-dummy; +# gst-launch alsasrc device="hw:2" ! fakesink +# gst-launch fakesrc ! alsasink device="hw:2" +# +# need a way to figure out value for the device property +state_ignore_elements = '''aasink autoaudiosrc autoaudiosink autovideosrc + autovideosink cacasink cairotextoverlay jackaudiosrc jackaudiosink + osssrc osssink osxaudiosink osxaudiosrc osxvideosrc osxvideosink + pulsesink pulsesrc pulsemixer v4l2src''' + +# FIXME: WHITELIST should probably refer to core/base paths properly +# (need to make this work right for the subproject case too) +test_env = [ + 'GST_PLUGIN_SYSTEM_PATH_1_0=', + 'GST_PLUGIN_PATH_1_0=' + meson.build_root() + '/gst:' + meson.build_root() + '/ext:' + meson.build_root() + '/sys:' + other_plugins_dir, + 'GST_PLUGIN_LOADING_WHITELIST=gstreamer:gst-plugins-base:gst-plugins-good@' + meson.build_root(), + 'GST_STATE_IGNORE_ELEMENTS=@0@'.format(state_ignore_elements), + 'CK_DEFAULT_TIMEOUT=20', + 'GSETTINGS_BACKEND=memory', +] + +# FIXME: check, also + PTHREAD_CFLAGS +test_deps = [gst_dep, gstbase_dep, gstnet_dep, gstcheck_dep, gstaudio_dep, + gstvideo_dep, gstpbutils_dep, gstrtp_dep, gstrtsp_dep, gsttag_dep, + gstapp_dep, gio_dep] + glib_deps + +# FIXME: add valgrind suppression common/gst.supp gst-plugins-good.supp +foreach t : good_tests + test_name = t.get(0) + extra_deps = [ ] + if t.length() == 3 + extra_deps = t.get(2) + skip_test = t.get(1) + elif t.length() == 2 + skip_test = t.get(1) + else + skip_test = false + endif + if not skip_test + exe = executable(test_name, '@0@.c'.format(test_name), + include_directories : [configinc], + c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines, + dependencies : [libm] + test_deps + extra_deps, + ) + test(test_name, exe, + env: test_env + ['GST_REGISTRY=@0@/@1@.registry'.format(meson.current_build_dir(), test_name)], + timeout: 3 * 60 + ) + endif +endforeach + +# FIXME: orc tests +fixme_orc_tests=''' +orc_deinterlace_CFLAGS = $(ORC_CFLAGS) +orc_deinterlace_LDADD = $(ORC_LIBS) -lorc-test-0.4 +nodist_orc_deinterlace_SOURCES = orc/deinterlace.c +orc_videomixer_CFLAGS = $(ORC_CFLAGS) +orc_videomixer_LDADD = $(ORC_LIBS) -lorc-test-0.4 +nodist_orc_videomixer_SOURCES = orc/videomixer.c +orc_videobox_CFLAGS = $(ORC_CFLAGS) +orc_videobox_LDADD = $(ORC_LIBS) -lorc-test-0.4 +nodist_orc_videobox_SOURCES = orc/videobox.c + +orc/deinterlace.c: $(top_srcdir)/gst/deinterlace/tvtime.orc + $(MKDIR_P) orc/ + $(ORCC) --test -o $@ $< + +orc/videomixer.c: $(top_srcdir)/gst/videomixer/videomixerorc.orc + $(MKDIR_P) orc/ + $(ORCC) --test -o $@ $< + +orc/videobox.c: $(top_srcdir)/gst/videobox/gstvideoboxorc.orc + $(MKDIR_P) orc/ + $(ORCC) --test -o $@ $< +'''