Simplify subprocesses in tests

Use the new way of running tests in a subprocess without
registering extra 'subprocess' test cases where appropriate.
This commit is contained in:
Matthias Clasen 2013-12-15 11:20:19 -05:00
parent cd2204bb65
commit c34cc2348c
9 changed files with 179 additions and 222 deletions

View File

@ -99,7 +99,12 @@ test_basic (void)
* that is not in the schema * that is not in the schema
*/ */
static void static void
test_unknown_key_subprocess (void) test_unknown_key (void)
{
if (!g_test_undefined ())
return;
if (g_test_subprocess ())
{ {
GSettings *settings; GSettings *settings;
GVariant *value; GVariant *value;
@ -110,15 +115,9 @@ test_unknown_key_subprocess (void)
g_assert (value == NULL); g_assert (value == NULL);
g_object_unref (settings); g_object_unref (settings);
}
static void
test_unknown_key (void)
{
if (!g_test_undefined ())
return; return;
}
g_test_trap_subprocess ("/gsettings/unknown-key/subprocess", 0, 0); g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*does not contain*"); g_test_trap_assert_stderr ("*does not contain*");
} }
@ -129,11 +128,6 @@ test_unknown_key (void)
static void static void
test_no_schema_subprocess (void) test_no_schema_subprocess (void)
{ {
GSettings *settings;
settings = g_settings_new ("no.such.schema");
g_assert (settings == NULL);
} }
static void static void
@ -142,7 +136,16 @@ test_no_schema (void)
if (!g_test_undefined ()) if (!g_test_undefined ())
return; return;
g_test_trap_subprocess ("/gsettings/no-schema/subprocess", 0, 0); if (g_test_subprocess ())
{
GSettings *settings;
settings = g_settings_new ("no.such.schema");
g_assert (settings == NULL);
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*Settings schema 'no.such.schema' is not installed*"); g_test_trap_assert_stderr ("*Settings schema 'no.such.schema' is not installed*");
} }
@ -179,31 +182,22 @@ test_wrong_type (void)
} }
/* Check errors with explicit paths */ /* Check errors with explicit paths */
static void
test_wrong_path_subprocess (void)
{
GSettings *settings G_GNUC_UNUSED;
settings = g_settings_new_with_path ("org.gtk.test", "/wrong-path/");
}
static void static void
test_wrong_path (void) test_wrong_path (void)
{ {
if (!g_test_undefined ()) if (!g_test_undefined ())
return; return;
g_test_trap_subprocess ("/gsettings/wrong-path/subprocess", 0, 0); if (g_test_subprocess ())
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*but path * specified by schema*");
}
static void
test_no_path_subprocess (void)
{ {
GSettings *settings G_GNUC_UNUSED; GSettings *settings G_GNUC_UNUSED;
settings = g_settings_new ("org.gtk.test.no-path"); settings = g_settings_new_with_path ("org.gtk.test", "/wrong-path/");
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*but path * specified by schema*");
} }
static void static void
@ -212,7 +206,14 @@ test_no_path (void)
if (!g_test_undefined ()) if (!g_test_undefined ())
return; return;
g_test_trap_subprocess ("/gsettings/no-path/subprocess", 0, 0); if (g_test_subprocess ())
{
GSettings *settings G_GNUC_UNUSED;
settings = g_settings_new ("org.gtk.test.no-path");
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*attempting to create schema * without a path**"); g_test_trap_assert_stderr ("*attempting to create schema * without a path**");
} }
@ -1348,10 +1349,14 @@ test_directional_binding (void)
g_object_unref (settings); g_object_unref (settings);
} }
/* Test that type mismatch is caught when creating a binding /* Test that type mismatch is caught when creating a binding */
*/
static void static void
test_typesafe_binding_subprocess (void) test_typesafe_binding (void)
{
if (!g_test_undefined ())
return;
if (g_test_subprocess ())
{ {
TestObject *obj; TestObject *obj;
GSettings *settings; GSettings *settings;
@ -1363,15 +1368,9 @@ test_typesafe_binding_subprocess (void)
g_object_unref (obj); g_object_unref (obj);
g_object_unref (settings); g_object_unref (settings);
}
static void
test_typesafe_binding (void)
{
if (!g_test_undefined ())
return; return;
}
g_test_trap_subprocess ("/gsettings/typesafe-binding/subprocess", 0, 0); g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*not compatible*"); g_test_trap_assert_stderr ("*not compatible*");
} }
@ -2500,14 +2499,10 @@ main (int argc, char *argv[])
if (!backend_set) if (!backend_set)
{ {
g_test_add_func ("/gsettings/no-schema", test_no_schema); g_test_add_func ("/gsettings/no-schema", test_no_schema);
g_test_add_func ("/gsettings/no-schema/subprocess", test_no_schema_subprocess);
g_test_add_func ("/gsettings/unknown-key", test_unknown_key); g_test_add_func ("/gsettings/unknown-key", test_unknown_key);
g_test_add_func ("/gsettings/unknown-key/subprocess", test_unknown_key_subprocess);
g_test_add_func ("/gsettings/wrong-type", test_wrong_type); g_test_add_func ("/gsettings/wrong-type", test_wrong_type);
g_test_add_func ("/gsettings/wrong-path", test_wrong_path); g_test_add_func ("/gsettings/wrong-path", test_wrong_path);
g_test_add_func ("/gsettings/wrong-path/subprocess", test_wrong_path_subprocess);
g_test_add_func ("/gsettings/no-path", test_no_path); g_test_add_func ("/gsettings/no-path", test_no_path);
g_test_add_func ("/gsettings/no-path/subprocess", test_no_path_subprocess);
} }
g_test_add_func ("/gsettings/basic-types", test_basic_types); g_test_add_func ("/gsettings/basic-types", test_basic_types);

