From 9089df6d11a0b34f893d0e6369499e9fd02a9a81 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 7 Sep 2016 10:59:22 -0300 Subject: [PATCH] validate:meson: Add tests --- meson.build | 2 ++ validate/meson.build | 2 +- validate/tests/check/getpluginsdir | 26 ++++++++++++++ validate/tests/check/meson.build | 54 ++++++++++++++++++++++++++++++ validate/tests/meson.build | 4 +++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 validate/tests/check/getpluginsdir create mode 100644 validate/tests/check/meson.build create mode 100644 validate/tests/meson.build diff --git a/meson.build b/meson.build index 4c95f83f1e..44a51514e1 100644 --- a/meson.build +++ b/meson.build @@ -36,6 +36,8 @@ gst_pbutils_dep = dependency('gstreamer-pbutils-' + apiversion, version : gst_re fallback : ['gst-plugins-base', 'pbutils_dep']) gst_video_dep = dependency('gstreamer-video-' + apiversion, version : gst_req, fallback : ['gst-plugins-base', 'video_dep']) +gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req, + fallback : ['gstreamer', 'gst_check_dep']) glib_dep = dependency('glib-2.0', version: glib_req) gio_dep = dependency('gio-2.0', version: glib_req) gmodule_dep = dependency('gmodule-2.0', version: glib_req) diff --git a/validate/meson.build b/validate/meson.build index 3f5c30745d..08b7fddcfd 100644 --- a/validate/meson.build +++ b/validate/meson.build @@ -15,5 +15,5 @@ subdir('launcher') subdir('tools') subdir('docs') subdir('pkgconfig') -#subdir('tests') +subdir('tests') #subdir('po') diff --git a/validate/tests/check/getpluginsdir b/validate/tests/check/getpluginsdir new file mode 100644 index 0000000000..98054b401a --- /dev/null +++ b/validate/tests/check/getpluginsdir @@ -0,0 +1,26 @@ +#!/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/validate/tests/check/meson.build b/validate/tests/check/meson.build new file mode 100644 index 0000000000..9c555eb286 --- /dev/null +++ b/validate/tests/check/meson.build @@ -0,0 +1,54 @@ +# tests and condition when to skip the test +validate_tests = [ + ['validate/padmonitor'], + ['validate/monitoring'], + ['validate/reporting'], + ['validate/overrides'] +] + +test_defines = [ + '-UG_DISABLE_ASSERT', + '-UG_DISABLE_CAST_CHECKS', + '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_STATE_IGNORE_ELEMENTS"', + '-DTESTFILE="' + meson.current_source_dir() + '/meson.build"', + '-DGST_USE_UNSTABLE_API', +] + +getpluginsdir = find_program('getpluginsdir') +runcmd = run_command(getpluginsdir, 'gstreamer', 'gstreamer-' + apiversion) +if runcmd.returncode() == 0 + needed_plugins_dirs = runcmd.stdout().strip() + message('Using GStreamer plug-ins in ' + needed_plugins_dirs) +else + error('Could not determine GStreamer core plugins directory for unit tests.') +endif + +test_env = [ + 'GST_PLUGIN_SYSTEM_PATH_1_0=', + 'GST_PLUGIN_PATH_1_0=' + needed_plugins_dirs, + 'GST_PLUGIN_SCANNER_1_0='+ meson.build_root() + '/libs/gst/helpers/gst-plugin-scanner', + 'GST_STATE_IGNORE_ELEMENTS=', + 'CK_DEFAULT_TIMEOUT=20', +] + +foreach t : validate_tests + test_name = t.get(0) + if 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), + 'validate/test-utils.c', + c_args : gst_c_args + test_defines, + include_directories : [inc_dirs], + dependencies : [validate_dep, gstcheck_dep], + ) + test(test_name, exe, + env: test_env + ['GST_REGISTRY=@0@/@1@.registry'.format(meson.current_build_dir(), test_name)] + ) + endif +endforeach + diff --git a/validate/tests/meson.build b/validate/tests/meson.build new file mode 100644 index 0000000000..76b079162c --- /dev/null +++ b/validate/tests/meson.build @@ -0,0 +1,4 @@ +# FIXME: make check work on windows +if host_machine.system() != 'windows' +subdir('check') +endif