mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
tests: port from g_test_trap_subprocess() to g_test_trap_fork()
(or, in a few cases, to g_test_expect_message()) https://bugzilla.gnome.org/show_bug.cgi?id=679683
This commit is contained in:
parent
e3a29184d5
commit
ea06ec8063
@ -109,25 +109,13 @@ close_async_cb (GObject *source G_GNUC_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_exit_on_close (gconstpointer test_data)
|
test_exit_on_close_child (gconstpointer test_data)
|
||||||
{
|
{
|
||||||
const TestData *td = test_data;
|
const TestData *td = test_data;
|
||||||
GTestTrapFlags silence;
|
|
||||||
|
|
||||||
/* all the tests rely on a shared main loop */
|
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
|
||||||
|
|
||||||
g_test_dbus_unset ();
|
|
||||||
|
|
||||||
if (g_test_verbose ())
|
|
||||||
silence = 0;
|
|
||||||
else
|
|
||||||
silence = G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, silence))
|
|
||||||
{
|
|
||||||
GDBusConnection *c;
|
GDBusConnection *c;
|
||||||
|
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
session_bus_up ();
|
session_bus_up ();
|
||||||
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
||||||
|
|
||||||
@ -182,6 +170,24 @@ test_exit_on_close (gconstpointer test_data)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_exit_on_close (gconstpointer test_data)
|
||||||
|
{
|
||||||
|
const TestData *td = test_data;
|
||||||
|
GTestTrapFlags silence;
|
||||||
|
char *child_name;
|
||||||
|
|
||||||
|
g_test_dbus_unset ();
|
||||||
|
|
||||||
|
if (g_test_verbose ())
|
||||||
|
silence = 0;
|
||||||
|
else
|
||||||
|
silence = G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR;
|
||||||
|
|
||||||
|
child_name = g_strdup_printf ("/gdbus/exit-on-close/%s:child", td->name);
|
||||||
|
g_test_trap_subprocess (child_name, 0, silence);
|
||||||
|
g_free (child_name);
|
||||||
|
|
||||||
if (td->exit_on_close == EXPLICITLY_FALSE ||
|
if (td->exit_on_close == EXPLICITLY_FALSE ||
|
||||||
td->who_closes == LOCAL)
|
td->who_closes == LOCAL)
|
||||||
{
|
{
|
||||||
@ -207,10 +213,15 @@ main (int argc,
|
|||||||
|
|
||||||
for (i = 0; cases[i].name != NULL; i++)
|
for (i = 0; cases[i].name != NULL; i++)
|
||||||
{
|
{
|
||||||
gchar *name = g_strdup_printf ("/gdbus/exit-on-close/%s", cases[i].name);
|
gchar *name;
|
||||||
|
|
||||||
|
name = g_strdup_printf ("/gdbus/exit-on-close/%s", cases[i].name);
|
||||||
g_test_add_data_func (name, &cases[i], test_exit_on_close);
|
g_test_add_data_func (name, &cases[i], test_exit_on_close);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
name = g_strdup_printf ("/gdbus/exit-on-close/%s:child", cases[i].name);
|
||||||
|
g_test_add_data_func (name, &cases[i], test_exit_on_close_child);
|
||||||
|
g_free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_test_run();
|
return g_test_run();
|
||||||
|
@ -137,7 +137,7 @@ test_non_socket (void)
|
|||||||
pid_t first_child;
|
pid_t first_child;
|
||||||
GVariant *ret;
|
GVariant *ret;
|
||||||
const gchar *str;
|
const gchar *str;
|
||||||
gboolean ok;
|
gboolean ok, in_child;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
|
||||||
@ -219,7 +219,12 @@ test_non_socket (void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_test_trap_fork (0, 0))
|
/* This is #ifdef G_OS_UNIX anyway, so just use g_test_trap_fork() */
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||||
|
in_child = g_test_trap_fork (0, 0);
|
||||||
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||||
|
|
||||||
|
if (!in_child)
|
||||||
{
|
{
|
||||||
/* parent */
|
/* parent */
|
||||||
g_object_unref (streams[0]);
|
g_object_unref (streams[0]);
|
||||||
|
@ -620,12 +620,10 @@ test_expected_interface (GDBusProxy *proxy)
|
|||||||
if (g_test_undefined ())
|
if (g_test_undefined ())
|
||||||
{
|
{
|
||||||
/* Also check that we complain if setting a cached property of the wrong type */
|
/* Also check that we complain if setting a cached property of the wrong type */
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
{
|
"*Trying to set property y of type s but according to the expected interface the type is y*");
|
||||||
g_dbus_proxy_set_cached_property (proxy, "y", g_variant_new_string ("error_me_out!"));
|
g_dbus_proxy_set_cached_property (proxy, "y", g_variant_new_string ("error_me_out!"));
|
||||||
}
|
g_test_assert_expected_messages ();
|
||||||
g_test_trap_assert_stderr ("*Trying to set property y of type s but according to the expected interface the type is y*");
|
|
||||||
g_test_trap_assert_failed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this should work, however (since the type is correct) */
|
/* this should work, however (since the type is correct) */
|
||||||
@ -636,12 +634,10 @@ test_expected_interface (GDBusProxy *proxy)
|
|||||||
/* Try to get the value of a property where the type we expect is different from
|
/* Try to get the value of a property where the type we expect is different from
|
||||||
* what we have in our cache (e.g. what the service returned)
|
* what we have in our cache (e.g. what the service returned)
|
||||||
*/
|
*/
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
{
|
"*Trying to get property i with type i but according to the expected interface the type is u*");
|
||||||
value = g_dbus_proxy_get_cached_property (proxy, "i");
|
value = g_dbus_proxy_get_cached_property (proxy, "i");
|
||||||
}
|
g_test_assert_expected_messages ();
|
||||||
g_test_trap_assert_stderr ("*Trying to get property i with type i but according to the expected interface the type is u*");
|
|
||||||
g_test_trap_assert_failed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Even if a property does not exist in expected_interface, looking it
|
/* Even if a property does not exist in expected_interface, looking it
|
||||||
|
@ -12,12 +12,9 @@ typedef struct {
|
|||||||
} SchemaTest;
|
} SchemaTest;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_schema (gpointer data)
|
test_schema_do_compile (gpointer data)
|
||||||
{
|
{
|
||||||
SchemaTest *test = (SchemaTest *) data;
|
SchemaTest *test = (SchemaTest *) data;
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
|
||||||
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
|
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
|
||||||
gchar *path = g_build_filename (SRCDIR, "schema-tests", filename, NULL);
|
gchar *path = g_build_filename (SRCDIR, "schema-tests", filename, NULL);
|
||||||
gchar *argv[] = {
|
gchar *argv[] = {
|
||||||
@ -29,10 +26,21 @@ test_schema (gpointer data)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
gchar *envp[] = { NULL };
|
gchar *envp[] = { NULL };
|
||||||
|
|
||||||
execve (argv[0], argv, envp);
|
execve (argv[0], argv, envp);
|
||||||
g_free (filename);
|
g_assert_not_reached ();
|
||||||
g_free (path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_schema (gpointer data)
|
||||||
|
{
|
||||||
|
SchemaTest *test = (SchemaTest *) data;
|
||||||
|
gchar *child_name;
|
||||||
|
|
||||||
|
child_name = g_strdup_printf ("/gschema/%s%s:do_compile", test->name, test->opt ? "/opt" : "");
|
||||||
|
g_test_trap_subprocess (child_name, 0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_free (child_name);
|
||||||
|
|
||||||
if (test->err)
|
if (test->err)
|
||||||
{
|
{
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
@ -135,9 +143,15 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (tests); ++i)
|
for (i = 0; i < G_N_ELEMENTS (tests); ++i)
|
||||||
{
|
{
|
||||||
gchar *name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
|
gchar *name;
|
||||||
|
|
||||||
|
name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
|
||||||
g_test_add_data_func (name, &tests[i], (gpointer) test_schema);
|
g_test_add_data_func (name, &tests[i], (gpointer) test_schema);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
name = g_strdup_printf ("/gschema/%s%s:do_compile", tests[i].name, tests[i].opt ? "/opt" : "");
|
||||||
|
g_test_add_data_func (name, &tests[i], (gpointer) test_schema_do_compile);
|
||||||
|
g_free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
|
@ -83,12 +83,7 @@ test_basic (void)
|
|||||||
* that is not in the schema
|
* that is not in the schema
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
test_unknown_key (void)
|
test_unknown_key_child (void)
|
||||||
{
|
|
||||||
if (!g_test_undefined ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
GVariant *value;
|
GVariant *value;
|
||||||
@ -100,6 +95,15 @@ test_unknown_key (void)
|
|||||||
|
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_unknown_key (void)
|
||||||
|
{
|
||||||
|
if (!g_test_undefined ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/gsettings/unknown-key:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
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*");
|
||||||
}
|
}
|
||||||
@ -108,12 +112,7 @@ test_unknown_key (void)
|
|||||||
* has not been installed
|
* has not been installed
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
test_no_schema (void)
|
test_no_schema_child (void)
|
||||||
{
|
|
||||||
if (!g_test_undefined ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
|
||||||
@ -122,6 +121,14 @@ test_no_schema (void)
|
|||||||
g_assert (settings == NULL);
|
g_assert (settings == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_no_schema (void)
|
||||||
|
{
|
||||||
|
if (!g_test_undefined ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/gsettings/no-schema:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
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*");
|
||||||
}
|
}
|
||||||
@ -159,35 +166,41 @@ test_wrong_type (void)
|
|||||||
|
|
||||||
/* Check errors with explicit paths */
|
/* Check errors with explicit paths */
|
||||||
static void
|
static void
|
||||||
test_wrong_path (void)
|
test_wrong_path_child (void)
|
||||||
{
|
|
||||||
if (!g_test_undefined ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
GSettings *settings G_GNUC_UNUSED;
|
GSettings *settings G_GNUC_UNUSED;
|
||||||
|
|
||||||
settings = g_settings_new_with_path ("org.gtk.test", "/wrong-path/");
|
settings = g_settings_new_with_path ("org.gtk.test", "/wrong-path/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_wrong_path (void)
|
||||||
|
{
|
||||||
|
if (!g_test_undefined ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/gsettings/wrong-path:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*but path * specified by schema*");
|
g_test_trap_assert_stderr ("*but path * specified by schema*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_no_path_child (void)
|
||||||
|
{
|
||||||
|
GSettings *settings G_GNUC_UNUSED;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.no-path");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_no_path (void)
|
test_no_path (void)
|
||||||
{
|
{
|
||||||
if (!g_test_undefined ())
|
if (!g_test_undefined ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/no-path:child",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
GSettings *settings G_GNUC_UNUSED;
|
|
||||||
|
|
||||||
settings = g_settings_new ("org.gtk.test.no-path");
|
|
||||||
}
|
|
||||||
|
|
||||||
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**");
|
||||||
}
|
}
|
||||||
@ -1299,12 +1312,7 @@ test_directional_binding (void)
|
|||||||
/* 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 (void)
|
test_typesafe_binding_child (void)
|
||||||
{
|
|
||||||
if (!g_test_undefined ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
TestObject *obj;
|
TestObject *obj;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
@ -1317,6 +1325,15 @@ test_typesafe_binding (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;
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/gsettings/typesafe-binding:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*not compatible*");
|
g_test_trap_assert_stderr ("*not compatible*");
|
||||||
}
|
}
|
||||||
@ -1425,11 +1442,7 @@ test_no_change_binding (void)
|
|||||||
* works in 'GET' mode.
|
* works in 'GET' mode.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
test_no_read_binding (void)
|
test_no_read_binding_fail (void)
|
||||||
{
|
|
||||||
if (g_test_undefined ())
|
|
||||||
{
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
TestObject *obj;
|
TestObject *obj;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
@ -1439,11 +1452,9 @@ test_no_read_binding (void)
|
|||||||
|
|
||||||
g_settings_bind (settings, "string", obj, "no-read", 0);
|
g_settings_bind (settings, "string", obj, "no-read", 0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*property*is not readable*");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, 0))
|
static void
|
||||||
|
test_no_read_binding_pass (void)
|
||||||
{
|
{
|
||||||
TestObject *obj;
|
TestObject *obj;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
@ -1455,6 +1466,19 @@ test_no_read_binding (void)
|
|||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_no_read_binding (void)
|
||||||
|
{
|
||||||
|
if (g_test_undefined ())
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/gsettings/no-read-binding:fail",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*property*is not readable*");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/gsettings/no-read-binding:pass", 0, 0);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1462,11 +1486,7 @@ test_no_read_binding (void)
|
|||||||
* works in 'SET' mode.
|
* works in 'SET' mode.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
test_no_write_binding (void)
|
test_no_write_binding_fail (void)
|
||||||
{
|
|
||||||
if (g_test_undefined ())
|
|
||||||
{
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
TestObject *obj;
|
TestObject *obj;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
@ -1476,11 +1496,9 @@ test_no_write_binding (void)
|
|||||||
|
|
||||||
g_settings_bind (settings, "string", obj, "no-write", 0);
|
g_settings_bind (settings, "string", obj, "no-write", 0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*property*is not writable*");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, 0))
|
static void
|
||||||
|
test_no_write_binding_pass (void)
|
||||||
{
|
{
|
||||||
TestObject *obj;
|
TestObject *obj;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
@ -1492,6 +1510,19 @@ test_no_write_binding (void)
|
|||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_no_write_binding (void)
|
||||||
|
{
|
||||||
|
if (g_test_undefined ())
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/gsettings/no-write-binding:fail",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*property*is not writable*");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/gsettings/no-write-binding:pass", 0, 0);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1630,6 +1661,46 @@ test_strinfo (void)
|
|||||||
g_assert (!strinfo_is_string_valid (strinfo, length, "quux"));
|
g_assert (!strinfo_is_string_valid (strinfo, length, "quux"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_enums_non_enum_key (void)
|
||||||
|
{
|
||||||
|
GSettings *direct;
|
||||||
|
|
||||||
|
direct = g_settings_new ("org.gtk.test.enums.direct");
|
||||||
|
g_settings_get_enum (direct, "test");
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_enums_non_enum_value (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.enums");
|
||||||
|
g_settings_set_enum (settings, "test", 42);
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_enums_range (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.enums");
|
||||||
|
g_settings_set_string (settings, "test", "qux");
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_enums_non_flags (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.enums");
|
||||||
|
g_settings_get_flags (settings, "test");
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_enums (void)
|
test_enums (void)
|
||||||
{
|
{
|
||||||
@ -1641,23 +1712,23 @@ test_enums (void)
|
|||||||
|
|
||||||
if (g_test_undefined () && !backend_set)
|
if (g_test_undefined () && !backend_set)
|
||||||
{
|
{
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/enums:non-enum-key",
|
||||||
g_settings_get_enum (direct, "test");
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*not associated with an enum*");
|
g_test_trap_assert_stderr ("*not associated with an enum*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/enums:non-enum-value",
|
||||||
g_settings_set_enum (settings, "test", 42);
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*invalid enum value 42*");
|
g_test_trap_assert_stderr ("*invalid enum value 42*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/enums:range",
|
||||||
g_settings_set_string (settings, "test", "qux");
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/enums:non-flags",
|
||||||
g_settings_get_flags (settings, "test");
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*not associated with a flags*");
|
g_test_trap_assert_stderr ("*not associated with a flags*");
|
||||||
}
|
}
|
||||||
@ -1687,6 +1758,47 @@ test_enums (void)
|
|||||||
g_assert_cmpint (g_settings_get_enum (settings, "test"), ==, TEST_ENUM_QUUX);
|
g_assert_cmpint (g_settings_get_enum (settings, "test"), ==, TEST_ENUM_QUUX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_flags_non_flags_key (void)
|
||||||
|
{
|
||||||
|
GSettings *direct;
|
||||||
|
|
||||||
|
direct = g_settings_new ("org.gtk.test.enums.direct");
|
||||||
|
g_settings_get_flags (direct, "test");
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_flags_non_flags_value (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.enums");
|
||||||
|
g_settings_set_flags (settings, "f-test", 0x42);
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_flags_range (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.enums");
|
||||||
|
g_settings_set_strv (settings, "f-test",
|
||||||
|
(const gchar **) g_strsplit ("rock", ",", 0));
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_flags_non_enum (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.enums");
|
||||||
|
g_settings_get_enum (settings, "f-test");
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_flags (void)
|
test_flags (void)
|
||||||
{
|
{
|
||||||
@ -1699,24 +1811,23 @@ test_flags (void)
|
|||||||
|
|
||||||
if (g_test_undefined () && !backend_set)
|
if (g_test_undefined () && !backend_set)
|
||||||
{
|
{
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/flags:non-flags-key",
|
||||||
g_settings_get_flags (direct, "test");
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*not associated with a flags*");
|
g_test_trap_assert_stderr ("*not associated with a flags*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/flags:non-flags-value",
|
||||||
g_settings_set_flags (settings, "f-test", 0x42);
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*invalid flags value 0x00000042*");
|
g_test_trap_assert_stderr ("*invalid flags value 0x00000042*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/flags:range",
|
||||||
g_settings_set_strv (settings, "f-test",
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
(const gchar **) g_strsplit ("rock", ",", 0));
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/flags:non-enum",
|
||||||
g_settings_get_enum (settings, "f-test");
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*not associated with an enum*");
|
g_test_trap_assert_stderr ("*not associated with an enum*");
|
||||||
}
|
}
|
||||||
@ -1759,6 +1870,26 @@ test_flags (void)
|
|||||||
TEST_FLAGS_TALKING | TEST_FLAGS_LAUGHING);
|
TEST_FLAGS_TALKING | TEST_FLAGS_LAUGHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_range_high (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.range");
|
||||||
|
g_settings_set_int (settings, "val", 45);
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_range_low (void)
|
||||||
|
{
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.gtk.test.range");
|
||||||
|
g_settings_set_int (settings, "val", 1);
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_range (void)
|
test_range (void)
|
||||||
{
|
{
|
||||||
@ -1770,13 +1901,13 @@ test_range (void)
|
|||||||
|
|
||||||
if (g_test_undefined () && !backend_set)
|
if (g_test_undefined () && !backend_set)
|
||||||
{
|
{
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/range:high",
|
||||||
g_settings_set_int (settings, "val", 45);
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/gsettings/range:low",
|
||||||
g_settings_set_int (settings, "val", 1);
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
|
||||||
}
|
}
|
||||||
@ -2133,6 +2264,10 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
|
if (!g_test_subprocess ())
|
||||||
|
{
|
||||||
backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL;
|
backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL;
|
||||||
|
|
||||||
g_setenv ("XDG_DATA_DIRS", ".", TRUE);
|
g_setenv ("XDG_DATA_DIRS", ".", TRUE);
|
||||||
@ -2141,8 +2276,6 @@ main (int argc, char *argv[])
|
|||||||
if (!backend_set)
|
if (!backend_set)
|
||||||
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
|
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
|
|
||||||
g_remove ("org.gtk.test.enums.xml");
|
g_remove ("org.gtk.test.enums.xml");
|
||||||
g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums "
|
g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums "
|
||||||
"--template " SRCDIR "/enums.xml.template "
|
"--template " SRCDIR "/enums.xml.template "
|
||||||
@ -2165,16 +2298,21 @@ main (int argc, char *argv[])
|
|||||||
"--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
|
"--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
|
||||||
NULL, NULL, &result, NULL));
|
NULL, NULL, &result, NULL));
|
||||||
g_assert (result == 0);
|
g_assert (result == 0);
|
||||||
|
}
|
||||||
|
|
||||||
g_test_add_func ("/gsettings/basic", test_basic);
|
g_test_add_func ("/gsettings/basic", test_basic);
|
||||||
|
|
||||||
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:child", test_no_schema_child);
|
||||||
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:child", test_unknown_key_child);
|
||||||
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:child", test_wrong_path_child);
|
||||||
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:child", test_no_path_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_test_add_func ("/gsettings/basic-types", test_basic_types);
|
g_test_add_func ("/gsettings/basic-types", test_basic_types);
|
||||||
@ -2201,16 +2339,31 @@ main (int argc, char *argv[])
|
|||||||
if (!backend_set)
|
if (!backend_set)
|
||||||
{
|
{
|
||||||
g_test_add_func ("/gsettings/typesafe-binding", test_typesafe_binding);
|
g_test_add_func ("/gsettings/typesafe-binding", test_typesafe_binding);
|
||||||
|
g_test_add_func ("/gsettings/typesafe-binding:child", test_typesafe_binding_child);
|
||||||
g_test_add_func ("/gsettings/no-read-binding", test_no_read_binding);
|
g_test_add_func ("/gsettings/no-read-binding", test_no_read_binding);
|
||||||
|
g_test_add_func ("/gsettings/no-read-binding:fail", test_no_read_binding_fail);
|
||||||
|
g_test_add_func ("/gsettings/no-read-binding:pass", test_no_read_binding_pass);
|
||||||
g_test_add_func ("/gsettings/no-write-binding", test_no_write_binding);
|
g_test_add_func ("/gsettings/no-write-binding", test_no_write_binding);
|
||||||
|
g_test_add_func ("/gsettings/no-write-binding:fail", test_no_write_binding_fail);
|
||||||
|
g_test_add_func ("/gsettings/no-write-binding:pass", test_no_write_binding_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_test_add_func ("/gsettings/keyfile", test_keyfile);
|
g_test_add_func ("/gsettings/keyfile", test_keyfile);
|
||||||
g_test_add_func ("/gsettings/child-schema", test_child_schema);
|
g_test_add_func ("/gsettings/child-schema", test_child_schema);
|
||||||
g_test_add_func ("/gsettings/strinfo", test_strinfo);
|
g_test_add_func ("/gsettings/strinfo", test_strinfo);
|
||||||
g_test_add_func ("/gsettings/enums", test_enums);
|
g_test_add_func ("/gsettings/enums", test_enums);
|
||||||
|
g_test_add_func ("/gsettings/enums:non-enum-key", test_enums_non_enum_key);
|
||||||
|
g_test_add_func ("/gsettings/enums:non-enum-value", test_enums_non_enum_value);
|
||||||
|
g_test_add_func ("/gsettings/enums:range", test_enums_range);
|
||||||
|
g_test_add_func ("/gsettings/enums:non-flags", test_enums_non_flags);
|
||||||
g_test_add_func ("/gsettings/flags", test_flags);
|
g_test_add_func ("/gsettings/flags", test_flags);
|
||||||
|
g_test_add_func ("/gsettings/flags:non-flags-key", test_flags_non_flags_key);
|
||||||
|
g_test_add_func ("/gsettings/flags:non-flags-value", test_flags_non_flags_value);
|
||||||
|
g_test_add_func ("/gsettings/flags:range", test_flags_range);
|
||||||
|
g_test_add_func ("/gsettings/flags:non-enum", test_flags_non_enum);
|
||||||
g_test_add_func ("/gsettings/range", test_range);
|
g_test_add_func ("/gsettings/range", test_range);
|
||||||
|
g_test_add_func ("/gsettings/range:high", test_range_high);
|
||||||
|
g_test_add_func ("/gsettings/range:low", test_range_low);
|
||||||
g_test_add_func ("/gsettings/list-items", test_list_items);
|
g_test_add_func ("/gsettings/list-items", test_list_items);
|
||||||
g_test_add_func ("/gsettings/list-schemas", test_list_schemas);
|
g_test_add_func ("/gsettings/list-schemas", test_list_schemas);
|
||||||
g_test_add_func ("/gsettings/mapped", test_get_mapped);
|
g_test_add_func ("/gsettings/mapped", test_get_mapped);
|
||||||
|
@ -216,23 +216,25 @@ static GMemVTable array_large_size_mem_vtable = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
array_large_size (void)
|
array_large_size_subprocess (void)
|
||||||
{
|
{
|
||||||
GArray *array;
|
GArray *array;
|
||||||
|
|
||||||
g_test_bug ("568760");
|
|
||||||
|
|
||||||
array = g_array_new (FALSE, FALSE, sizeof (char));
|
array = g_array_new (FALSE, FALSE, sizeof (char));
|
||||||
|
|
||||||
if (g_test_trap_fork (5 /* s */ * 1000 /* ms */ * 1000 /* µs */, 0))
|
|
||||||
{
|
|
||||||
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 ();
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
|
|
||||||
g_array_free (array, TRUE);
|
static void
|
||||||
|
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 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -851,6 +853,7 @@ 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);
|
||||||
|
@ -183,17 +183,21 @@ free_one (gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_datalist_clear (void)
|
test_datalist_clear_subprocess (void)
|
||||||
{
|
|
||||||
if (g_test_trap_fork (500000, 0))
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
exit (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
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 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +214,7 @@ 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 ();
|
||||||
}
|
}
|
||||||
|
@ -2809,24 +2809,12 @@ test_format_strings (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exit_on_abort (int signal)
|
do_failed_test (const char *test,
|
||||||
|
const gchar *pattern)
|
||||||
{
|
{
|
||||||
exit (signal);
|
g_test_trap_subprocess (test, 1000000, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
do_failed_test (const gchar *pattern)
|
|
||||||
{
|
|
||||||
if (g_test_trap_fork (1000000, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
|
||||||
signal (SIGABRT, exit_on_abort);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr (pattern);
|
g_test_trap_assert_stderr (pattern);
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2874,6 +2862,14 @@ check_and_free (GVariant *value,
|
|||||||
g_free (valstr);
|
g_free (valstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_varargs_empty_array (void)
|
||||||
|
{
|
||||||
|
g_variant_new ("(a{s*})", NULL);
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_varargs (void)
|
test_varargs (void)
|
||||||
{
|
{
|
||||||
@ -3406,8 +3402,8 @@ test_varargs (void)
|
|||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
if (do_failed_test ("*which type of empty array*"))
|
do_failed_test ("/gvariant/varargs:empty-array",
|
||||||
g_variant_new ("(a{s*})", NULL);
|
"*which type of empty array*");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_variant_type_info_assert_no_infos ();
|
g_variant_type_info_assert_no_infos ();
|
||||||
@ -3868,6 +3864,30 @@ test_parse_failures (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_parse_bad_format_char (void)
|
||||||
|
{
|
||||||
|
g_variant_new_parsed ("%z");
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_parse_bad_format_string (void)
|
||||||
|
{
|
||||||
|
g_variant_new_parsed ("uint32 %i", 2);
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_parse_bad_args (void)
|
||||||
|
{
|
||||||
|
g_variant_new_parsed ("%@i", g_variant_new_uint32 (2));
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_parse_positional (void)
|
test_parse_positional (void)
|
||||||
{
|
{
|
||||||
@ -3883,23 +3903,14 @@ test_parse_positional (void)
|
|||||||
|
|
||||||
if (g_test_undefined ())
|
if (g_test_undefined ())
|
||||||
{
|
{
|
||||||
if (do_failed_test ("*GVariant format string*"))
|
do_failed_test ("/gvariant/parse:bad-format-char",
|
||||||
{
|
"*GVariant format string*");
|
||||||
g_variant_new_parsed ("%z");
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (do_failed_test ("*can not parse as*"))
|
do_failed_test ("/gvariant/parse:bad-format-string",
|
||||||
{
|
"*can not parse as*");
|
||||||
g_variant_new_parsed ("uint32 %i", 2);
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (do_failed_test ("*expected GVariant of type `i'*"))
|
do_failed_test ("/gvariant/parse:bad-args",
|
||||||
{
|
"*expected GVariant of type `i'*");
|
||||||
g_variant_new_parsed ("%@i", g_variant_new_uint32 (2));
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4315,6 +4326,7 @@ main (int argc, char **argv)
|
|||||||
g_test_add_func ("/gvariant/format-strings", test_format_strings);
|
g_test_add_func ("/gvariant/format-strings", test_format_strings);
|
||||||
g_test_add_func ("/gvariant/invalid-varargs", test_invalid_varargs);
|
g_test_add_func ("/gvariant/invalid-varargs", test_invalid_varargs);
|
||||||
g_test_add_func ("/gvariant/varargs", test_varargs);
|
g_test_add_func ("/gvariant/varargs", test_varargs);
|
||||||
|
g_test_add_func ("/gvariant/varargs:empty-array", test_varargs_empty_array);
|
||||||
g_test_add_func ("/gvariant/valist", test_valist);
|
g_test_add_func ("/gvariant/valist", test_valist);
|
||||||
g_test_add_func ("/gvariant/builder-memory", test_builder_memory);
|
g_test_add_func ("/gvariant/builder-memory", test_builder_memory);
|
||||||
g_test_add_func ("/gvariant/hashing", test_hashing);
|
g_test_add_func ("/gvariant/hashing", test_hashing);
|
||||||
@ -4322,6 +4334,9 @@ main (int argc, char **argv)
|
|||||||
g_test_add_func ("/gvariant/parser", test_parses);
|
g_test_add_func ("/gvariant/parser", test_parses);
|
||||||
g_test_add_func ("/gvariant/parse-failures", test_parse_failures);
|
g_test_add_func ("/gvariant/parse-failures", test_parse_failures);
|
||||||
g_test_add_func ("/gvariant/parse-positional", test_parse_positional);
|
g_test_add_func ("/gvariant/parse-positional", test_parse_positional);
|
||||||
|
g_test_add_func ("/gvariant/parse:bad-format-char", test_parse_bad_format_char);
|
||||||
|
g_test_add_func ("/gvariant/parse:bad-format-string", test_parse_bad_format_string);
|
||||||
|
g_test_add_func ("/gvariant/parse:bad-args", test_parse_bad_args);
|
||||||
g_test_add_func ("/gvariant/floating", test_floating);
|
g_test_add_func ("/gvariant/floating", test_floating);
|
||||||
g_test_add_func ("/gvariant/bytestring", test_bytestring);
|
g_test_add_func ("/gvariant/bytestring", test_bytestring);
|
||||||
g_test_add_func ("/gvariant/lookup-value", test_lookup_value);
|
g_test_add_func ("/gvariant/lookup-value", test_lookup_value);
|
||||||
|
@ -5,19 +5,15 @@
|
|||||||
static void
|
static void
|
||||||
test_warnings (void)
|
test_warnings (void)
|
||||||
{
|
{
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
{
|
"*test_warnings*should not be reached*");
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
}
|
g_test_assert_expected_messages ();
|
||||||
g_test_trap_assert_failed();
|
|
||||||
g_test_trap_assert_stderr ("*WARNING*test_warnings*should not be reached*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
{
|
"*test_warnings*runtime check failed*");
|
||||||
g_warn_if_fail (FALSE);
|
g_warn_if_fail (FALSE);
|
||||||
}
|
g_test_assert_expected_messages ();
|
||||||
g_test_trap_assert_failed();
|
|
||||||
g_test_trap_assert_stderr ("*WARNING*test_warnings*runtime check failed*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint log_count = 0;
|
static guint log_count = 0;
|
||||||
@ -44,113 +40,153 @@ test_set_handler (void)
|
|||||||
|
|
||||||
id = g_log_set_handler ("bu", G_LOG_LEVEL_INFO, log_handler, NULL);
|
id = g_log_set_handler ("bu", G_LOG_LEVEL_INFO, log_handler, NULL);
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
g_log ("bu", G_LOG_LEVEL_DEBUG, "message");
|
g_log ("bu", G_LOG_LEVEL_DEBUG, "message");
|
||||||
g_log ("ba", G_LOG_LEVEL_DEBUG, "message");
|
g_log ("ba", G_LOG_LEVEL_DEBUG, "message");
|
||||||
g_log ("bu", G_LOG_LEVEL_INFO, "message");
|
g_log ("bu", G_LOG_LEVEL_INFO, "message");
|
||||||
g_log ("ba", G_LOG_LEVEL_INFO, "message");
|
g_log ("ba", G_LOG_LEVEL_INFO, "message");
|
||||||
|
|
||||||
g_assert_cmpint (log_count, ==, 1);
|
g_assert_cmpint (log_count, ==, 1);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
|
|
||||||
g_log_remove_handler ("bu", id);
|
g_log_remove_handler ("bu", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_default_handler (void)
|
test_default_handler_error (void)
|
||||||
{
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
g_error ("message1");
|
g_error ("message1");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*ERROR*message1*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
static void
|
||||||
|
test_default_handler_critical (void)
|
||||||
{
|
{
|
||||||
g_critical ("message2");
|
g_critical ("message2");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*CRITICAL*message2*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
static void
|
||||||
|
test_default_handler_warning (void)
|
||||||
{
|
{
|
||||||
g_warning ("message3");
|
g_warning ("message3");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*WARNING*message3*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
static void
|
||||||
|
test_default_handler_message (void)
|
||||||
{
|
{
|
||||||
g_message ("message4");
|
g_message ("message4");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stderr ("*Message*message4*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
static void
|
||||||
|
test_default_handler_info (void)
|
||||||
{
|
{
|
||||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "message5");
|
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "message5");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout_unmatched ("*INFO*message5*");
|
|
||||||
|
|
||||||
g_setenv ("G_MESSAGES_DEBUG", "foo bar baz", TRUE);
|
static void
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
test_default_handler_bar_info (void)
|
||||||
{
|
{
|
||||||
|
g_setenv ("G_MESSAGES_DEBUG", "foo bar baz", TRUE);
|
||||||
|
|
||||||
g_log ("bar", G_LOG_LEVEL_INFO, "message5");
|
g_log ("bar", G_LOG_LEVEL_INFO, "message5");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*INFO*message5*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
static void
|
||||||
|
test_default_handler_baz_debug (void)
|
||||||
{
|
{
|
||||||
|
g_setenv ("G_MESSAGES_DEBUG", "foo bar baz", TRUE);
|
||||||
|
|
||||||
g_log ("baz", G_LOG_LEVEL_DEBUG, "message6");
|
g_log ("baz", G_LOG_LEVEL_DEBUG, "message6");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*DEBUG*message6*");
|
|
||||||
|
|
||||||
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
|
static void
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
test_default_handler_debug (void)
|
||||||
{
|
{
|
||||||
|
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
|
||||||
|
|
||||||
g_log ("foo", G_LOG_LEVEL_DEBUG, "6");
|
g_log ("foo", G_LOG_LEVEL_DEBUG, "6");
|
||||||
g_log ("bar", G_LOG_LEVEL_DEBUG, "6");
|
g_log ("bar", G_LOG_LEVEL_DEBUG, "6");
|
||||||
g_log ("baz", G_LOG_LEVEL_DEBUG, "6");
|
g_log ("baz", G_LOG_LEVEL_DEBUG, "6");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*DEBUG*6*6*6*");
|
|
||||||
|
|
||||||
g_unsetenv ("G_MESSAGES_DEBUG");
|
static void
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
test_default_handler_0x400 (void)
|
||||||
{
|
{
|
||||||
g_log (G_LOG_DOMAIN, 1<<10, "message7");
|
g_log (G_LOG_DOMAIN, 1<<10, "message7");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_default_handler (void)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:error",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*ERROR*message1*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:critical",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*CRITICAL*message2*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:warning",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*WARNING*message3*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:message",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stderr ("*Message*message4*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:info",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stdout_unmatched ("*INFO*message5*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:bar-info",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stdout ("*INFO*message5*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:baz-debug",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stdout ("*DEBUG*message6*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:debug",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stdout ("*DEBUG*6*6*6*");
|
||||||
|
|
||||||
|
g_test_trap_subprocess ("/logging/default-handler:0x400",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
g_test_trap_assert_stdout ("*LOG-0x400*message7*");
|
g_test_trap_assert_stdout ("*LOG-0x400*message7*");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test that setting levels as fatal works */
|
/* test that setting levels as fatal works */
|
||||||
|
static void
|
||||||
|
test_fatal_log_mask_child (void)
|
||||||
|
{
|
||||||
|
g_log_set_fatal_mask ("bu", G_LOG_LEVEL_INFO);
|
||||||
|
g_log ("bu", G_LOG_LEVEL_INFO, "fatal");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_fatal_log_mask (void)
|
test_fatal_log_mask (void)
|
||||||
{
|
{
|
||||||
GLogLevelFlags flags;
|
g_test_trap_subprocess ("/logging/fatal-log-mask:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
flags = g_log_set_fatal_mask ("bu", G_LOG_LEVEL_INFO);
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
g_log ("bu", G_LOG_LEVEL_INFO, "fatal");
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_log_set_fatal_mask ("bu", flags);
|
/* G_LOG_LEVEL_INFO isn't printed by default */
|
||||||
|
g_test_trap_assert_stdout_unmatched ("*fatal*");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint my_print_count = 0;
|
static gint my_print_count = 0;
|
||||||
@ -255,8 +291,18 @@ main (int argc, char *argv[])
|
|||||||
g_test_bug_base ("http://bugzilla.gnome.org/");
|
g_test_bug_base ("http://bugzilla.gnome.org/");
|
||||||
|
|
||||||
g_test_add_func ("/logging/default-handler", test_default_handler);
|
g_test_add_func ("/logging/default-handler", test_default_handler);
|
||||||
|
g_test_add_func ("/logging/default-handler:error", test_default_handler_error);
|
||||||
|
g_test_add_func ("/logging/default-handler:critical", test_default_handler_critical);
|
||||||
|
g_test_add_func ("/logging/default-handler:warning", test_default_handler_warning);
|
||||||
|
g_test_add_func ("/logging/default-handler:message", test_default_handler_message);
|
||||||
|
g_test_add_func ("/logging/default-handler:info", test_default_handler_info);
|
||||||
|
g_test_add_func ("/logging/default-handler:bar-info", test_default_handler_bar_info);
|
||||||
|
g_test_add_func ("/logging/default-handler:baz-debug", test_default_handler_baz_debug);
|
||||||
|
g_test_add_func ("/logging/default-handler:debug", test_default_handler_debug);
|
||||||
|
g_test_add_func ("/logging/default-handler:0x400", test_default_handler_0x400);
|
||||||
g_test_add_func ("/logging/warnings", test_warnings);
|
g_test_add_func ("/logging/warnings", test_warnings);
|
||||||
g_test_add_func ("/logging/fatal-log-mask", test_fatal_log_mask);
|
g_test_add_func ("/logging/fatal-log-mask", test_fatal_log_mask);
|
||||||
|
g_test_add_func ("/logging/fatal-log-mask:child", test_fatal_log_mask_child);
|
||||||
g_test_add_func ("/logging/set-handler", test_set_handler);
|
g_test_add_func ("/logging/set-handler", test_set_handler);
|
||||||
g_test_add_func ("/logging/print-handler", test_print_handler);
|
g_test_add_func ("/logging/print-handler", test_print_handler);
|
||||||
g_test_add_func ("/logging/printerr-handler", test_printerr_handler);
|
g_test_add_func ("/logging/printerr-handler", test_printerr_handler);
|
||||||
|
@ -26,13 +26,48 @@
|
|||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static gsize a = G_MAXSIZE / 10 + 10;
|
||||||
|
static gsize b = 10;
|
||||||
|
typedef char X[10];
|
||||||
|
|
||||||
|
#define MEM_OVERFLOW_TEST(name, code) \
|
||||||
|
static void \
|
||||||
|
mem_overflow_ ## name (void) \
|
||||||
|
{ \
|
||||||
|
gpointer p; \
|
||||||
|
code; \
|
||||||
|
g_free (p); \
|
||||||
|
exit (0); \
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_OVERFLOW_TEST (malloc_n_a_a, p = g_malloc_n (a, a))
|
||||||
|
MEM_OVERFLOW_TEST (malloc_n_a_b, p = g_malloc_n (a, b))
|
||||||
|
MEM_OVERFLOW_TEST (malloc_n_b_a, p = g_malloc_n (b, a))
|
||||||
|
MEM_OVERFLOW_TEST (malloc_n_b_b, p = g_malloc_n (b, b))
|
||||||
|
|
||||||
|
MEM_OVERFLOW_TEST (malloc0_n_a_a, p = g_malloc0_n (a, a))
|
||||||
|
MEM_OVERFLOW_TEST (malloc0_n_a_b, p = g_malloc0_n (a, b))
|
||||||
|
MEM_OVERFLOW_TEST (malloc0_n_b_a, p = g_malloc0_n (b, a))
|
||||||
|
MEM_OVERFLOW_TEST (malloc0_n_b_b, p = g_malloc0_n (b, b))
|
||||||
|
|
||||||
|
MEM_OVERFLOW_TEST (realloc_n_a_a, p = g_malloc (1); p = g_realloc_n (p, a, a))
|
||||||
|
MEM_OVERFLOW_TEST (realloc_n_a_b, p = g_malloc (1); p = g_realloc_n (p, a, b))
|
||||||
|
MEM_OVERFLOW_TEST (realloc_n_b_a, p = g_malloc (1); p = g_realloc_n (p, b, a))
|
||||||
|
MEM_OVERFLOW_TEST (realloc_n_b_b, p = g_malloc (1); p = g_realloc_n (p, b, b))
|
||||||
|
|
||||||
|
MEM_OVERFLOW_TEST (new_a, p = g_new (X, a))
|
||||||
|
MEM_OVERFLOW_TEST (new_b, p = g_new (X, b))
|
||||||
|
|
||||||
|
MEM_OVERFLOW_TEST (new0_a, p = g_new0 (X, a))
|
||||||
|
MEM_OVERFLOW_TEST (new0_b, p = g_new0 (X, b))
|
||||||
|
|
||||||
|
MEM_OVERFLOW_TEST (renew_a, p = g_malloc (1); p = g_renew (X, p, a))
|
||||||
|
MEM_OVERFLOW_TEST (renew_b, p = g_malloc (1); p = g_renew (X, p, b))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mem_overflow (void)
|
mem_overflow (void)
|
||||||
{
|
{
|
||||||
gsize a = G_MAXSIZE / 10 + 10;
|
|
||||||
gsize b = 10;
|
|
||||||
gpointer p, q;
|
gpointer p, q;
|
||||||
typedef char X[10];
|
|
||||||
|
|
||||||
/* "FAIL" here apparently means "fail to overflow"... */
|
/* "FAIL" here apparently means "fail to overflow"... */
|
||||||
#define CHECK_PASS(P) p = (P); g_assert (p == NULL);
|
#define CHECK_PASS(P) p = (P); g_assert (p == NULL);
|
||||||
@ -70,66 +105,61 @@ mem_overflow (void)
|
|||||||
CHECK_FAIL (g_try_renew (X, q, b));
|
CHECK_FAIL (g_try_renew (X, q, b));
|
||||||
free (p);
|
free (p);
|
||||||
|
|
||||||
#undef CHECK_FAIL
|
#define CHECK_SUBPROCESS_FAIL(name) do { \
|
||||||
#undef CHECK_PASS
|
|
||||||
|
|
||||||
#define CHECK_FAIL(P) do { \
|
|
||||||
if (g_test_undefined ()) \
|
if (g_test_undefined ()) \
|
||||||
{ \
|
{ \
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
|
g_test_trap_subprocess ("/mem/overflow:" #name, 0, G_TEST_TRAP_SILENCE_STDERR); \
|
||||||
{ \
|
|
||||||
p = (P); \
|
|
||||||
exit (0); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
g_test_trap_assert_failed(); \
|
g_test_trap_assert_failed(); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CHECK_PASS(P) do { \
|
#define CHECK_SUBPROCESS_PASS(name) do { \
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
|
if (g_test_undefined ()) \
|
||||||
{ \
|
{ \
|
||||||
p = (P); \
|
g_test_trap_subprocess ("/mem/overflow:" #name, 0, G_TEST_TRAP_SILENCE_STDERR); \
|
||||||
g_free (p); \
|
|
||||||
exit (0); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
g_test_trap_assert_passed(); \
|
g_test_trap_assert_passed(); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
CHECK_FAIL (g_malloc_n (a, a));
|
CHECK_SUBPROCESS_FAIL (malloc_n_a_a);
|
||||||
CHECK_FAIL (g_malloc_n (a, b));
|
CHECK_SUBPROCESS_FAIL (malloc_n_a_b);
|
||||||
CHECK_FAIL (g_malloc_n (b, a));
|
CHECK_SUBPROCESS_FAIL (malloc_n_b_a);
|
||||||
CHECK_PASS (g_malloc_n (b, b));
|
CHECK_SUBPROCESS_PASS (malloc_n_b_b);
|
||||||
|
|
||||||
CHECK_FAIL (g_malloc0_n (a, a));
|
CHECK_SUBPROCESS_FAIL (malloc0_n_a_a);
|
||||||
CHECK_FAIL (g_malloc0_n (a, b));
|
CHECK_SUBPROCESS_FAIL (malloc0_n_a_b);
|
||||||
CHECK_FAIL (g_malloc0_n (b, a));
|
CHECK_SUBPROCESS_FAIL (malloc0_n_b_a);
|
||||||
CHECK_PASS (g_malloc0_n (b, b));
|
CHECK_SUBPROCESS_PASS (malloc0_n_b_b);
|
||||||
|
|
||||||
q = g_malloc (1);
|
CHECK_SUBPROCESS_FAIL (realloc_n_a_a);
|
||||||
CHECK_FAIL (g_realloc_n (q, a, a));
|
CHECK_SUBPROCESS_FAIL (realloc_n_a_b);
|
||||||
CHECK_FAIL (g_realloc_n (q, a, b));
|
CHECK_SUBPROCESS_FAIL (realloc_n_b_a);
|
||||||
CHECK_FAIL (g_realloc_n (q, b, a));
|
CHECK_SUBPROCESS_PASS (realloc_n_b_b);
|
||||||
CHECK_PASS (g_realloc_n (q, b, b));
|
|
||||||
g_free (q);
|
|
||||||
|
|
||||||
CHECK_FAIL (g_new (X, a));
|
CHECK_SUBPROCESS_FAIL (new_a);
|
||||||
CHECK_PASS (g_new (X, b));
|
CHECK_SUBPROCESS_PASS (new_b);
|
||||||
|
|
||||||
CHECK_FAIL (g_new0 (X, a));
|
CHECK_SUBPROCESS_FAIL (new0_a);
|
||||||
CHECK_PASS (g_new0 (X, b));
|
CHECK_SUBPROCESS_PASS (new0_b);
|
||||||
|
|
||||||
q = g_malloc (1);
|
CHECK_SUBPROCESS_FAIL (renew_a);
|
||||||
CHECK_FAIL (g_renew (X, q, a));
|
CHECK_SUBPROCESS_PASS (renew_b);
|
||||||
CHECK_PASS (g_renew (X, q, b));
|
|
||||||
g_free (q);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
} Empty;
|
} Empty;
|
||||||
|
|
||||||
|
static void
|
||||||
|
empty_alloc_child (void)
|
||||||
|
{
|
||||||
|
Empty *empty;
|
||||||
|
|
||||||
|
empty = g_new0 (Empty, 1);
|
||||||
|
g_assert (empty == NULL);
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
empty_alloc (void)
|
empty_alloc (void)
|
||||||
{
|
{
|
||||||
@ -137,14 +167,7 @@ empty_alloc (void)
|
|||||||
|
|
||||||
g_assert_cmpint (sizeof (Empty), ==, 0);
|
g_assert_cmpint (sizeof (Empty), ==, 0);
|
||||||
|
|
||||||
if (g_test_trap_fork (0, 0))
|
g_test_trap_subprocess ("/mem/empty-alloc:child", 0, 0);
|
||||||
{
|
|
||||||
Empty *empty;
|
|
||||||
|
|
||||||
empty = g_new0 (Empty, 1);
|
|
||||||
g_assert (empty == NULL);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +180,27 @@ main (int argc,
|
|||||||
g_test_bug_base ("http://bugzilla.gnome.org/");
|
g_test_bug_base ("http://bugzilla.gnome.org/");
|
||||||
|
|
||||||
g_test_add_func ("/mem/overflow", mem_overflow);
|
g_test_add_func ("/mem/overflow", mem_overflow);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc_n_a_a", mem_overflow_malloc_n_a_a);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc_n_a_b", mem_overflow_malloc_n_a_b);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc_n_b_a", mem_overflow_malloc_n_b_a);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc_n_b_b", mem_overflow_malloc_n_b_b);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc0_n_a_a", mem_overflow_malloc0_n_a_a);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc0_n_a_b", mem_overflow_malloc0_n_a_b);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc0_n_b_a", mem_overflow_malloc0_n_b_a);
|
||||||
|
g_test_add_func ("/mem/overflow:malloc0_n_b_b", mem_overflow_malloc0_n_b_b);
|
||||||
|
g_test_add_func ("/mem/overflow:realloc_n_a_a", mem_overflow_realloc_n_a_a);
|
||||||
|
g_test_add_func ("/mem/overflow:realloc_n_a_b", mem_overflow_realloc_n_a_b);
|
||||||
|
g_test_add_func ("/mem/overflow:realloc_n_b_a", mem_overflow_realloc_n_b_a);
|
||||||
|
g_test_add_func ("/mem/overflow:realloc_n_b_b", mem_overflow_realloc_n_b_b);
|
||||||
|
g_test_add_func ("/mem/overflow:new_a", mem_overflow_new_a);
|
||||||
|
g_test_add_func ("/mem/overflow:new_b", mem_overflow_new_b);
|
||||||
|
g_test_add_func ("/mem/overflow:new0_a", mem_overflow_new0_a);
|
||||||
|
g_test_add_func ("/mem/overflow:new0_b", mem_overflow_new0_b);
|
||||||
|
g_test_add_func ("/mem/overflow:renew_a", mem_overflow_renew_a);
|
||||||
|
g_test_add_func ("/mem/overflow:renew_b", mem_overflow_renew_b);
|
||||||
|
|
||||||
g_test_add_func ("/mem/empty-alloc", empty_alloc);
|
g_test_add_func ("/mem/empty-alloc", empty_alloc);
|
||||||
|
g_test_add_func ("/mem/empty-alloc:child", empty_alloc_child);
|
||||||
|
|
||||||
return g_test_run();
|
return g_test_run();
|
||||||
}
|
}
|
||||||
|
@ -27,36 +27,27 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
static void
|
static GOptionEntry main_entries[] = {
|
||||||
test_group_captions (void)
|
|
||||||
{
|
|
||||||
gchar *help_variants[] = { "--help", "--help-all", "--help-test" };
|
|
||||||
|
|
||||||
GOptionEntry main_entries[] = {
|
|
||||||
{ "main-switch", 0, 0,
|
{ "main-switch", 0, 0,
|
||||||
G_OPTION_ARG_NONE, NULL,
|
G_OPTION_ARG_NONE, NULL,
|
||||||
"A switch that is in the main group", NULL },
|
"A switch that is in the main group", NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
GOptionEntry group_entries[] = {
|
static GOptionEntry group_entries[] = {
|
||||||
{ "test-switch", 0, 0,
|
{ "test-switch", 0, 0,
|
||||||
G_OPTION_ARG_NONE, NULL,
|
G_OPTION_ARG_NONE, NULL,
|
||||||
"A switch that is in the test group", NULL },
|
"A switch that is in the test group", NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
gint i, j;
|
static GOptionContext *
|
||||||
|
make_options (int test_number)
|
||||||
g_test_bug ("504142");
|
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i)
|
|
||||||
{
|
{
|
||||||
gboolean have_main_entries = (0 != (i & 1));
|
|
||||||
gboolean have_test_entries = (0 != (i & 2));
|
|
||||||
|
|
||||||
GOptionContext *options;
|
GOptionContext *options;
|
||||||
GOptionGroup *group = NULL;
|
GOptionGroup *group = NULL;
|
||||||
|
gboolean have_main_entries = (0 != (test_number & 1));
|
||||||
|
gboolean have_test_entries = (0 != (test_number & 2));
|
||||||
|
|
||||||
options = g_option_context_new (NULL);
|
options = g_option_context_new (NULL);
|
||||||
|
|
||||||
@ -71,25 +62,13 @@ test_group_captions (void)
|
|||||||
g_option_group_add_entries (group, group_entries);
|
g_option_group_add_entries (group, group_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < G_N_ELEMENTS (help_variants); ++j)
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_help (GOptionContext *options, gchar **argv)
|
||||||
{
|
{
|
||||||
GTestTrapFlags trap_flags = 0;
|
gint argc = 3;
|
||||||
gchar *args[3];
|
|
||||||
|
|
||||||
args[0] = __FILE__;
|
|
||||||
args[1] = help_variants[j];
|
|
||||||
args[2] = NULL;
|
|
||||||
|
|
||||||
if (!g_test_verbose ())
|
|
||||||
trap_flags |= G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR;
|
|
||||||
|
|
||||||
g_test_message ("test setup: args='%s', main-entries=%d, test-entries=%d",
|
|
||||||
args[1], have_main_entries, have_test_entries);
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, trap_flags))
|
|
||||||
{
|
|
||||||
gchar **argv = args;
|
|
||||||
gint argc = 2;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
g_setenv ("LANG", "C", TRUE);
|
g_setenv ("LANG", "C", TRUE);
|
||||||
@ -98,35 +77,87 @@ test_group_captions (void)
|
|||||||
g_option_context_free (options);
|
g_option_context_free (options);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
static void
|
||||||
|
test_group_captions_help (gconstpointer test_number)
|
||||||
{
|
{
|
||||||
|
GOptionContext *options;
|
||||||
|
gchar *argv[] = { __FILE__, "--help", NULL };
|
||||||
|
|
||||||
|
options = make_options (GPOINTER_TO_INT (test_number));
|
||||||
|
print_help (options, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_group_captions_help_all (gconstpointer test_number)
|
||||||
|
{
|
||||||
|
GOptionContext *options;
|
||||||
|
gchar *argv[] = { __FILE__, "--help-all", NULL };
|
||||||
|
|
||||||
|
options = make_options (GPOINTER_TO_INT (test_number));
|
||||||
|
print_help (options, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_group_captions_help_test (gconstpointer test_number)
|
||||||
|
{
|
||||||
|
GOptionContext *options;
|
||||||
|
gchar *argv[] = { __FILE__, "--help-test", NULL };
|
||||||
|
|
||||||
|
options = make_options (GPOINTER_TO_INT (test_number));
|
||||||
|
print_help (options, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_group_captions (void)
|
||||||
|
{
|
||||||
|
const gchar *test_name_base[] = { "help", "help-all", "help-test" };
|
||||||
|
gchar *test_name;
|
||||||
|
gint i, j;
|
||||||
|
|
||||||
|
g_test_bug ("504142");
|
||||||
|
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
gboolean have_main_entries = (0 != (i & 1));
|
||||||
|
gboolean have_test_entries = (0 != (i & 2));
|
||||||
|
|
||||||
|
for (j = 0; j < G_N_ELEMENTS (test_name_base); ++j)
|
||||||
|
{
|
||||||
|
GTestTrapFlags trap_flags = 0;
|
||||||
gboolean expect_main_description = FALSE;
|
gboolean expect_main_description = FALSE;
|
||||||
gboolean expect_main_switch = FALSE;
|
gboolean expect_main_switch = FALSE;
|
||||||
|
|
||||||
gboolean expect_test_description = FALSE;
|
gboolean expect_test_description = FALSE;
|
||||||
gboolean expect_test_switch = FALSE;
|
gboolean expect_test_switch = FALSE;
|
||||||
gboolean expect_test_group = FALSE;
|
gboolean expect_test_group = FALSE;
|
||||||
|
|
||||||
|
if (!g_test_verbose ())
|
||||||
|
trap_flags |= G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR;
|
||||||
|
|
||||||
|
test_name = g_strdup_printf ("/option/group/captions:%s-%d",
|
||||||
|
test_name_base[j], i);
|
||||||
|
g_test_trap_subprocess (test_name, 0, trap_flags);
|
||||||
|
g_free (test_name);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
g_test_trap_assert_stderr ("");
|
g_test_trap_assert_stderr ("");
|
||||||
|
|
||||||
switch (j)
|
switch (j)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
g_assert_cmpstr ("--help", ==, args[1]);
|
g_assert_cmpstr ("help", ==, test_name_base[j]);
|
||||||
expect_main_switch = have_main_entries;
|
expect_main_switch = have_main_entries;
|
||||||
expect_test_group = have_test_entries;
|
expect_test_group = have_test_entries;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
g_assert_cmpstr ("--help-all", ==, args[1]);
|
g_assert_cmpstr ("help-all", ==, test_name_base[j]);
|
||||||
expect_main_switch = have_main_entries;
|
expect_main_switch = have_main_entries;
|
||||||
expect_test_switch = have_test_entries;
|
expect_test_switch = have_test_entries;
|
||||||
expect_test_group = have_test_entries;
|
expect_test_group = have_test_entries;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
g_assert_cmpstr ("--help-test", ==, args[1]);
|
g_assert_cmpstr ("help-test", ==, test_name_base[j]);
|
||||||
expect_test_switch = have_test_entries;
|
expect_test_switch = have_test_entries;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -162,9 +193,6 @@ test_group_captions (void)
|
|||||||
g_test_trap_assert_stdout_unmatched ("*--help-test*");
|
g_test_trap_assert_stdout_unmatched ("*--help-test*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_option_context_free (options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int error_test1_int;
|
int error_test1_int;
|
||||||
@ -2156,11 +2184,6 @@ test_group_parse (void)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
flag_reverse_string (void)
|
flag_reverse_string (void)
|
||||||
{
|
|
||||||
if (!g_test_undefined ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gchar *arg = NULL;
|
gchar *arg = NULL;
|
||||||
@ -2172,29 +2195,27 @@ flag_reverse_string (void)
|
|||||||
gboolean retval;
|
gboolean retval;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!g_test_undefined ())
|
||||||
|
return;
|
||||||
|
|
||||||
context = g_option_context_new (NULL);
|
context = g_option_context_new (NULL);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*ignoring reverse flag*");
|
||||||
g_option_context_add_main_entries (context, entries, NULL);
|
g_option_context_add_main_entries (context, entries, NULL);
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
argv = split_string ("program --test bla", &argc);
|
argv = split_string ("program --test bla", &argc);
|
||||||
|
|
||||||
retval = g_option_context_parse (context, &argc, &argv, &error);
|
retval = g_option_context_parse (context, &argc, &argv, &error);
|
||||||
g_assert (retval == FALSE);
|
g_assert (retval == TRUE);
|
||||||
g_clear_error (&error);
|
g_assert_no_error (error);
|
||||||
g_strfreev (argv);
|
g_strfreev (argv);
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*ignoring reverse flag*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flag_optional_int (void)
|
flag_optional_int (void)
|
||||||
{
|
|
||||||
if (!g_test_undefined ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gint arg = 0;
|
gint arg = 0;
|
||||||
@ -2206,25 +2227,32 @@ flag_optional_int (void)
|
|||||||
gboolean retval;
|
gboolean retval;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!g_test_undefined ())
|
||||||
|
return;
|
||||||
|
|
||||||
context = g_option_context_new (NULL);
|
context = g_option_context_new (NULL);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*ignoring no-arg, optional-arg or filename flags*");
|
||||||
g_option_context_add_main_entries (context, entries, NULL);
|
g_option_context_add_main_entries (context, entries, NULL);
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
argv = split_string ("program --test 5", &argc);
|
argv = split_string ("program --test 5", &argc);
|
||||||
|
|
||||||
retval = g_option_context_parse (context, &argc, &argv, &error);
|
retval = g_option_context_parse (context, &argc, &argv, &error);
|
||||||
g_assert (retval == FALSE);
|
g_assert (retval == TRUE);
|
||||||
g_clear_error (&error);
|
g_assert_no_error (error);
|
||||||
g_strfreev (argv);
|
g_strfreev (argv);
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
|
||||||
g_test_trap_assert_stderr ("*ignoring no-arg, optional-arg or filename flags*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
gchar *test_name;
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
g_test_bug_base ("http://bugzilla.gnome.org/");
|
g_test_bug_base ("http://bugzilla.gnome.org/");
|
||||||
@ -2232,7 +2260,25 @@ main (int argc,
|
|||||||
g_test_add_func ("/option/help/no-options", test_help_no_options);
|
g_test_add_func ("/option/help/no-options", test_help_no_options);
|
||||||
|
|
||||||
g_test_add_func ("/option/basic", test_basic);
|
g_test_add_func ("/option/basic", test_basic);
|
||||||
|
|
||||||
g_test_add_func ("/option/group/captions", test_group_captions);
|
g_test_add_func ("/option/group/captions", test_group_captions);
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
test_name = g_strdup_printf ("/option/group/captions:help-%d", i);
|
||||||
|
g_test_add_data_func (test_name, GINT_TO_POINTER (i),
|
||||||
|
test_group_captions_help);
|
||||||
|
g_free (test_name);
|
||||||
|
test_name = g_strdup_printf ("/option/group/captions:help-all-%d", i);
|
||||||
|
g_test_add_data_func (test_name, GINT_TO_POINTER (i),
|
||||||
|
test_group_captions_help_all);
|
||||||
|
g_free (test_name);
|
||||||
|
test_name = g_strdup_printf ("/option/group/captions:help-test-%d", i);
|
||||||
|
g_test_add_data_func (test_name, GINT_TO_POINTER (i),
|
||||||
|
test_group_captions_help_test);
|
||||||
|
|
||||||
|
g_free (test_name);
|
||||||
|
}
|
||||||
|
|
||||||
g_test_add_func ("/option/group/main", test_main_group);
|
g_test_add_func ("/option/group/main", test_main_group);
|
||||||
g_test_add_func ("/option/group/error-hook", test_error_hook);
|
g_test_add_func ("/option/group/error-hook", test_error_hook);
|
||||||
g_test_add_func ("/option/group/parse", test_group_parse);
|
g_test_add_func ("/option/group/parse", test_group_parse);
|
||||||
|
@ -59,16 +59,20 @@ test_scanner_warn (ScannerFixture *fix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_scanner_error (ScannerFixture *fix,
|
test_scanner_error_child (ScannerFixture *fix,
|
||||||
gconstpointer test_data)
|
gconstpointer test_data)
|
||||||
{
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
{
|
||||||
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");
|
||||||
g_assert_cmpint (fix->scanner->parse_errors, ==, pe + 1);
|
g_assert_cmpint (fix->scanner->parse_errors, ==, pe + 1);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_scanner_error (ScannerFixture *fix,
|
||||||
|
gconstpointer test_data)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/scanner/error:child", 0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
|
||||||
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*");
|
||||||
}
|
}
|
||||||
@ -135,6 +139,7 @@ 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:child", ScannerFixture, 0, scanner_fixture_setup, test_scanner_error_child, 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);
|
||||||
|
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
/* We test deprecated functionality here */
|
/* We test deprecated functionality here */
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_slice_config_child (void)
|
||||||
|
{
|
||||||
|
g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_slice_config (void)
|
test_slice_config (void)
|
||||||
{
|
{
|
||||||
if (!g_test_undefined ())
|
g_test_trap_subprocess ("/slice/config:child",
|
||||||
return;
|
1000000, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
|
|
||||||
if (g_test_trap_fork (1000000, G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
|
|
||||||
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ 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:child", test_slice_config_child);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
@ -609,36 +609,27 @@ test_positional_params (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_positional_params2 (void)
|
test_positional_params2_child (void)
|
||||||
{
|
{
|
||||||
gint res;
|
gint res;
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%2$c %1$c\n", 'b', 'a');
|
||||||
{
|
g_assert_cmpint (res, ==, 4);
|
||||||
res = g_printf ("%2$c %1$c", 'b', 'a');
|
|
||||||
g_assert_cmpint (res, ==, 3);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*a b*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%1$*2$.*3$s\n", "abc", 5, 2);
|
||||||
{
|
|
||||||
res = g_printf ("%1$*2$.*3$s", "abc", 5, 2);
|
|
||||||
g_assert_cmpint (res, ==, 5);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("* ab*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%1$s%1$s", "abc");
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
g_assert_cmpint (res, ==, 6);
|
||||||
exit (0);
|
|
||||||
|
res = g_printf ("%1$s%1$s\n", "abc");
|
||||||
|
g_assert_cmpint (res, ==, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_positional_params2 (void)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/printf/test-positional-params:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
g_test_trap_assert_stdout ("*abcabc*");
|
g_test_trap_assert_stdout ("a b\n ab\nabcabc\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -661,16 +652,19 @@ test_positional_params3 (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_percent2 (void)
|
test_percent2_child (void)
|
||||||
{
|
{
|
||||||
gint res;
|
gint res;
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%%");
|
res = g_printf ("%%");
|
||||||
g_assert_cmpint (res, ==, 1);
|
g_assert_cmpint (res, ==, 1);
|
||||||
exit (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_percent2 (void)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/printf/test-percent:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
g_test_trap_assert_stdout ("*%*");
|
g_test_trap_assert_stdout ("*%*");
|
||||||
}
|
}
|
||||||
@ -770,83 +764,41 @@ _Pragma ("GCC diagnostic pop")
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_64bit2 (void)
|
test_64bit2_child (void)
|
||||||
{
|
{
|
||||||
gint res;
|
gint res;
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" G_GINT64_FORMAT "\n", (gint64)123456);
|
||||||
{
|
|
||||||
res = g_printf ("%" G_GINT64_FORMAT, (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*123456*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%" G_GINT64_FORMAT, (gint64)-123456);
|
|
||||||
g_assert_cmpint (res, ==, 7);
|
g_assert_cmpint (res, ==, 7);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*-123456*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" G_GINT64_FORMAT "\n", (gint64)-123456);
|
||||||
{
|
g_assert_cmpint (res, ==, 8);
|
||||||
res = g_printf ("%" G_GUINT64_FORMAT, (guint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*123456*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" G_GUINT64_FORMAT "\n", (guint64)123456);
|
||||||
{
|
|
||||||
res = g_printf ("%" G_GINT64_MODIFIER "o", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*361100*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%#" G_GINT64_MODIFIER "o", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 7);
|
g_assert_cmpint (res, ==, 7);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*0361100*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" G_GINT64_MODIFIER "o\n", (gint64)123456);
|
||||||
{
|
|
||||||
res = g_printf ("%" G_GINT64_MODIFIER "x", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 5);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*1e240*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%#" G_GINT64_MODIFIER "x", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 7);
|
g_assert_cmpint (res, ==, 7);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*0x1e240*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%#" G_GINT64_MODIFIER "o\n", (gint64)123456);
|
||||||
{
|
g_assert_cmpint (res, ==, 8);
|
||||||
res = g_printf ("%" G_GINT64_MODIFIER "X", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 5);
|
res = g_printf ("%" G_GINT64_MODIFIER "x\n", (gint64)123456);
|
||||||
exit (0);
|
g_assert_cmpint (res, ==, 6);
|
||||||
|
|
||||||
|
res = g_printf ("%#" G_GINT64_MODIFIER "x\n", (gint64)123456);
|
||||||
|
g_assert_cmpint (res, ==, 8);
|
||||||
|
|
||||||
|
res = g_printf ("%" G_GINT64_MODIFIER "X\n", (gint64)123456);
|
||||||
|
g_assert_cmpint (res, ==, 6);
|
||||||
}
|
}
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*1E240*");
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
static void
|
||||||
|
test_64bit2_child_win32 (void)
|
||||||
|
{
|
||||||
|
gint res;
|
||||||
|
|
||||||
/* On Win32, test that the "ll" modifier also works, for backward
|
/* On Win32, test that the "ll" modifier also works, for backward
|
||||||
* compatibility. One really should use the G_GINT64_MODIFIER (which
|
* compatibility. One really should use the G_GINT64_MODIFIER (which
|
||||||
* on Win32 is the "I64" that the (msvcrt) C library's printf uses),
|
* on Win32 is the "I64" that the (msvcrt) C library's printf uses),
|
||||||
@ -863,82 +815,53 @@ _Pragma ("GCC diagnostic ignored \"-Wformat\"")
|
|||||||
_Pragma ("GCC diagnostic ignored \"-Wformat-extra-args\"")
|
_Pragma ("GCC diagnostic ignored \"-Wformat-extra-args\"")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" "lli\n", (gint64)123456);
|
||||||
{
|
|
||||||
res = g_printf ("%" "lli", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*123456*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%" "lli", (gint64)-123456);
|
|
||||||
g_assert_cmpint (res, ==, 7);
|
g_assert_cmpint (res, ==, 7);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*-123456*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" "lli\n", (gint64)-123456);
|
||||||
{
|
g_assert_cmpint (res, ==, 8);
|
||||||
res = g_printf ("%" "llu", (guint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*123456*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" "llu\n", (guint64)123456);
|
||||||
{
|
|
||||||
res = g_printf ("%" "ll" "o", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 6);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*361100*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%#" "ll" "o", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 7);
|
g_assert_cmpint (res, ==, 7);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*0361100*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%" "ll" "o\n", (gint64)123456);
|
||||||
{
|
|
||||||
res = g_printf ("%" "ll" "x", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 5);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*1e240*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
|
||||||
{
|
|
||||||
res = g_printf ("%#" "ll" "x", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 7);
|
g_assert_cmpint (res, ==, 7);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
|
||||||
g_test_trap_assert_stdout ("*0x1e240*");
|
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
|
res = g_printf ("%#" "ll" "o\n", (gint64)123456);
|
||||||
{
|
g_assert_cmpint (res, ==, 8);
|
||||||
res = g_printf ("%" "ll" "X", (gint64)123456);
|
|
||||||
g_assert_cmpint (res, ==, 5);
|
res = g_printf ("%" "ll" "x\n", (gint64)123456);
|
||||||
exit (0);
|
g_assert_cmpint (res, ==, 6);
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
res = g_printf ("%#" "ll" "x\n", (gint64)123456);
|
||||||
g_test_trap_assert_stdout ("*1E240*");
|
g_assert_cmpint (res, ==, 8);
|
||||||
|
|
||||||
|
res = g_printf ("%" "ll" "X\n", (gint64)123456);
|
||||||
|
g_assert_cmpint (res, ==, 6);
|
||||||
|
|
||||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||||
_Pragma ("GCC diagnostic pop")
|
_Pragma ("GCC diagnostic pop")
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_64bit2 (void)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/printf/test-64bit:child",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stdout ("123456\n-123456\n123456\n"
|
||||||
|
"361100\n0361100\n1e240\n"
|
||||||
|
"0x1e240\n1E240\n");
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
g_test_trap_subprocess ("/printf/test-64bit:child-win32",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDOUT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stdout ("123456\n-123456\n123456\n"
|
||||||
|
"361100\n0361100\n1e240\n"
|
||||||
|
"0x1e240\n1E240\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,8 +909,14 @@ 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:child", test_percent2_child);
|
||||||
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:child", test_positional_params2_child);
|
||||||
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:child", test_64bit2_child);
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
g_test_add_func ("/printf/test-64bit:child-win32", test_64bit2_child_win32);
|
||||||
|
#endif
|
||||||
|
|
||||||
g_test_add_func ("/sprintf/test-positional-params", test_positional_params3);
|
g_test_add_func ("/sprintf/test-positional-params", test_positional_params3);
|
||||||
g_test_add_func ("/sprintf/upper-bound", test_upper_bound);
|
g_test_add_func ("/sprintf/upper-bound", test_upper_bound);
|
||||||
|
@ -25,6 +25,20 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* test assertion variants */
|
/* test assertion variants */
|
||||||
|
static void
|
||||||
|
test_assertions_bad_cmpstr (void)
|
||||||
|
{
|
||||||
|
g_assert_cmpstr ("fzz", !=, "fzz");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_assertions_bad_cmpint (void)
|
||||||
|
{
|
||||||
|
g_assert_cmpint (4, !=, 4);
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_assertions (void)
|
test_assertions (void)
|
||||||
{
|
{
|
||||||
@ -46,17 +60,13 @@ test_assertions (void)
|
|||||||
g_assert_cmpstr ("fzz", >, "faa");
|
g_assert_cmpstr ("fzz", >, "faa");
|
||||||
g_assert_cmpstr ("fzz", ==, "fzz");
|
g_assert_cmpstr ("fzz", ==, "fzz");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/assertions:bad_cmpstr",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_assert_cmpstr ("fzz", !=, "fzz");
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*assertion failed*");
|
g_test_trap_assert_stderr ("*assertion failed*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/assertions:bad_cmpint",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_assert_cmpint (4, !=, 4);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*assertion failed*");
|
g_test_trap_assert_stderr ("*assertion failed*");
|
||||||
}
|
}
|
||||||
@ -290,108 +300,152 @@ fatal_handler (const gchar *log_domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_fatal_log_handler (void)
|
test_fatal_log_handler_critical_pass (void)
|
||||||
{
|
{
|
||||||
g_test_log_set_fatal_handler (fatal_handler, NULL);
|
g_test_log_set_fatal_handler (fatal_handler, NULL);
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_str_has_prefix (NULL, "file://");
|
||||||
|
g_critical ("Test passing");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_fatal_log_handler_error_fail (void)
|
||||||
|
{
|
||||||
|
g_error ("Test failing");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_fatal_log_handler_critical_fail (void)
|
||||||
{
|
{
|
||||||
g_str_has_prefix (NULL, "file://");
|
g_str_has_prefix (NULL, "file://");
|
||||||
g_critical ("Test passing");
|
g_critical ("Test passing");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_fatal_log_handler (void)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/misc/fatal-log-handler:critical-pass",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stderr ("*CRITICAL*g_str_has_prefix*");
|
||||||
|
g_test_trap_assert_stderr ("*CRITICAL*Test passing*");
|
||||||
|
|
||||||
g_test_log_set_fatal_handler (NULL, NULL);
|
g_test_trap_subprocess ("/misc/fatal-log-handler:error-fail",
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_error ("Test failing");
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*ERROR*Test failing*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/fatal-log-handler:critical-fail",
|
||||||
g_str_has_prefix (NULL, "file://");
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
|
g_test_trap_assert_stderr ("*CRITICAL*g_str_has_prefix*");
|
||||||
|
g_test_trap_assert_stderr_unmatched ("*CRITICAL*Test passing*");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
expected_messages_helper (void)
|
test_expected_messages_warning (void)
|
||||||
{
|
{
|
||||||
g_warning ("This is a %d warning", g_random_int ());
|
g_warning ("This is a %d warning", g_random_int ());
|
||||||
g_return_if_reached ();
|
g_return_if_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_expected_messages (void)
|
test_expected_messages_expect_warning (void)
|
||||||
{
|
{
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"This is a * warning");
|
||||||
|
test_expected_messages_warning ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_expected_messages_wrong_warning (void)
|
||||||
{
|
{
|
||||||
expected_messages_helper ();
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"*should not be *");
|
||||||
|
test_expected_messages_warning ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_expected_messages_expected (void)
|
||||||
|
{
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"This is a * warning");
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"*should not be reached");
|
||||||
|
|
||||||
|
test_expected_messages_warning ();
|
||||||
|
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_expected_messages_extra_warning (void)
|
||||||
|
{
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"This is a * warning");
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"*should not be reached");
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"nope");
|
||||||
|
|
||||||
|
test_expected_messages_warning ();
|
||||||
|
|
||||||
|
/* If we don't assert, it won't notice the missing message */
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_expected_messages_unexpected_extra_warning (void)
|
||||||
|
{
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"This is a * warning");
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"*should not be reached");
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"nope");
|
||||||
|
|
||||||
|
test_expected_messages_warning ();
|
||||||
|
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_expected_messages (void)
|
||||||
|
{
|
||||||
|
g_test_trap_subprocess ("/misc/expected-messages:warning",
|
||||||
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*This is a * warning*");
|
g_test_trap_assert_stderr ("*This is a * warning*");
|
||||||
g_test_trap_assert_stderr_unmatched ("*should not be reached*");
|
g_test_trap_assert_stderr_unmatched ("*should not be reached*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/expected-messages:expect-warning",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
|
||||||
"This is a * warning");
|
|
||||||
expected_messages_helper ();
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr_unmatched ("*This is a * warning*");
|
g_test_trap_assert_stderr_unmatched ("*This is a * warning*");
|
||||||
g_test_trap_assert_stderr ("*should not be reached*");
|
g_test_trap_assert_stderr ("*should not be reached*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/expected-messages:wrong-warning",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
||||||
"*should not be *");
|
|
||||||
expected_messages_helper ();
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr_unmatched ("*should not be reached*");
|
g_test_trap_assert_stderr_unmatched ("*should not be reached*");
|
||||||
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*should not be *WARNING*This is a * warning*");
|
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*should not be *WARNING*This is a * warning*");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/expected-messages:expected",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
|
||||||
"This is a * warning");
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
||||||
"*should not be reached");
|
|
||||||
expected_messages_helper ();
|
|
||||||
g_test_assert_expected_messages ();
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
g_test_trap_assert_stderr ("");
|
g_test_trap_assert_stderr ("");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/expected-messages:extra-warning",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
|
||||||
"This is a * warning");
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
||||||
"*should not be reached");
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
||||||
"nope");
|
|
||||||
expected_messages_helper ();
|
|
||||||
/* If we don't assert, it won't notice the missing message */
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_passed ();
|
g_test_trap_assert_passed ();
|
||||||
g_test_trap_assert_stderr ("");
|
g_test_trap_assert_stderr ("");
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/misc/expected-messages:unexpected-extra-warning",
|
||||||
{
|
0, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
|
||||||
"This is a * warning");
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
||||||
"*should not be reached");
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
||||||
"nope");
|
|
||||||
expected_messages_helper ();
|
|
||||||
g_test_assert_expected_messages ();
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*nope*");
|
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*nope*");
|
||||||
}
|
}
|
||||||
@ -406,6 +460,8 @@ main (int argc,
|
|||||||
g_test_add_func ("/random-generator/rand-2", test_rand2);
|
g_test_add_func ("/random-generator/rand-2", test_rand2);
|
||||||
g_test_add_func ("/random-generator/random-conversions", test_random_conversions);
|
g_test_add_func ("/random-generator/random-conversions", test_random_conversions);
|
||||||
g_test_add_func ("/misc/assertions", test_assertions);
|
g_test_add_func ("/misc/assertions", test_assertions);
|
||||||
|
g_test_add_func ("/misc/assertions:bad_cmpstr", test_assertions_bad_cmpstr);
|
||||||
|
g_test_add_func ("/misc/assertions:bad_cmpint", test_assertions_bad_cmpint);
|
||||||
g_test_add_data_func ("/misc/test-data", (void*) 0xc0c0baba, test_data_test);
|
g_test_add_data_func ("/misc/test-data", (void*) 0xc0c0baba, test_data_test);
|
||||||
g_test_add ("/misc/primetoul", Fixturetest, (void*) 0xc0cac01a, fixturetest_setup, fixturetest_test, fixturetest_teardown);
|
g_test_add ("/misc/primetoul", Fixturetest, (void*) 0xc0cac01a, fixturetest_setup, fixturetest_test, fixturetest_teardown);
|
||||||
if (g_test_perf())
|
if (g_test_perf())
|
||||||
@ -431,7 +487,17 @@ main (int argc,
|
|||||||
g_test_add_func ("/subprocess/patterns:child", test_subprocess_patterns_child);
|
g_test_add_func ("/subprocess/patterns:child", 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:critical-pass", test_fatal_log_handler_critical_pass);
|
||||||
|
g_test_add_func ("/misc/fatal-log-handler:error-fail", test_fatal_log_handler_error_fail);
|
||||||
|
g_test_add_func ("/misc/fatal-log-handler:critical-fail", test_fatal_log_handler_critical_fail);
|
||||||
|
|
||||||
g_test_add_func ("/misc/expected-messages", test_expected_messages);
|
g_test_add_func ("/misc/expected-messages", test_expected_messages);
|
||||||
|
g_test_add_func ("/misc/expected-messages:warning", test_expected_messages_warning);
|
||||||
|
g_test_add_func ("/misc/expected-messages:expect-warning", test_expected_messages_expect_warning);
|
||||||
|
g_test_add_func ("/misc/expected-messages:wrong-warning", test_expected_messages_wrong_warning);
|
||||||
|
g_test_add_func ("/misc/expected-messages:expected", test_expected_messages_expected);
|
||||||
|
g_test_add_func ("/misc/expected-messages:extra-warning", test_expected_messages_extra_warning);
|
||||||
|
g_test_add_func ("/misc/expected-messages:unexpected-extra-warning", test_expected_messages_unexpected_extra_warning);
|
||||||
|
|
||||||
return g_test_run();
|
return g_test_run();
|
||||||
}
|
}
|
||||||
|
@ -260,6 +260,20 @@ 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)
|
||||||
{
|
{
|
||||||
@ -294,12 +308,7 @@ 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);
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
g_test_trap_subprocess ("/utils/debug:help", 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_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*");
|
||||||
}
|
}
|
||||||
@ -535,6 +544,7 @@ 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: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);
|
||||||
|
@ -695,9 +695,18 @@ static void test_implementation_class_init (TestImplementationClass *class)
|
|||||||
g_object_class_install_property (class, 1, pspec);
|
g_object_class_install_property (class, 1, pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
gint change_this_flag;
|
||||||
|
gint change_this_type;
|
||||||
|
gint use_this_flag;
|
||||||
|
gint use_this_type;
|
||||||
|
} TestParamImplementData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_param_implement (void)
|
test_param_implement_child (gconstpointer user_data)
|
||||||
{
|
{
|
||||||
|
TestParamImplementData *data = (gpointer) user_data;
|
||||||
|
|
||||||
/* GObject oddity: GObjectClass must be initialised before we can
|
/* GObject oddity: GObjectClass must be initialised before we can
|
||||||
* initialise a GTypeInterface.
|
* initialise a GTypeInterface.
|
||||||
*/
|
*/
|
||||||
@ -706,6 +715,22 @@ test_param_implement (void)
|
|||||||
/* Bring up the interface first. */
|
/* Bring up the interface first. */
|
||||||
g_type_default_interface_ref (test_interface_get_type ());
|
g_type_default_interface_ref (test_interface_get_type ());
|
||||||
|
|
||||||
|
/* Copy the flags into the global vars so
|
||||||
|
* test_implementation_class_init() will see them.
|
||||||
|
*/
|
||||||
|
change_this_flag = data->change_this_flag;
|
||||||
|
change_this_type = data->change_this_type;
|
||||||
|
use_this_flag = data->use_this_flag;
|
||||||
|
use_this_type = data->use_this_type;
|
||||||
|
|
||||||
|
g_type_class_ref (test_implementation_get_type ());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_param_implement (void)
|
||||||
|
{
|
||||||
|
gchar *test_path;
|
||||||
|
|
||||||
for (change_this_flag = 0; change_this_flag < 16; change_this_flag++)
|
for (change_this_flag = 0; change_this_flag < 16; change_this_flag++)
|
||||||
for (change_this_type = 0; change_this_type < 3; change_this_type++)
|
for (change_this_type = 0; change_this_type < 3; change_this_type++)
|
||||||
for (use_this_flag = 0; use_this_flag < 16; use_this_flag++)
|
for (use_this_flag = 0; use_this_flag < 16; use_this_flag++)
|
||||||
@ -721,11 +746,11 @@ test_param_implement (void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_test_trap_fork (G_TIME_SPAN_SECOND, G_TEST_TRAP_SILENCE_STDERR))
|
test_path = g_strdup_printf ("/param/implement:%d-%d-%d-%d",
|
||||||
{
|
change_this_flag, change_this_type,
|
||||||
g_type_class_ref (test_implementation_get_type ());
|
use_this_flag, use_this_type);
|
||||||
exit (0);
|
g_test_trap_subprocess (test_path, G_TIME_SPAN_SECOND, G_TEST_TRAP_SILENCE_STDERR);
|
||||||
}
|
g_free (test_path);
|
||||||
|
|
||||||
/* We want to ensure that any flags mismatch problems are reported first. */
|
/* We want to ensure that any flags mismatch problems are reported first. */
|
||||||
switch (valid_impl_flags[change_this_flag][use_this_flag])
|
switch (valid_impl_flags[change_this_flag][use_this_flag])
|
||||||
@ -789,6 +814,9 @@ test_param_implement (void)
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
TestParamImplementData data, *test_data;
|
||||||
|
gchar *test_path;
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
g_test_add_func ("/param/value", test_param_value);
|
g_test_add_func ("/param/value", test_param_value);
|
||||||
@ -796,7 +824,21 @@ main (int argc, char *argv[])
|
|||||||
g_test_add_func ("/param/qdata", test_param_qdata);
|
g_test_add_func ("/param/qdata", test_param_qdata);
|
||||||
g_test_add_func ("/param/validate", test_param_validate);
|
g_test_add_func ("/param/validate", test_param_validate);
|
||||||
g_test_add_func ("/param/convert", test_param_convert);
|
g_test_add_func ("/param/convert", test_param_convert);
|
||||||
|
|
||||||
g_test_add_func ("/param/implement", test_param_implement);
|
g_test_add_func ("/param/implement", test_param_implement);
|
||||||
|
for (data.change_this_flag = 0; data.change_this_flag < 16; data.change_this_flag++)
|
||||||
|
for (data.change_this_type = 0; data.change_this_type < 3; data.change_this_type++)
|
||||||
|
for (data.use_this_flag = 0; data.use_this_flag < 16; data.use_this_flag++)
|
||||||
|
for (data.use_this_type = 0; data.use_this_type < 4; data.use_this_type++)
|
||||||
|
{
|
||||||
|
test_path = g_strdup_printf ("/param/implement:%d-%d-%d-%d",
|
||||||
|
data.change_this_flag, data.change_this_type,
|
||||||
|
data.use_this_flag, data.use_this_type);
|
||||||
|
test_data = g_memdup (&data, sizeof (TestParamImplementData));
|
||||||
|
g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free);
|
||||||
|
g_free (test_path);
|
||||||
|
}
|
||||||
|
|
||||||
g_test_add_func ("/value/transform", test_value_transform);
|
g_test_add_func ("/value/transform", test_value_transform);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
|
@ -5,6 +5,7 @@ SUBDIRS=gobject refcount
|
|||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
$(gmodule_INCLUDES) \
|
$(gmodule_INCLUDES) \
|
||||||
-DGLIB_DISABLE_DEPRECATION_WARNINGS \
|
-DGLIB_DISABLE_DEPRECATION_WARNINGS \
|
||||||
|
-DG_LOG_DOMAIN=\"GLib\" \
|
||||||
$(GLIB_DEBUG_FLAGS)
|
$(GLIB_DEBUG_FLAGS)
|
||||||
|
|
||||||
AM_CFLAGS = -g
|
AM_CFLAGS = -g
|
||||||
|
@ -552,32 +552,30 @@ test_g_parse_debug_string (void)
|
|||||||
static void
|
static void
|
||||||
log_warning_error_tests (void)
|
log_warning_error_tests (void)
|
||||||
{
|
{
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE,
|
||||||
{
|
"*is a g_message test*");
|
||||||
g_message ("this is a g_message test.");
|
g_message ("this is a g_message test.");
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE,
|
||||||
|
"*non-printable UTF-8*");
|
||||||
g_message ("non-printable UTF-8: \"\xc3\xa4\xda\x85\"");
|
g_message ("non-printable UTF-8: \"\xc3\xa4\xda\x85\"");
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE,
|
||||||
|
"*unsafe chars*");
|
||||||
g_message ("unsafe chars: \"\x10\x11\x12\n\t\x7f\x81\x82\x83\"");
|
g_message ("unsafe chars: \"\x10\x11\x12\n\t\x7f\x81\x82\x83\"");
|
||||||
exit (0);
|
g_test_assert_expected_messages ();
|
||||||
}
|
|
||||||
g_test_trap_assert_passed();
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
g_test_trap_assert_stderr ("*is a g_message test*");
|
"*harmless warning*");
|
||||||
g_test_trap_assert_stderr ("*non-printable UTF-8*");
|
|
||||||
g_test_trap_assert_stderr ("*unsafe chars*");
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
|
||||||
g_warning ("harmless warning with parameters: %d %s %#x", 42, "Boo", 12345);
|
g_warning ("harmless warning with parameters: %d %s %#x", 42, "Boo", 12345);
|
||||||
exit (0);
|
g_test_assert_expected_messages ();
|
||||||
}
|
|
||||||
g_test_trap_assert_failed(); /* we have fatal-warnings enabled */
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
g_test_trap_assert_stderr ("*harmless warning*");
|
"*g_print*assertion*failed*");
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
|
||||||
{
|
|
||||||
g_print (NULL);
|
g_print (NULL);
|
||||||
exit (0);
|
g_test_assert_expected_messages ();
|
||||||
}
|
|
||||||
g_test_trap_assert_failed(); /* we have fatal-warnings enabled */
|
|
||||||
g_test_trap_assert_stderr ("*g_print*assertion*failed*");
|
|
||||||
g_test_trap_assert_stderr ("*NULL*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user