| 1 |
/* GStreamer Editing Services |
| 2 |
* Copyright (C) 2019 Seungha Yang <[email protected]> |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Library General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Library General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Library General Public |
| 15 |
* License along with this library; if not, write to the |
| 16 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 17 |
* Boston, MA 02110-1301, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <ges/ges.h> |
| 21 |
#include <gst/check/gstcheck.h> |
| 22 |
#include <signal.h> |
| 23 |
|
| 24 |
#ifdef HAVE_CONFIG_H |
| 25 |
# include "config.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
#ifdef HAVE_VALGRIND |
| 29 |
# include <valgrind/valgrind.h> |
| 30 |
#endif |
| 31 |
|
| 32 |
static void |
| 33 |
sigabrt_handler (int signum) |
| 34 |
{ |
| 35 |
/* expected abort */ |
| 36 |
exit (0); |
| 37 |
} |
| 38 |
|
| 39 |
static gpointer |
| 40 |
deinit_thread_func (gpointer user_data) |
| 41 |
{ |
| 42 |
signal (SIGABRT, sigabrt_handler); |
| 43 |
ges_deinit (); |
| 44 |
|
| 45 |
/* shouldn't be reached */ |
| 46 |
exit (1); |
| 47 |
|
| 48 |
return NULL; |
| 49 |
} |
| 50 |
|
| 51 |
GST_START_TEST (test_inconsistent_init_deinit_thread) |
| 52 |
{ |
| 53 |
GThread *thread; |
| 54 |
|
| 55 |
fail_unless (ges_init ()); |
| 56 |
|
| 57 |
/* test assertion, when trying to call ges_deinit() in a thread different |
| 58 |
* from that of ges_init() called. |
| 59 |
*/ |
| 60 |
thread = g_thread_new ("test-ges-deinit-thread", |
| 61 |
(GThreadFunc) deinit_thread_func, NULL); |
| 62 |
|
| 63 |
g_thread_join (thread); |
| 64 |
} |
| 65 |
|
| 66 |
GST_END_TEST; |
| 67 |
|
| 68 |
static Suite * |
| 69 |
ges_suite (void) |
| 70 |
{ |
| 71 |
Suite *s = suite_create ("ges-negative"); |
| 72 |
TCase *tc_chain = tcase_create ("negative"); |
| 73 |
|
| 74 |
suite_add_tcase (s, tc_chain); |
| 75 |
|
| 76 |
#ifdef HAVE_VALGRIND |
| 77 |
if (RUNNING_ON_VALGRIND) { |
| 78 |
} else |
| 79 |
#endif |
| 80 |
{ |
| 81 |
tcase_add_test (tc_chain, test_inconsistent_init_deinit_thread); |
| 82 |
} |
| 83 |
|
| 84 |
return s; |
| 85 |
} |
| 86 |
|
| 87 |
GST_CHECK_MAIN (ges); |