tests: check: initial unit test support
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Tue, 8 Oct 2019 19:20:26 +0000 (12:20 -0700)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Wed, 16 Oct 2019 19:49:17 +0000 (12:49 -0700)
Add minimal unit test toolchain files and a simple
vaapipostproc unit test.

meson.build
meson_options.txt
tests/check/elements/vaapipostproc.c [new file with mode: 0644]
tests/check/meson.build [new file with mode: 0644]
tests/meson.build

index 827dc27..d1cb310 100644 (file)
@@ -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)
index 24b2c3b..fd4d92e 100644 (file)
@@ -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 (file)
index 0000000..9190fcf
--- /dev/null
@@ -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);
diff --git a/tests/check/meson.build b/tests/check/meson.build
new file mode 100644 (file)
index 0000000..1b2a4a0
--- /dev/null
@@ -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
index b27c0da..2b8b815 100644 (file)
@@ -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')