Simplify subprocesses in tests
[platform/upstream/glib.git] / glib / tests / slice.c
1 #include <glib.h>
2
3 /* We test deprecated functionality here */
4 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
5
6 static void
7 test_slice_config (void)
8 {
9   if (g_test_subprocess ())
10     {
11       g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
12       return;
13     }
14   g_test_trap_subprocess (NULL, 1000000, 0);
15   g_test_trap_assert_failed ();
16 }
17
18 int
19 main (int argc, char **argv)
20 {
21   /* have to do this before using gtester since it uses gslice */
22   gboolean was;
23
24   was = g_slice_get_config (G_SLICE_CONFIG_ALWAYS_MALLOC);
25   g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, !was);
26   g_assert_cmpint (g_slice_get_config (G_SLICE_CONFIG_ALWAYS_MALLOC), !=, was);
27   g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, was);
28
29   g_test_init (&argc, &argv, NULL);
30
31   g_test_add_func ("/slice/config", test_slice_config);
32
33   return g_test_run ();
34 }