From 7ce24e6ff793dfd8aa710c2cc236002304bc0849 Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Tue, 8 Oct 2019 12:20:26 -0700 Subject: [PATCH] tests: check: initial unit test support Add minimal unit test toolchain files and a simple vaapipostproc unit test. --- meson.build | 3 ++ meson_options.txt | 1 + tests/check/elements/vaapipostproc.c | 53 ++++++++++++++++++++++++++++ tests/check/meson.build | 33 +++++++++++++++++ tests/meson.build | 4 +++ 5 files changed, 94 insertions(+) create mode 100644 tests/check/elements/vaapipostproc.c create mode 100644 tests/check/meson.build diff --git a/meson.build b/meson.build index 827dc275fa..d1cb310f5a 100644 --- a/meson.build +++ b/meson.build @@ -81,6 +81,9 @@ libudev_dep = dependency('libudev', required: false) egl_dep = dependency('egl', required: false) gl_dep = dependency('gl', required: false) glesv2_dep = dependency('glesv2', required: false) +gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req, + required : get_option('tests'), + fallback : ['gstreamer', 'gst_check_dep']) libdl_dep = cc.find_library('dl', required: false) wayland_client_dep = dependency('wayland-client', version: libwayland_req, required: false) wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', required: false) diff --git a/meson_options.txt b/meson_options.txt index 24b2c3b044..fd4d92e6e5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,5 +7,6 @@ option('with_egl', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'aut # Common feature options option('examples', type : 'feature', value : 'auto', yield : true) +option('tests', type : 'feature', value : 'auto', yield : true) option('doc', type : 'feature', value : 'auto', yield: true, description: 'Enable documentation.') diff --git a/tests/check/elements/vaapipostproc.c b/tests/check/elements/vaapipostproc.c new file mode 100644 index 0000000000..9190fcfdac --- /dev/null +++ b/tests/check/elements/vaapipostproc.c @@ -0,0 +1,53 @@ +/* + * vaapipostproc.c - GStreamer unit test for the vaapipostproc element + * + * Copyright (C) 2019 Intel Corporation + * Author: U. Artie Eoff + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +GST_START_TEST (test_make) +{ + GstElement *vaapipostproc; + + vaapipostproc = gst_element_factory_make ("vaapipostproc", "vaapipostproc"); + fail_unless (vaapipostproc != NULL, "Failed to create vaapipostproc element"); + + gst_object_unref (vaapipostproc); +} + +GST_END_TEST; + +static Suite * +vaapipostproc_suite (void) +{ + Suite *s = suite_create ("vaapipostproc"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_make); + + return s; +} + +GST_CHECK_MAIN (vaapipostproc); diff --git a/tests/check/meson.build b/tests/check/meson.build new file mode 100644 index 0000000000..1b2a4a01dd --- /dev/null +++ b/tests/check/meson.build @@ -0,0 +1,33 @@ +tests = [ + [ 'elements/vaapipostproc' ], +] + +test_deps = [gst_dep, gstcheck_dep] +test_defines = [ + '-UG_DISABLE_ASSERT', + '-UG_DISABLE_CAST_CHECKS', + '-DGST_USE_UNSTABLE_API', +] + +pluginsdirs = [] +if gst_dep.type_name() == 'pkgconfig' + pluginsdirs = [gst_dep.get_pkgconfig_variable('pluginsdir')] +endif + +foreach t : tests + fname = '@0@.c'.format(t.get(0)) + test_name = t.get(0).underscorify() + extra_sources = [ ] + extra_deps = [ ] + env = environment() + env.set('CK_DEFAULT_TIMEOUT', '20') + env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '') + env.set('GST_PLUGIN_PATH_1_0', [meson.build_root()] + pluginsdirs) + env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name))) + exe = executable(test_name, fname, extra_sources, + include_directories : [configinc, libsinc], + c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines, + dependencies : test_deps + extra_deps, + ) + test(test_name, exe, env: env, timeout: 3 * 60) +endforeach diff --git a/tests/meson.build b/tests/meson.build index b27c0dab83..2b8b8155df 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,3 +1,7 @@ +if not get_option('tests').disabled() and gstcheck_dep.found() + subdir('check') +endif + if not get_option('examples').disabled() subdir('examples') subdir('internal')