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",
27 "--schema-file", path,
31 gchar *envp[] = { NULL };
32 execve (argv[0], argv, envp);
38 g_test_trap_assert_failed ();
39 g_test_trap_assert_stderr (test->err);
42 g_test_trap_assert_passed();
45 static const SchemaTest tests[] = {
46 { "no-default", NULL, "*<default> is required in <key>*" },
47 { "missing-quotes", NULL, "*unknown keyword*" },
48 { "incomplete-list", NULL, "*to follow array element*" },
49 { "wrong-category", NULL, "*unsupported l10n category*" },
50 { "bad-type", NULL, "*invalid GVariant type string*" },
51 { "overflow", NULL, "*out of range*" },
52 { "range-wrong-type", NULL, "*<range> not allowed for keys of type*" },
53 { "range-missing-min", NULL, NULL },
54 { "range-missing-max", NULL, NULL },
55 { "default-out-of-range", NULL, "*<default> is not contained in the specified range*" },
56 { "choices-wrong-type", NULL, "*<choices> not allowed for keys of type*" },
57 { "choice-missing-value", NULL, "*element 'choice' requires attribute 'value'*" },
58 { "default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
59 { "array-default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
60 { "bad-key", NULL, "*invalid name*" },
61 { "invalid-path", NULL, "*must begin and end with a slash*" },
62 { "bad-key", "--allow-any-name", NULL },
63 { "bad-key2", NULL, "*invalid name*" },
64 { "bad-key2", "--allow-any-name", NULL },
65 { "bad-key3", NULL, "*invalid name*" },
66 { "bad-key3", "--allow-any-name", NULL },
67 { "bad-key4", NULL, "*invalid name*" },
68 { "bad-key4", "--allow-any-name", NULL },
69 { "empty-key", NULL, "*empty names*" },
70 { "empty-key", "--allow-any-name", "*empty names*" },
71 { "enum", NULL, NULL },
72 { "enum-with-aliases", NULL, NULL },
73 { "enum-with-invalid-alias", NULL, "*'banger' is not in enumerated type*" },
74 { "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" },
75 { "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" },
76 { "enum-with-repeated-value", NULL, "*value='1' already specified*" },
77 { "enum-with-chained-alias", NULL, "*'sausages' is not in enumerated type*" },
78 { "enum-with-shadow-alias", NULL, "*'mash' is already a member of the enum*" },
79 { "enum-with-choice", NULL, "*<choices> cannot be specified*" },
80 { "enum-with-bad-default", NULL, "*<default> is not a valid member*" },
81 { "choice", NULL, NULL },
82 { "choice-upside-down", NULL, NULL },
83 { "bad-choice", NULL, "*<default> contains string not in <choices>*" },
84 { "choice-bad", NULL, "*<default> contains string not in <choices>*" },
85 { "choice-badtype", NULL, "*<choices> not allowed for keys of type 'i'*" },
86 { "bare-alias", NULL, "*enumerated or flags types or after <choices>*" },
87 { "choice-alias", NULL, NULL },
88 { "default-in-aliases", NULL, "*<default> contains string not in <choices>*" },
89 { "choice-invalid-alias", NULL, "*'befor' is not in <choices>*" },
90 { "choice-shadowed-alias", NULL, "*given when <choice value='before'/> was already*" },
91 { "range", NULL, NULL },
92 { "range-badtype", NULL, "*<range> not allowed for keys of type 's'*" },
93 { "range-low-default", NULL, "*<default> is not contained in the specified range*" },
94 { "range-high-default", NULL, "*<default> is not contained in the specified range*" },
95 { "range-default-low", NULL, "*<default> is not contained in the specified range*" },
96 { "range-default-high", NULL, "*<default> is not contained in the specified range*" },
97 { "range-parse-error", NULL, "*invalid character in number*" },
98 { "from-docs", NULL, NULL },
99 { "extending", NULL, NULL },
100 { "extend-missing", NULL, "*extends not-yet-existing schema*" },
101 { "extend-nonlist", NULL, "*which is not a list*" },
102 { "extend-self", NULL, "*not-yet-existing*" },
103 { "extend-wrong-list-indirect", NULL, "*'y' does not extend 'x'*" },
104 { "extend-wrong-list", NULL, "*'y' does not extend 'x'*" },
105 { "key-in-list-indirect", NULL, "*cannot add keys to a 'list*" },
106 { "key-in-list", NULL, "*cannot add keys to a 'list*" },
107 { "list-of-missing", NULL, "*is list of not-yet-existing schema*" },
108 { "extend-and-shadow", NULL, "*shadows*use <override>*" },
109 { "extend-and-shadow-indirect", NULL, "*shadows*use <override>*" },
110 { "override", NULL, NULL },
111 { "override-missing", NULL, "*no <key name='bar'> to override*" },
112 { "override-range-error", NULL, "*<override> is not contained in the specified range*"},
113 { "override-then-key", NULL, "*shadows <key name='foo'> in <schema id='base'>*" },
114 { "override-twice", NULL, "*<override name='foo'> already specified*" },
115 { "override-type-error", NULL, "*invalid character in number*" },
116 { "flags-aliased-default", NULL, "*<default> * not in the specified flags type*" },
117 { "flags-bad-default", NULL, "*<default> * not in the specified flags type*" },
118 { "flags-more-than-one-bit", NULL, "*flags values must have at most 1 bit set*" },
119 { "flags-with-enum-attr", NULL, "*<enum id='flags'> not (yet) defined*" },
120 { "flags-with-enum-tag", NULL, "*<flags id='flags'> not (yet) defined*" },
121 { "inherit-gettext-domain", NULL, NULL },
122 { "range-type-test", NULL, NULL },
123 { "cdata", NULL, NULL }
128 main (int argc, char *argv[])
132 setlocale (LC_ALL, "");
134 g_test_init (&argc, &argv, NULL);
136 for (i = 0; i < G_N_ELEMENTS (tests); ++i)
138 gchar *name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
139 g_test_add_data_func (name, &tests[i], (gpointer) test_schema);
143 return g_test_run ();