From 12d8448cf85510cce354fdc1b22319b163d9b51a Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 29 Jan 2019 13:45:49 +0900 Subject: [PATCH] tests: Add inconsistent init/deinit test case --- tests/check/Makefile.am | 1 + tests/check/ges/negative.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/check/meson.build | 1 + 3 files changed, 75 insertions(+) create mode 100644 tests/check/ges/negative.c diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 40094ba..413b8f2 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -55,6 +55,7 @@ check_PROGRAMS = \ ges/project\ ges/track\ ges/tempochange \ + ges/negative\ nle/simple \ nle/complex \ nle/nleoperation \ diff --git a/tests/check/ges/negative.c b/tests/check/ges/negative.c new file mode 100644 index 0000000..92f21ff --- /dev/null +++ b/tests/check/ges/negative.c @@ -0,0 +1,73 @@ +/* GStreamer Editing Services + * Copyright (C) 2019 Seungha Yang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +static void +sigabrt_handler (int signum) +{ + /* expected abort */ + exit (0); +} + +static gpointer +deinit_thread_func (gpointer user_data) +{ + signal (SIGABRT, sigabrt_handler); + ges_deinit (); + + /* shouldn't be reached */ + exit (1); + + return NULL; +} + +GST_START_TEST (test_inconsistent_init_deinit_thread) +{ + GThread *thread; + + fail_unless (ges_init ()); + + /* test assertion, when trying to call ges_deinit() in a thread different + * from that of ges_init() called. + */ + thread = g_thread_new ("test-ges-deinit-thread", + (GThreadFunc) deinit_thread_func, NULL); + + g_thread_join (thread); +} + +GST_END_TEST; + +static Suite * +ges_suite (void) +{ + Suite *s = suite_create ("ges-negative"); + TCase *tc_chain = tcase_create ("negative"); + + suite_add_tcase (s, tc_chain); + + tcase_add_test (tc_chain, test_inconsistent_init_deinit_thread); + + return s; +} + +GST_CHECK_MAIN (ges); diff --git a/tests/check/meson.build b/tests/check/meson.build index cd91d18..6147992 100644 --- a/tests/check/meson.build +++ b/tests/check/meson.build @@ -16,6 +16,7 @@ ges_tests = [ ['ges/project'], ['ges/track'], ['ges/tempochange'], + ['ges/negative'], ['nle/simple'], ['nle/complex'], ['nle/nleoperation'], -- 2.7.4