Skip to content

Commit

Permalink
test stub
Browse files Browse the repository at this point in the history
  • Loading branch information
MaZderMind committed Sep 28, 2020
1 parent 8475731 commit 584c091
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 23 deletions.
35 changes: 17 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,35 @@ build: builddir
builddir:
meson builddir

clean:
tests/builddir:
cd tests && meson builddir

clean: builddir
ninja -C builddir clean

format:
clang-format -i src/**
clang-format -i src/*.[ch] tests/elements/*.[ch]

inspect:
gst-inspect-1.0 builddir/libgstebur128.so

inspect-ebur128:
GST_PLUGIN_PATH=$(realpath builddir) gst-inspect-1.0 ebur128

inspect-ebur128display:
GST_PLUGIN_PATH=$(realpath builddir) gst-inspect-1.0 ebur128display

inspect-ebur128graph:
GST_PLUGIN_PATH=$(realpath builddir) gst-inspect-1.0 ebur128graph

DEBUG=0
#DEBUG=9
run-tests: builddir
cd builddir && meson test

run-ebur128:
GST_PLUGIN_PATH=$(realpath builddir) GST_DEBUG=ebur128:$(DEBUG) gst-launch-1.0 -m \
GST_PLUGIN_PATH=$(realpath builddir) GST_DEBUG=ebur128:0 gst-launch-1.0 -m \
filesrc location=example-audio/music.mp3 ! mpegaudioparse ! mpg123audiodec ! \
ebur128 momentary=true shortterm=true global=true window=5000 range=true sample-peak=true true-peak=true ! \
ebur128 momentary=true shortterm=true global=true window=5000 range=true sample-peak=true true-peak=true interval=100000000 ! \
autoaudiosink

run-ebur128-with-seek:
GST_PLUGIN_PATH=$(realpath builddir) GST_DEBUG=ebur128:$(DEBUG) gst-launch-1.0 -m \
GST_PLUGIN_PATH=$(realpath builddir) GST_DEBUG=ebur128:0 gst-launch-1.0 -m \
filesrc location=example-audio/music.mp3 ! \
mpegaudioparse ! mpg123audiodec ! \
ebur128 ! \
Expand All @@ -40,13 +42,10 @@ run-ebur128-with-seek:
t. ! queue ! audioconvert ! wavescope ! ximagesink \
t. ! queue ! autoaudiosink

run-ebur128display:
GST_PLUGIN_PATH=$(realpath builddir) GST_DEBUG=ebur128:9 gst-launch-1.0 audiotestsrc ! \
audio/x-raw,format=S16LE,channels=2,rate=48000 ! \
ebur128display ! \
video/x-raw,format=RGBA,width=640,height=480,framerate=60/1 !
glimagesink


run-ebur128graph:
GST_PLUGIN_PATH=$(realpath builddir) GST_DEBUG=ebur128:9 gst-launch-1.0 ! \
filesrc location=example-audio/music.mp3 ! mpegaudioparse ! mpg123audiodec ! tee name=t \
t. ! queue ! ebur128graph ! video/x-raw,format=RGBA,width=640,height=480,framerate=30/1 ! glimagesink \
t. ! queue ! autoaudiosink

.PHONY: build inspect inspect-ebur128 run-ebur128 format
13 changes: 8 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ gst_version = meson.project_version()
api_version = '1.0'

gst_dep = dependency('gstreamer-1.0', fallback : ['gstreamer', 'gst_dep'])
gstbase_dep = dependency('gstreamer-base-1.0', fallback : ['gstreamer', 'gst_base_dep'])
gstaudio_dep = dependency('gstreamer-audio-1.0', fallback : ['gst-plugins-base', 'audio_dep'])

libebur128_dep = dependency('libebur128')

plugin_c_args = ['-DHAVE_CONFIG_H']
Expand All @@ -22,18 +25,18 @@ cdata.set_quoted('GST_PACKAGE_NAME', 'GStreamer ebur128 Plug-ins')
cdata.set_quoted('GST_PACKAGE_ORIGIN', 'https://mazdermind.de')
configure_file(output : 'config.h', configuration : cdata)

gstaudio_dep = dependency('gstreamer-audio-1.0',
fallback: ['gst-plugins-base', 'audio_dep'])

# Plugin 1
plugin_sources = [
'src/gstebur128.c',
]

ebur128 = library('gstebur128',
plugin_sources,
c_args: plugin_c_args,
dependencies : [gst_dep, gstaudio_dep, libebur128_dep],
dependencies : [gst_dep, gstbase_dep, gstaudio_dep, libebur128_dep],
install : true,
install_dir : plugins_install_dir,
)

if not get_option('tests').disabled()
subdir('tests')
endif
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('tests', type : 'feature', value : 'auto', yield : true)
27 changes: 27 additions & 0 deletions tests/elements/ebur128.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS

#ifndef GST_PLUGIN_LOADING_WHITELIST
#define GST_PLUGIN_LOADING_WHITELIST ""
#endif

#include <gst/audio/audio.h>
#include <gst/check/gstcheck.h>

GST_START_TEST(test_foo) {
// nop
}
GST_END_TEST;

static Suite *level_suite(void) {
Suite *s = suite_create("ebur128");
TCase *tc_general = tcase_create("general");

suite_add_tcase(s, tc_general);
tcase_add_test(tc_general, test_foo);

return s;
}

GST_CHECK_MAIN(level);
57 changes: 57 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
gstcheck_dep = dependency('gstreamer-check-1.0', fallback : ['gstreamer', 'gst_check_dep'])

test_deps = [gst_dep, gstbase_dep, gstcheck_dep, gstaudio_dep]

test_defines = [
'-UG_DISABLE_ASSERT',
'-UG_DISABLE_CAST_CHECKS',
'-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_PLUGIN_LOADING_WHITELIST"',
#'-DGST_TEST_FILES_PATH="' + meson.current_source_dir() + '/../files"',
'-DGST_USE_UNSTABLE_API',
]

pluginsdirs = []
if gst_dep.type_name() == 'pkgconfig'
pbase = dependency('gstreamer-plugins-base-' + api_version, required: true)
pluginsdirs = [gst_dep.get_pkgconfig_variable('pluginsdir'),
pbase.get_pkgconfig_variable('pluginsdir')]

gst_plugin_scanner_dir = gst_dep.get_pkgconfig_variable('pluginscannerdir')
else
gst_plugin_scanner_dir = subproject('gstreamer').get_variable('gst_scanner_dir')
endif
gst_plugin_scanner_path = join_paths(gst_plugin_scanner_dir, 'gst-plugin-scanner')


tests = [
# name, skip?, extra_deps, extra_sources
[ 'elements/ebur128', false, [gst_dep, gstaudio_dep, libebur128_dep] ],
]


foreach t : tests
fname = '@0@.c'.format(t.get(0))
test_name = t.get(0).underscorify()
skip_test = t.get(1, false)
extra_deps = t.get(2, [ ])
extra_sources = t.get(3, [ ])

if not skip_test
env = environment()
env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '')
env.set('CK_DEFAULT_TIMEOUT', '20')
env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer', 'gst-plugins-base',
'gst-plugins-good@' + meson.build_root()) # 'timecode' ?
env.set('GST_PLUGIN_PATH_1_0', [meson.build_root()] + pluginsdirs)
env.set('GSETTINGS_BACKEND', 'memory')

env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name)))
env.set('GST_PLUGIN_SCANNER_1_0', gst_plugin_scanner_path)

exe = executable(test_name, fname, extra_sources,
c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines,
dependencies : test_deps + extra_deps,
)
test(test_name, exe, env: env, timeout: 3 * 60)
endif
endforeach

0 comments on commit 584c091

Please sign in to comment.