View File

@ -216,7 +216,11 @@ static GMemVTable array_large_size_mem_vtable = {
}; };
static void static void
array_large_size_subprocess (void) array_large_size (void)
{
g_test_bug ("568760");
if (g_test_subprocess ())
{ {
GArray *array; GArray *array;
@ -225,15 +229,10 @@ array_large_size_subprocess (void)
g_mem_set_vtable (&array_large_size_mem_vtable); g_mem_set_vtable (&array_large_size_mem_vtable);
g_array_set_size (array, 1073750016); g_array_set_size (array, 1073750016);
g_assert_not_reached (); g_assert_not_reached ();
return;
} }
static void g_test_trap_subprocess (NULL, 5000000, 0);
array_large_size (void)
{
g_test_bug ("568760");
g_test_trap_subprocess ("/array/large-size/subprocess",
5 /* s */ * 1000 /* ms */ * 1000 /* µs */, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
} }
@ -875,7 +874,6 @@ main (int argc, char *argv[])
g_test_add_func ("/array/remove-range", array_remove_range); g_test_add_func ("/array/remove-range", array_remove_range);
g_test_add_func ("/array/ref-count", array_ref_count); g_test_add_func ("/array/ref-count", array_ref_count);
g_test_add_func ("/array/large-size", array_large_size); g_test_add_func ("/array/large-size", array_large_size);
g_test_add_func ("/array/large-size/subprocess", array_large_size_subprocess);
g_test_add_func ("/array/sort", array_sort); g_test_add_func ("/array/sort", array_sort);
g_test_add_func ("/array/sort-with-data", array_sort_with_data); g_test_add_func ("/array/sort-with-data", array_sort_with_data);
g_test_add_func ("/array/clear-func", array_clear_func); g_test_add_func ("/array/clear-func", array_clear_func);

View File

@ -183,20 +183,20 @@ free_one (gpointer data)
} }
static void static void
test_datalist_clear_subprocess (void) test_datalist_clear (void)
{
/* Need to use a subprocess because it will deadlock if it fails */
if (g_test_subprocess ())
{ {
g_datalist_init (&list); g_datalist_init (&list);
g_datalist_set_data_full (&list, "one", GINT_TO_POINTER (1), free_one); g_datalist_set_data_full (&list, "one", GINT_TO_POINTER (1), free_one);
g_datalist_set_data_full (&list, "two", GINT_TO_POINTER (2), NULL); g_datalist_set_data_full (&list, "two", GINT_TO_POINTER (2), NULL);
g_datalist_clear (&list); g_datalist_clear (&list);
g_assert (list == NULL); g_assert (list == NULL);
return;
} }
static void g_test_trap_subprocess (NULL, 500000, 0);
test_datalist_clear (void)
{
/* Need to use a subprocess because it will deadlock if it fails */
g_test_trap_subprocess ("/datalist/recursive-clear/subprocess", 500000, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
} }
@ -213,7 +213,6 @@ main (int argc, char *argv[])
g_test_add_func ("/dataset/foreach", test_dataset_foreach); g_test_add_func ("/dataset/foreach", test_dataset_foreach);
g_test_add_func ("/dataset/destroy", test_dataset_destroy); g_test_add_func ("/dataset/destroy", test_dataset_destroy);
g_test_add_func ("/datalist/recursive-clear", test_datalist_clear); g_test_add_func ("/datalist/recursive-clear", test_datalist_clear);
g_test_add_func ("/datalist/recursive-clear/subprocess", test_datalist_clear_subprocess);
return g_test_run (); return g_test_run ();
} }

