tests: check: initial unit test support

Add minimal unit test toolchain files and a simple
vaapipostproc unit test.
This commit is contained in:
U. Artie Eoff 2019-10-08 12:20:26 -07:00
parent 97aabe8784
commit 7ce24e6ff7
5 changed files with 94 additions and 0 deletions

View file

@ -81,6 +81,9 @@ libudev_dep = dependency('libudev', required: false)
egl_dep = dependency('egl', required: false) egl_dep = dependency('egl', required: false)
gl_dep = dependency('gl', required: false) gl_dep = dependency('gl', required: false)
glesv2_dep = dependency('glesv2', 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) libdl_dep = cc.find_library('dl', required: false)
wayland_client_dep = dependency('wayland-client', version: libwayland_req, required: false) wayland_client_dep = dependency('wayland-client', version: libwayland_req, required: false)
wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', required: false) wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', required: false)

View file

@ -7,5 +7,6 @@ option('with_egl', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'aut
# Common feature options # Common feature options
option('examples', type : 'feature', value : 'auto', yield : true) option('examples', type : 'feature', value : 'auto', yield : true)
option('tests', type : 'feature', value : 'auto', yield : true)
option('doc', type : 'feature', value : 'auto', yield: true, option('doc', type : 'feature', value : 'auto', yield: true,
description: 'Enable documentation.') description: 'Enable documentation.')

View file

@ -0,0 +1,53 @@
/*
* vaapipostproc.c - GStreamer unit test for the vaapipostproc element
*
* Copyright (C) 2019 Intel Corporation
* Author: U. Artie Eoff <ullysses.a.eoff@intel.com>
*
* 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/check/gstcheck.h>
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);

33
tests/check/meson.build Normal file
View file

@ -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

View file

@ -1,3 +1,7 @@
if not get_option('tests').disabled() and gstcheck_dep.found()
subdir('check')
endif
if not get_option('examples').disabled() if not get_option('examples').disabled()
subdir('examples') subdir('examples')
subdir('internal') subdir('internal')