test-attributes: Remove deprecated use of g_test_trap_fork()

This commit is contained in:
Stef Walter 2013-12-11 09:42:01 +01:00
parent 8d297361de
commit 7b7e886288

View File

@ -59,15 +59,17 @@ test_build_unknown (void)
{ {
GHashTable *attributes; GHashTable *attributes;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { if (g_test_subprocess ()) {
attributes = secret_attributes_build (&MOCK_SCHEMA, attributes = secret_attributes_build (&MOCK_SCHEMA,
"invalid", "whee", "invalid", "whee",
"string", "four", "string", "four",
"even", TRUE, "even", TRUE,
NULL); NULL);
g_assert (attributes == NULL); g_assert (attributes == NULL);
return;
} }
g_test_trap_subprocess ("/attributes/build-unknown", 0, G_TEST_SUBPROCESS_INHERIT_STDOUT);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*was not found in*"); g_test_trap_assert_stderr ("*was not found in*");
} }
@ -77,15 +79,17 @@ test_build_null_string (void)
{ {
GHashTable *attributes; GHashTable *attributes;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { if (g_test_subprocess ()) {
attributes = secret_attributes_build (&MOCK_SCHEMA, attributes = secret_attributes_build (&MOCK_SCHEMA,
"number", 4, "number", 4,
"string", NULL, "string", NULL,
"even", TRUE, "even", TRUE,
NULL); NULL);
g_assert (attributes == NULL); g_assert (attributes == NULL);
return;
} }
g_test_trap_subprocess ("/attributes/build-null-string", 0, G_TEST_SUBPROCESS_INHERIT_STDOUT);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*attribute*NULL*"); g_test_trap_assert_stderr ("*attribute*NULL*");
} }
@ -95,15 +99,17 @@ test_build_non_utf8_string (void)
{ {
GHashTable *attributes; GHashTable *attributes;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { if (g_test_subprocess ()) {
attributes = secret_attributes_build (&MOCK_SCHEMA, attributes = secret_attributes_build (&MOCK_SCHEMA,
"number", 4, "number", 4,
"string", "\xfftest", "string", "\xfftest",
"even", TRUE, "even", TRUE,
NULL); NULL);
g_assert (attributes == NULL); g_assert (attributes == NULL);
return;
} }
g_test_trap_subprocess ("/attributes/build-non-utf8-string", 0, G_TEST_SUBPROCESS_INHERIT_STDOUT);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*attribute*UTF-8*"); g_test_trap_assert_stderr ("*attribute*UTF-8*");
} }
@ -113,13 +119,15 @@ test_build_bad_type (void)
{ {
GHashTable *attributes; GHashTable *attributes;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { if (g_test_subprocess ()) {
attributes = secret_attributes_build (&MOCK_SCHEMA, attributes = secret_attributes_build (&MOCK_SCHEMA,
"bad-type", "test", "bad-type", "test",
NULL); NULL);
g_assert (attributes == NULL); g_assert (attributes == NULL);
return;
} }
g_test_trap_subprocess ("/attributes/build-bad-type", 0, G_TEST_SUBPROCESS_INHERIT_STDOUT);
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*invalid type*"); g_test_trap_assert_stderr ("*invalid type*");
} }
@ -147,17 +155,20 @@ test_validate_schema_bad (void)
GHashTable *attributes; GHashTable *attributes;
gboolean ret; gboolean ret;
if (g_test_subprocess ()) {
attributes = g_hash_table_new (g_str_hash, g_str_equal); attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_replace (attributes, "number", "1"); g_hash_table_replace (attributes, "number", "1");
g_hash_table_replace (attributes, "string", "test"); g_hash_table_replace (attributes, "string", "test");
g_hash_table_replace (attributes, "xdg:schema", "mismatched.Schema"); g_hash_table_replace (attributes, "xdg:schema", "mismatched.Schema");
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
ret = _secret_attributes_validate (&MOCK_SCHEMA, attributes, G_STRFUNC, TRUE); ret = _secret_attributes_validate (&MOCK_SCHEMA, attributes, G_STRFUNC, TRUE);
g_assert (ret == FALSE); g_assert (ret == FALSE);
}
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
return;
}
g_test_trap_subprocess ("/attributes/validate-schema-bad", 0, G_TEST_SUBPROCESS_INHERIT_STDOUT);
} }
static void static void