Revert "tests: port from g_test_trap_subprocess() to g_test_trap_fork()"

This reverts commit ea06ec8063.
This commit is contained in:
Matthias Clasen
2012-12-19 15:20:37 -05:00
parent 6f15db8c3d
commit 0178402c6d
19 changed files with 859 additions and 1250 deletions

View File

@@ -108,74 +108,14 @@ close_async_cb (GObject *source G_GNUC_UNUSED,
}
}
static void
test_exit_on_close_child (gconstpointer test_data)
{
const TestData *td = test_data;
GDBusConnection *c;
loop = g_main_loop_new (NULL, FALSE);
session_bus_up ();
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
g_assert (c != NULL);
/* the default is meant to be TRUE */
if (td->exit_on_close != IMPLICITLY_TRUE)
g_dbus_connection_set_exit_on_close (c, td->exit_on_close);
g_assert_cmpint (g_dbus_connection_get_exit_on_close (c), ==,
(td->exit_on_close != EXPLICITLY_FALSE));
g_assert (!g_dbus_connection_is_closed (c));
g_timeout_add (50, quit_later_cb, NULL);
g_main_loop_run (loop);
g_signal_connect (c, "closed", G_CALLBACK (closed_cb), (gpointer) td);
if (td->who_closes == LOCAL)
{
GVariant *v;
GError *error = NULL;
v = g_dbus_connection_call_sync (c, "org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"ListNames",
NULL,
G_VARIANT_TYPE ("(as)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
g_assert_no_error (error);
g_assert (v != NULL);
g_variant_unref (v);
g_dbus_connection_close (c, NULL, close_async_cb, NULL);
}
else
{
session_bus_stop ();
}
g_main_loop_run (loop);
/* this is only reached when we turn off exit-on-close */
g_main_loop_unref (loop);
g_object_unref (c);
session_bus_down ();
exit (0);
}
static void
test_exit_on_close (gconstpointer test_data)
{
const TestData *td = test_data;
GTestTrapFlags silence;
char *child_name;
/* all the tests rely on a shared main loop */
loop = g_main_loop_new (NULL, FALSE);
g_test_dbus_unset ();
@@ -184,9 +124,63 @@ test_exit_on_close (gconstpointer test_data)
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 (g_test_trap_fork (0, silence))
{
GDBusConnection *c;
session_bus_up ();
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
g_assert (c != NULL);
/* the default is meant to be TRUE */
if (td->exit_on_close != IMPLICITLY_TRUE)
g_dbus_connection_set_exit_on_close (c, td->exit_on_close);
g_assert_cmpint (g_dbus_connection_get_exit_on_close (c), ==,
(td->exit_on_close != EXPLICITLY_FALSE));
g_assert (!g_dbus_connection_is_closed (c));
g_timeout_add (50, quit_later_cb, NULL);
g_main_loop_run (loop);
g_signal_connect (c, "closed", G_CALLBACK (closed_cb), (gpointer) td);
if (td->who_closes == LOCAL)
{
GVariant *v;
GError *error = NULL;
v = g_dbus_connection_call_sync (c, "org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"ListNames",
NULL,
G_VARIANT_TYPE ("(as)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
g_assert_no_error (error);
g_assert (v != NULL);
g_variant_unref (v);
g_dbus_connection_close (c, NULL, close_async_cb, NULL);
}
else
{
session_bus_stop ();
}
g_main_loop_run (loop);
/* this is only reached when we turn off exit-on-close */
g_main_loop_unref (loop);
g_object_unref (c);
session_bus_down ();
exit (0);
}
if (td->exit_on_close == EXPLICITLY_FALSE ||
td->who_closes == LOCAL)
@@ -213,15 +207,10 @@ main (int argc,
for (i = 0; cases[i].name != NULL; i++)
{
gchar *name;
gchar *name = g_strdup_printf ("/gdbus/exit-on-close/%s", cases[i].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_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();

View File

@@ -137,7 +137,7 @@ test_non_socket (void)
pid_t first_child;
GVariant *ret;
const gchar *str;
gboolean ok, in_child;
gboolean ok;
error = NULL;
@@ -219,12 +219,7 @@ test_non_socket (void)
break;
}
/* 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)
if (!g_test_trap_fork (0, 0))
{
/* parent */
g_object_unref (streams[0]);

View File

@@ -620,10 +620,12 @@ test_expected_interface (GDBusProxy *proxy)
if (g_test_undefined ())
{
/* Also check that we complain if setting a cached property of the wrong type */
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_test_assert_expected_messages ();
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
{
g_dbus_proxy_set_cached_property (proxy, "y", g_variant_new_string ("error_me_out!"));
}
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) */
@@ -634,10 +636,12 @@ test_expected_interface (GDBusProxy *proxy)
/* 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)
*/
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");
g_test_assert_expected_messages ();
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
{
value = g_dbus_proxy_get_cached_property (proxy, "i");
}
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

View File

@@ -11,36 +11,28 @@ typedef struct {
const gchar *err;
} SchemaTest;
static void
test_schema_do_compile (gpointer data)
{
SchemaTest *test = (SchemaTest *) data;
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
gchar *path = g_build_filename (SRCDIR, "schema-tests", filename, NULL);
gchar *argv[] = {
"../glib-compile-schemas",
"--strict",
"--dry-run",
"--schema-file", path,
(gchar *)test->opt,
NULL
};
gchar *envp[] = { NULL };
execve (argv[0], argv, envp);
g_assert_not_reached ();
}
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 (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
gchar *path = g_build_filename (SRCDIR, "schema-tests", filename, NULL);
gchar *argv[] = {
"../glib-compile-schemas",
"--strict",
"--dry-run",
"--schema-file", path,
(gchar *)test->opt,
NULL
};
gchar *envp[] = { NULL };
execve (argv[0], argv, envp);
g_free (filename);
g_free (path);
}
if (test->err)
{
g_test_trap_assert_failed ();
@@ -143,15 +135,9 @@ main (int argc, char *argv[])
for (i = 0; i < G_N_ELEMENTS (tests); ++i)
{
gchar *name;
name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
gchar *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_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 ();

View File

@@ -82,28 +82,24 @@ test_basic (void)
/* Check that we get an error when getting a key
* that is not in the schema
*/
static void
test_unknown_key_child (void)
{
GSettings *settings;
GVariant *value;
settings = g_settings_new ("org.gtk.test");
value = g_settings_get_value (settings, "no_such_key");
g_assert (value == NULL);
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);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings;
GVariant *value;
settings = g_settings_new ("org.gtk.test");
value = g_settings_get_value (settings, "no_such_key");
g_assert (value == NULL);
g_object_unref (settings);
}
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*does not contain*");
}
@@ -111,24 +107,21 @@ test_unknown_key (void)
/* Check that we get an error when the schema
* has not been installed
*/
static void
test_no_schema_child (void)
{
GSettings *settings;
settings = g_settings_new ("no.such.schema");
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);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings;
settings = g_settings_new ("no.such.schema");
g_assert (settings == NULL);
}
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*Settings schema 'no.such.schema' is not installed*");
}
@@ -165,42 +158,36 @@ test_wrong_type (void)
}
/* Check errors with explicit paths */
static void
test_wrong_path_child (void)
{
GSettings *settings G_GNUC_UNUSED;
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);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings G_GNUC_UNUSED;
settings = g_settings_new_with_path ("org.gtk.test", "/wrong-path/");
}
g_test_trap_assert_failed ();
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
test_no_path (void)
{
if (!g_test_undefined ())
return;
g_test_trap_subprocess ("/gsettings/no-path:child",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (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_stderr ("*attempting to create schema * without a path**");
}
@@ -1311,29 +1298,25 @@ test_directional_binding (void)
/* Test that type mismatch is caught when creating a binding
*/
static void
test_typesafe_binding_child (void)
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "int", G_SETTINGS_BIND_DEFAULT);
g_object_unref (obj);
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);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "int", G_SETTINGS_BIND_DEFAULT);
g_object_unref (obj);
g_object_unref (settings);
}
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*not compatible*");
}
@@ -1441,88 +1424,74 @@ test_no_change_binding (void)
/* Test that binding a non-readable property only
* works in 'GET' mode.
*/
static void
test_no_read_binding_fail (void)
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-read", 0);
}
static void
test_no_read_binding_pass (void)
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-read", G_SETTINGS_BIND_GET);
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);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-read", 0);
}
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);
if (g_test_trap_fork (0, 0))
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-read", G_SETTINGS_BIND_GET);
exit (0);
}
g_test_trap_assert_passed ();
}
/* Test that binding a non-writable property only
* works in 'SET' mode.
*/
static void
test_no_write_binding_fail (void)
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-write", 0);
}
static void
test_no_write_binding_pass (void)
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-write", G_SETTINGS_BIND_SET);
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);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-write", 0);
}
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);
if (g_test_trap_fork (0, 0))
{
TestObject *obj;
GSettings *settings;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_settings_bind (settings, "string", obj, "no-write", G_SETTINGS_BIND_SET);
exit (0);
}
g_test_trap_assert_passed ();
}
@@ -1661,46 +1630,6 @@ test_strinfo (void)
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
test_enums (void)
{
@@ -1712,23 +1641,23 @@ test_enums (void)
if (g_test_undefined () && !backend_set)
{
g_test_trap_subprocess ("/gsettings/enums:non-enum-key",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_get_enum (direct, "test");
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*not associated with an enum*");
g_test_trap_subprocess ("/gsettings/enums:non-enum-value",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_enum (settings, "test", 42);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*invalid enum value 42*");
g_test_trap_subprocess ("/gsettings/enums:range",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_string (settings, "test", "qux");
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
g_test_trap_subprocess ("/gsettings/enums:non-flags",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_get_flags (settings, "test");
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*not associated with a flags*");
}
@@ -1758,47 +1687,6 @@ test_enums (void)
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
test_flags (void)
{
@@ -1811,23 +1699,24 @@ test_flags (void)
if (g_test_undefined () && !backend_set)
{
g_test_trap_subprocess ("/gsettings/flags:non-flags-key",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_get_flags (direct, "test");
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*not associated with a flags*");
g_test_trap_subprocess ("/gsettings/flags:non-flags-value",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_flags (settings, "f-test", 0x42);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*invalid flags value 0x00000042*");
g_test_trap_subprocess ("/gsettings/flags:range",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_strv (settings, "f-test",
(const gchar **) g_strsplit ("rock", ",", 0));
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
g_test_trap_subprocess ("/gsettings/flags:non-enum",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_get_enum (settings, "f-test");
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*not associated with an enum*");
}
@@ -1870,26 +1759,6 @@ test_flags (void)
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
test_range (void)
{
@@ -1901,13 +1770,13 @@ test_range (void)
if (g_test_undefined () && !backend_set)
{
g_test_trap_subprocess ("/gsettings/range:high",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_int (settings, "val", 45);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
g_test_trap_subprocess ("/gsettings/range:low",
0, G_TEST_TRAP_SILENCE_STDERR);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_int (settings, "val", 1);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*g_settings_set_value*valid range*");
}
@@ -2264,55 +2133,48 @@ main (int argc, char *argv[])
setlocale (LC_ALL, "");
backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL;
g_setenv ("XDG_DATA_DIRS", ".", TRUE);
g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE);
if (!backend_set)
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
g_test_init (&argc, &argv, NULL);
if (!g_test_subprocess ())
{
backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL;
g_remove ("org.gtk.test.enums.xml");
g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums "
"--template " SRCDIR "/enums.xml.template "
SRCDIR "/testenum.h",
&enums, NULL, &result, NULL));
g_assert (result == 0);
g_assert (g_file_set_contents ("org.gtk.test.enums.xml", enums, -1, NULL));
g_free (enums);
g_setenv ("XDG_DATA_DIRS", ".", TRUE);
g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE);
g_remove ("gschemas.compiled");
g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=. "
"--schema-file=org.gtk.test.enums.xml "
"--schema-file=" SRCDIR "/org.gtk.test.gschema.xml",
NULL, NULL, &result, NULL));
g_assert (result == 0);
if (!backend_set)
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
g_remove ("org.gtk.test.enums.xml");
g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums "
"--template " SRCDIR "/enums.xml.template "
SRCDIR "/testenum.h",
&enums, NULL, &result, NULL));
g_assert (result == 0);
g_assert (g_file_set_contents ("org.gtk.test.enums.xml", enums, -1, NULL));
g_free (enums);
g_remove ("gschemas.compiled");
g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=. "
"--schema-file=org.gtk.test.enums.xml "
"--schema-file=" SRCDIR "/org.gtk.test.gschema.xml",
NULL, NULL, &result, NULL));
g_assert (result == 0);
g_remove ("schema-source/gschemas.compiled");
g_mkdir ("schema-source", 0777);
g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=schema-source "
"--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
NULL, NULL, &result, NULL));
g_assert (result == 0);
}
g_remove ("schema-source/gschemas.compiled");
g_mkdir ("schema-source", 0777);
g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=schema-source "
"--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
NULL, NULL, &result, NULL));
g_assert (result == 0);
g_test_add_func ("/gsettings/basic", test_basic);
if (!backend_set)
{
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:child", test_unknown_key_child);
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:child", test_wrong_path_child);
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);
@@ -2339,31 +2201,16 @@ main (int argc, char *argv[])
if (!backend_set)
{
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: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: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/child-schema", test_child_schema);
g_test_add_func ("/gsettings/strinfo", test_strinfo);
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: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: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-schemas", test_list_schemas);
g_test_add_func ("/gsettings/mapped", test_get_mapped);