tests: port from g_test_trap_subprocess() to g_test_trap_fork()

https://bugzilla.gnome.org/show_bug.cgi?id=679683
This commit is contained in:
Dan Winship
2012-11-24 15:58:36 -05:00
parent 467f9ea1bc
commit e3d1869ee3
20 changed files with 1243 additions and 893 deletions

View File

@@ -260,6 +260,20 @@ test_find_program (void)
g_assert (res == NULL);
}
static void
test_debug_help (void)
{
GDebugKey keys[] = {
{ "key1", 1 },
{ "key2", 2 },
{ "key3", 4 },
};
guint res;
res = g_parse_debug_string ("help", keys, G_N_ELEMENTS (keys));
g_assert_cmpint (res, ==, 0);
}
static void
test_debug (void)
{
@@ -294,12 +308,7 @@ test_debug (void)
res = g_parse_debug_string ("all", keys, G_N_ELEMENTS (keys));
g_assert_cmpint (res, ==, 7);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
res = g_parse_debug_string ("help", keys, G_N_ELEMENTS (keys));
g_assert_cmpint (res, ==, 0);
exit (0);
}
g_test_trap_subprocess ("/utils/debug/subprocess/help", 0, 0);
g_test_trap_assert_passed ();
g_test_trap_assert_stderr ("*Supported debug values: key1 key2 key3 all help*");
}
@@ -535,6 +544,7 @@ main (int argc,
g_test_add_func ("/utils/swap", test_swap);
g_test_add_func ("/utils/find-program", test_find_program);
g_test_add_func ("/utils/debug", test_debug);
g_test_add_func ("/utils/debug/subprocess/help", test_debug_help);
g_test_add_func ("/utils/codeset", test_codeset);
g_test_add_func ("/utils/basename", test_basename);
g_test_add_func ("/utils/gettext", test_gettext);