doc: updated italian translations
[adg.git] / src / cpml / tests / test-internal.c
blob5fb174edc7ae225dd057a70d50ebc9e12f69516e
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2011,2012 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser 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.
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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include <config.h>
22 #include "test-internal.h"
25 typedef void (*CpmlCallback) (void);
28 void
29 cpml_test_init(int *p_argc, char **p_argv[])
31 g_test_init(p_argc, p_argv, NULL);
32 g_log_set_always_fatal(0);
33 g_test_bug_base("http://dev.entidi.com/p/adg/issues/%s/");
36 static void
37 _cpml_log_handler(const gchar *log_domain, GLogLevelFlags log_level,
38 const gchar *message, gpointer user_data)
42 static void
43 _cpml_test_func(gconstpointer user_data)
45 CpmlCallback test_func;
46 GLogFunc previous_handler;
48 test_func = (CpmlCallback) user_data;
50 /* Run a test in a forked environment, without showing log messages */
51 previous_handler = g_log_set_default_handler(_cpml_log_handler, NULL);
52 if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR)) {
53 test_func();
54 exit(0);
56 g_log_set_default_handler(previous_handler, NULL);
58 /* On failed test, rerun it without hiding the log messages */
59 if (!g_test_trap_has_passed())
60 test_func();
63 void
64 cpml_test_add_func(const char *testpath, void (*test_func)(void))
66 g_test_add_data_func(testpath, (gconstpointer) test_func, _cpml_test_func);