15 test_schema (gpointer data)
17 SchemaTest *test = (SchemaTest *) data;
19 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
21 gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
22 gchar *path = g_build_filename (SRCDIR, "schema-tests", filename, NULL);
24 "../glib-compile-schemas",
26 "--schema-files", path,
30 gchar *envp[] = { NULL };
31 execve (argv[0], argv, envp);
37 g_test_trap_assert_failed ();
38 g_test_trap_assert_stderr (test->err);
41 g_test_trap_assert_passed();
44 static const SchemaTest tests[] = {
45 { "no-default", NULL, "*<default> is required in <key>*" },
46 { "missing-quotes", NULL, "*unknown keyword*" },
47 { "incomplete-list", NULL, "*to follow array element*" },
48 { "wrong-category", NULL, "*attribute 'l10n' invalid*" },
49 { "bad-type", NULL, "*invalid GVariant type string*" },
50 { "overflow", NULL, "*out of range*" },
51 { "range-wrong-type", NULL, "*<range> not allowed for keys of type*" },
52 { "range-missing-min", NULL, "*element 'range' requires attribute 'min'*" },
53 { "range-missing-max", NULL, "*element 'range' requires attribute 'max'*" },
54 { "default-out-of-range", NULL, "*<default> is not contained in the specified range*" },
55 { "choices-wrong-type", NULL, "*<choices> not allowed for keys of type*" },
56 { "choice-missing-value", NULL, "*element 'choice' requires attribute 'value'*" },
57 { "default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
58 { "array-default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
59 { "bad-key", NULL, "*invalid name*" },
60 { "bad-key", "--allow-any-name", NULL },
61 { "bad-key2", NULL, "*invalid name*" },
62 { "bad-key2", "--allow-any-name", NULL },
63 { "bad-key3", NULL, "*invalid name*" },
64 { "bad-key3", "--allow-any-name", NULL },
65 { "bad-key4", NULL, "*invalid name*" },
66 { "bad-key4", "--allow-any-name", NULL },
67 { "empty-key", NULL, "*empty names*" },
68 { "empty-key", "--allow-any-name", "*empty names*" }
72 main (int argc, char *argv[])
76 setlocale (LC_ALL, "");
79 g_test_init (&argc, &argv, NULL);
81 for (i = 0; i < G_N_ELEMENTS (tests); ++i)
83 gchar *name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
84 g_test_add_data_func (name, &tests[i], (gpointer) test_schema);