mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
tests: port from g_test_trap_subprocess() to g_test_trap_fork()
https://bugzilla.gnome.org/show_bug.cgi?id=679683
This commit is contained in:
@@ -11,28 +11,36 @@ 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/subprocess/do_compile", test->name, test->opt ? "/opt" : "");
|
||||
g_test_trap_subprocess (child_name, 0, 0);
|
||||
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 ();
|
||||
@@ -135,9 +143,15 @@ main (int argc, char *argv[])
|
||||
|
||||
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_free (name);
|
||||
|
||||
name = g_strdup_printf ("/gschema/%s%s/subprocess/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 ();
|
||||
|
Reference in New Issue
Block a user