View File

@ -59,8 +59,10 @@ test_scanner_warn (ScannerFixture *fix,
} }
static void static void
test_scanner_error_subprocess (ScannerFixture *fix, test_scanner_error (ScannerFixture *fix,
gconstpointer test_data) gconstpointer test_data)
{
if (g_test_subprocess ())
{ {
int pe = fix->scanner->parse_errors; int pe = fix->scanner->parse_errors;
g_scanner_error (fix->scanner, "scanner-error-message-test"); g_scanner_error (fix->scanner, "scanner-error-message-test");
@ -68,11 +70,7 @@ test_scanner_error_subprocess (ScannerFixture *fix,
exit (0); exit (0);
} }
static void g_test_trap_subprocess (NULL, 0, 0);
test_scanner_error (ScannerFixture *fix,
gconstpointer test_data)
{
g_test_trap_subprocess ("/scanner/error/subprocess", 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
g_test_trap_assert_stderr ("*scanner-error-message-test*"); g_test_trap_assert_stderr ("*scanner-error-message-test*");
} }
@ -139,7 +137,6 @@ main (int argc,
g_test_add ("/scanner/warn", ScannerFixture, 0, scanner_fixture_setup, test_scanner_warn, scanner_fixture_teardown); g_test_add ("/scanner/warn", ScannerFixture, 0, scanner_fixture_setup, test_scanner_warn, scanner_fixture_teardown);
g_test_add ("/scanner/error", ScannerFixture, 0, scanner_fixture_setup, test_scanner_error, scanner_fixture_teardown); g_test_add ("/scanner/error", ScannerFixture, 0, scanner_fixture_setup, test_scanner_error, scanner_fixture_teardown);
g_test_add ("/scanner/error/subprocess", ScannerFixture, 0, scanner_fixture_setup, test_scanner_error_subprocess, scanner_fixture_teardown);
g_test_add ("/scanner/symbols", ScannerFixture, 0, scanner_fixture_setup, test_scanner_symbols, scanner_fixture_teardown); g_test_add ("/scanner/symbols", ScannerFixture, 0, scanner_fixture_setup, test_scanner_symbols, scanner_fixture_teardown);
g_test_add ("/scanner/tokens", ScannerFixture, 0, scanner_fixture_setup, test_scanner_tokens, scanner_fixture_teardown); g_test_add ("/scanner/tokens", ScannerFixture, 0, scanner_fixture_setup, test_scanner_tokens, scanner_fixture_teardown);

View File

@ -3,16 +3,15 @@
/* We test deprecated functionality here */ /* We test deprecated functionality here */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
test_slice_config_subprocess (void)
{
g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
}
static void static void
test_slice_config (void) test_slice_config (void)
{ {
g_test_trap_subprocess ("/slice/config/subprocess", 1000000, 0); if (g_test_subprocess ())
{
g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
return;
}
g_test_trap_subprocess (NULL, 1000000, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
} }
@ -30,7 +29,6 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_func ("/slice/config", test_slice_config); g_test_add_func ("/slice/config", test_slice_config);
g_test_add_func ("/slice/config/subprocess", test_slice_config_subprocess);
return g_test_run (); return g_test_run ();
} }

View File

@ -610,7 +610,9 @@ test_positional_params (void)
} }
static void static void
test_positional_params2_subprocess (void) test_positional_params2 (void)
{
if (g_test_subprocess ())
{ {
gint res; gint res;
@ -622,12 +624,9 @@ test_positional_params2_subprocess (void)
res = g_printf ("%1$s%1$s\n", "abc"); res = g_printf ("%1$s%1$s\n", "abc");
g_assert_cmpint (res, ==, 7); g_assert_cmpint (res, ==, 7);
return;
} }
g_test_trap_subprocess (NULL, 0, 0);
static void
test_positional_params2 (void)
{
g_test_trap_subprocess ("/printf/test-positional-params/subprocess", 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
g_test_trap_assert_stdout ("a b\n ab\nabcabc\n"); g_test_trap_assert_stdout ("a b\n ab\nabcabc\n");
} }
@ -652,18 +651,17 @@ test_positional_params3 (void)
} }
static void static void
test_percent2_subprocess (void) test_percent2 (void)
{
if (g_test_subprocess ())
{ {
gint res; gint res;
res = g_printf ("%%"); res = g_printf ("%%");
g_assert_cmpint (res, ==, 1); g_assert_cmpint (res, ==, 1);
return;
} }
g_test_trap_subprocess (NULL, 0, 0);
static void
test_percent2 (void)
{
g_test_trap_subprocess ("/printf/test-percent/subprocess", 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
g_test_trap_assert_stdout ("*%*"); g_test_trap_assert_stdout ("*%*");
} }
@ -907,9 +905,7 @@ main (int argc,
g_test_add_func ("/snprintf/test-64bit", test_64bit); g_test_add_func ("/snprintf/test-64bit", test_64bit);
g_test_add_func ("/printf/test-percent", test_percent2); g_test_add_func ("/printf/test-percent", test_percent2);
g_test_add_func ("/printf/test-percent/subprocess", test_percent2_subprocess);
g_test_add_func ("/printf/test-positional-params", test_positional_params2); g_test_add_func ("/printf/test-positional-params", test_positional_params2);
g_test_add_func ("/printf/test-positional-params/subprocess", test_positional_params2_subprocess);
g_test_add_func ("/printf/test-64bit", test_64bit2); g_test_add_func ("/printf/test-64bit", test_64bit2);
g_test_add_func ("/printf/test-64bit/subprocess/base", test_64bit2_base); g_test_add_func ("/printf/test-64bit/subprocess/base", test_64bit2_base);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32

View File

@ -133,66 +133,62 @@ test_fork_timeout (void)
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
#endif /* G_OS_UNIX */ #endif /* G_OS_UNIX */
static void
test_subprocess_fail_child (void)
{
g_assert_not_reached ();
}
static void static void
test_subprocess_fail (void) test_subprocess_fail (void)
{ {
g_test_trap_subprocess ("/trap_subprocess/fail/subprocess", 0, 0); if (g_test_subprocess ())
g_test_trap_assert_failed (); {
g_test_trap_assert_stderr ("*ERROR*test_subprocess_fail_child*should not be reached*"); g_assert_not_reached ();
return;
} }
static void g_test_trap_subprocess (NULL, 0, 0);
test_subprocess_no_such_test_child (void) g_test_trap_assert_failed ();
{ g_test_trap_assert_stderr ("*ERROR*test_subprocess_fail*should not be reached*");
g_test_trap_subprocess ("/trap_subprocess/this-test-does-not-exist", 0, 0);
g_assert_not_reached ();
} }
static void static void
test_subprocess_no_such_test (void) test_subprocess_no_such_test (void)
{ {
g_test_trap_subprocess ("/trap_subprocess/no-such-test/subprocess", 0, 0); if (g_test_subprocess ())
{
g_test_trap_subprocess ("/trap_subprocess/this-test-does-not-exist", 0, 0);
g_assert_not_reached ();
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*test does not exist*"); g_test_trap_assert_stderr ("*test does not exist*");
g_test_trap_assert_stderr_unmatched ("*should not be reached*"); g_test_trap_assert_stderr_unmatched ("*should not be reached*");
} }
static void static void
test_subprocess_patterns_child (void) test_subprocess_patterns (void)
{
if (g_test_subprocess ())
{ {
g_print ("some stdout text: somagic17\n"); g_print ("some stdout text: somagic17\n");
g_printerr ("some stderr text: semagic43\n"); g_printerr ("some stderr text: semagic43\n");
exit (0); exit (0);
} }
g_test_trap_subprocess (NULL, 0, 0);
static void
test_subprocess_patterns (void)
{
g_test_trap_subprocess ("/trap_subprocess/patterns/subprocess", 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
g_test_trap_assert_stdout ("*somagic17*"); g_test_trap_assert_stdout ("*somagic17*");
g_test_trap_assert_stderr ("*semagic43*"); g_test_trap_assert_stderr ("*semagic43*");
} }
static void static void
test_subprocess_timeout_child (void) test_subprocess_timeout (void)
{
if (g_test_subprocess ())
{ {
/* loop and sleep forever */ /* loop and sleep forever */
while (TRUE) while (TRUE)
g_usleep (1000 * 1000); g_usleep (1000 * 1000);
return;
} }
static void
test_subprocess_timeout (void)
{
/* allow child to run for only a fraction of a second */ /* allow child to run for only a fraction of a second */
g_test_trap_subprocess ("/trap_subprocess/timeout/subprocess", 0.11 * 1000000, 0); g_test_trap_subprocess (NULL, 0.11 * 1000000, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_assert (g_test_trap_reached_timeout ()); g_assert (g_test_trap_reached_timeout ());
} }
@ -563,20 +559,17 @@ test_dash_p (void)
g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden*"); g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/subprocess/hidden*");
} }
static void
test_nonfatal_subprocess (void)
{
g_test_set_nonfatal_assertions ();
g_assert_cmpint (4, ==, 5);
g_print ("The End\n");
}
static void static void
test_nonfatal (void) test_nonfatal (void)
{ {
g_test_trap_subprocess ("/misc/nonfatal/subprocess", 0, 0); if (g_test_subprocess ())
{
g_test_set_nonfatal_assertions ();
g_assert_cmpint (4, ==, 5);
g_print ("The End\n");
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*assertion failed*4 == 5*"); g_test_trap_assert_stderr ("*assertion failed*4 == 5*");
g_test_trap_assert_stdout ("*The End*"); g_test_trap_assert_stdout ("*The End*");
@ -607,16 +600,11 @@ main (int argc,
#endif #endif
g_test_add_func ("/trap_subprocess/fail", test_subprocess_fail); g_test_add_func ("/trap_subprocess/fail", test_subprocess_fail);
g_test_add_func ("/trap_subprocess/fail/subprocess", test_subprocess_fail_child);
g_test_add_func ("/trap_subprocess/no-such-test", test_subprocess_no_such_test); g_test_add_func ("/trap_subprocess/no-such-test", test_subprocess_no_such_test);
g_test_add_func ("/trap_subprocess/no-such-test/subprocess", test_subprocess_no_such_test_child);
if (g_test_slow ()) if (g_test_slow ())
{
g_test_add_func ("/trap_subprocess/timeout", test_subprocess_timeout); g_test_add_func ("/trap_subprocess/timeout", test_subprocess_timeout);
g_test_add_func ("/trap_subprocess/timeout/subprocess", test_subprocess_timeout_child);
}
g_test_add_func ("/trap_subprocess/patterns", test_subprocess_patterns); g_test_add_func ("/trap_subprocess/patterns", test_subprocess_patterns);
g_test_add_func ("/trap_subprocess/patterns/subprocess", test_subprocess_patterns_child);
g_test_add_func ("/misc/fatal-log-handler", test_fatal_log_handler); g_test_add_func ("/misc/fatal-log-handler", test_fatal_log_handler);
g_test_add_func ("/misc/fatal-log-handler/subprocess/critical-pass", test_fatal_log_handler_critical_pass); g_test_add_func ("/misc/fatal-log-handler/subprocess/critical-pass", test_fatal_log_handler_critical_pass);
@ -644,7 +632,6 @@ main (int argc,
g_test_add_func ("/misc/dash-p/subprocess/hidden/sub", test_dash_p_hidden_sub); g_test_add_func ("/misc/dash-p/subprocess/hidden/sub", test_dash_p_hidden_sub);
g_test_add_func ("/misc/nonfatal", test_nonfatal); g_test_add_func ("/misc/nonfatal", test_nonfatal);
g_test_add_func ("/misc/nonfatal/subprocess", test_nonfatal_subprocess);
return g_test_run(); return g_test_run();
} }

View File

@ -260,20 +260,6 @@ test_find_program (void)
g_assert (res == NULL); 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 static void
test_debug (void) test_debug (void)
{ {
@ -308,7 +294,13 @@ test_debug (void)
res = g_parse_debug_string ("all", keys, G_N_ELEMENTS (keys)); res = g_parse_debug_string ("all", keys, G_N_ELEMENTS (keys));
g_assert_cmpint (res, ==, 7); g_assert_cmpint (res, ==, 7);
g_test_trap_subprocess ("/utils/debug/subprocess/help", 0, 0); if (g_test_subprocess ())
{
res = g_parse_debug_string ("help", keys, G_N_ELEMENTS (keys));
g_assert_cmpint (res, ==, 0);
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
g_test_trap_assert_stderr ("*Supported debug values: key1 key2 key3 all help*"); g_test_trap_assert_stderr ("*Supported debug values: key1 key2 key3 all help*");
} }
@ -519,16 +511,15 @@ atexit_func (void)
g_print ("atexit called"); g_print ("atexit called");
} }
static void
test_atexit_subprocess (void)
{
g_atexit (atexit_func);
}
static void static void
test_atexit (void) test_atexit (void)
{ {
g_test_trap_subprocess ("/utils/atexit/subprocess", 0, 0); if (g_test_subprocess ())
{
g_atexit (atexit_func);
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
g_test_trap_assert_stdout ("*atexit called*"); g_test_trap_assert_stdout ("*atexit called*");
} }
@ -563,7 +554,6 @@ main (int argc,
g_test_add_func ("/utils/swap", test_swap); g_test_add_func ("/utils/swap", test_swap);
g_test_add_func ("/utils/find-program", test_find_program); g_test_add_func ("/utils/find-program", test_find_program);
g_test_add_func ("/utils/debug", test_debug); 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/codeset", test_codeset);
g_test_add_func ("/utils/basename", test_basename); g_test_add_func ("/utils/basename", test_basename);
g_test_add_func ("/utils/gettext", test_gettext); g_test_add_func ("/utils/gettext", test_gettext);
@ -579,7 +569,6 @@ main (int argc,
g_test_add_func ("/utils/misc-mem", test_misc_mem); g_test_add_func ("/utils/misc-mem", test_misc_mem);
g_test_add_func ("/utils/nullify", test_nullify); g_test_add_func ("/utils/nullify", test_nullify);
g_test_add_func ("/utils/atexit", test_atexit); g_test_add_func ("/utils/atexit", test_atexit);
g_test_add_func ("/utils/atexit/subprocess", test_atexit_subprocess);
return g_test_run (); return g_test_run ();
} }

View File

@ -117,19 +117,18 @@ my_infanticide_object_class_init (MyInfanticideObjectClass *klass)
object_class->constructor = my_infanticide_object_constructor; object_class->constructor = my_infanticide_object_constructor;
} }
static void
test_object_constructor_infanticide_subprocess (void)
{
g_object_new (my_infanticide_object_get_type (), NULL);
g_assert_not_reached ();
}
static void static void
test_object_constructor_infanticide (void) test_object_constructor_infanticide (void)
{ {
g_test_bug ("661576"); g_test_bug ("661576");
g_test_trap_subprocess ("/object/constructor/infanticide/subprocess", 0, 0); if (g_test_subprocess ())
{
g_object_new (my_infanticide_object_get_type (), NULL);
g_assert_not_reached ();
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*finalized while still in-construction*"); g_test_trap_assert_stderr ("*finalized while still in-construction*");
g_test_trap_assert_stderr_unmatched ("*reached*"); g_test_trap_assert_stderr_unmatched ("*reached*");
@ -145,7 +144,6 @@ main (int argc, char *argv[])
g_test_add_func ("/object/constructor/singleton", test_object_constructor_singleton); g_test_add_func ("/object/constructor/singleton", test_object_constructor_singleton);
g_test_add_func ("/object/constructor/infanticide", test_object_constructor_infanticide); g_test_add_func ("/object/constructor/infanticide", test_object_constructor_infanticide);
g_test_add_func ("/object/constructor/infanticide/subprocess", test_object_constructor_infanticide_subprocess);
return g_test_run (); return g_test_run ();
} }