2010-04-19 17:31:21 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <locale.h>
|
|
|
|
#include <libintl.h>
|
2010-08-06 19:05:18 +02:00
|
|
|
#include <gio/gio.h>
|
2010-04-19 17:31:21 +02:00
|
|
|
#include <gstdio.h>
|
|
|
|
|
2010-04-21 06:43:55 +02:00
|
|
|
typedef struct {
|
|
|
|
const gchar *name;
|
2010-04-21 15:50:17 +02:00
|
|
|
const gchar *opt;
|
2010-04-25 16:26:41 +02:00
|
|
|
const gchar *err;
|
2010-04-21 06:43:55 +02:00
|
|
|
} SchemaTest;
|
2010-04-19 19:14:30 +02:00
|
|
|
|
2012-11-24 21:58:36 +01:00
|
|
|
static void
|
|
|
|
test_schema_do_compile (gpointer data)
|
|
|
|
{
|
|
|
|
SchemaTest *test = (SchemaTest *) data;
|
|
|
|
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
|
2013-05-29 14:49:16 +02:00
|
|
|
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
|
2012-11-24 21:58:36 +01:00
|
|
|
gchar *argv[] = {
|
2013-06-01 04:33:22 +02:00
|
|
|
"../glib-compile-schemas",
|
2012-11-24 21:58:36 +01:00
|
|
|
"--strict",
|
|
|
|
"--dry-run",
|
|
|
|
"--schema-file", path,
|
|
|
|
(gchar *)test->opt,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
gchar *envp[] = { NULL };
|
|
|
|
|
|
|
|
execve (argv[0], argv, envp);
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2010-04-19 19:14:30 +02:00
|
|
|
static void
|
2010-04-21 06:43:55 +02:00
|
|
|
test_schema (gpointer data)
|
2010-04-19 19:14:30 +02:00
|
|
|
{
|
2010-04-21 06:43:55 +02:00
|
|
|
SchemaTest *test = (SchemaTest *) data;
|
2012-11-24 21:58:36 +01:00
|
|
|
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);
|
2010-04-19 19:14:30 +02:00
|
|
|
|
2010-04-25 16:26:41 +02:00
|
|
|
if (test->err)
|
2010-04-21 15:50:17 +02:00
|
|
|
{
|
|
|
|
g_test_trap_assert_failed ();
|
2015-04-09 04:11:27 +02:00
|
|
|
g_test_trap_assert_stderr_unmatched ("*CRITICAL*");
|
|
|
|
g_test_trap_assert_stderr_unmatched ("*WARNING*");
|
2010-04-25 16:26:41 +02:00
|
|
|
g_test_trap_assert_stderr (test->err);
|
2010-04-21 15:50:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
g_test_trap_assert_passed();
|
2010-04-19 19:14:30 +02:00
|
|
|
}
|
|
|
|
|
2010-04-21 06:43:55 +02:00
|
|
|
static const SchemaTest tests[] = {
|
2010-04-26 03:07:26 +02:00
|
|
|
{ "no-default", NULL, "*<default> is required in <key>*" },
|
|
|
|
{ "missing-quotes", NULL, "*unknown keyword*" },
|
|
|
|
{ "incomplete-list", NULL, "*to follow array element*" },
|
2010-11-26 22:46:51 +01:00
|
|
|
{ "wrong-category", NULL, "*unsupported l10n category*" },
|
2010-04-26 03:07:26 +02:00
|
|
|
{ "bad-type", NULL, "*invalid GVariant type string*" },
|
|
|
|
{ "overflow", NULL, "*out of range*" },
|
|
|
|
{ "range-wrong-type", NULL, "*<range> not allowed for keys of type*" },
|
2011-03-31 11:41:30 +02:00
|
|
|
{ "range-missing-min", NULL, NULL },
|
|
|
|
{ "range-missing-max", NULL, NULL },
|
2010-04-26 03:07:26 +02:00
|
|
|
{ "default-out-of-range", NULL, "*<default> is not contained in the specified range*" },
|
|
|
|
{ "choices-wrong-type", NULL, "*<choices> not allowed for keys of type*" },
|
|
|
|
{ "choice-missing-value", NULL, "*element 'choice' requires attribute 'value'*" },
|
|
|
|
{ "default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
|
|
|
|
{ "array-default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
|
|
|
|
{ "bad-key", NULL, "*invalid name*" },
|
2010-06-07 10:18:43 +02:00
|
|
|
{ "invalid-path", NULL, "*must begin and end with a slash*" },
|
2010-04-26 03:07:26 +02:00
|
|
|
{ "bad-key", "--allow-any-name", NULL },
|
|
|
|
{ "bad-key2", NULL, "*invalid name*" },
|
|
|
|
{ "bad-key2", "--allow-any-name", NULL },
|
|
|
|
{ "bad-key3", NULL, "*invalid name*" },
|
|
|
|
{ "bad-key3", "--allow-any-name", NULL },
|
|
|
|
{ "bad-key4", NULL, "*invalid name*" },
|
|
|
|
{ "bad-key4", "--allow-any-name", NULL },
|
|
|
|
{ "empty-key", NULL, "*empty names*" },
|
2010-06-17 06:03:44 +02:00
|
|
|
{ "empty-key", "--allow-any-name", "*empty names*" },
|
|
|
|
{ "enum", NULL, NULL },
|
|
|
|
{ "enum-with-aliases", NULL, NULL },
|
|
|
|
{ "enum-with-invalid-alias", NULL, "*'banger' is not in enumerated type*" },
|
|
|
|
{ "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" },
|
2010-07-02 00:58:56 +02:00
|
|
|
{ "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" },
|
|
|
|
{ "enum-with-repeated-value", NULL, "*value='1' already specified*" },
|
2010-06-17 06:03:44 +02:00
|
|
|
{ "enum-with-chained-alias", NULL, "*'sausages' is not in enumerated type*" },
|
|
|
|
{ "enum-with-shadow-alias", NULL, "*'mash' is already a member of the enum*" },
|
2011-09-12 05:25:20 +02:00
|
|
|
{ "enum-with-choice", NULL, "*<choices> cannot be specified*" },
|
2010-06-17 06:03:44 +02:00
|
|
|
{ "enum-with-bad-default", NULL, "*<default> is not a valid member*" },
|
|
|
|
{ "choice", NULL, NULL },
|
|
|
|
{ "choice-upside-down", NULL, NULL },
|
|
|
|
{ "bad-choice", NULL, "*<default> contains string not in <choices>*" },
|
|
|
|
{ "choice-bad", NULL, "*<default> contains string not in <choices>*" },
|
|
|
|
{ "choice-badtype", NULL, "*<choices> not allowed for keys of type 'i'*" },
|
2010-07-02 00:58:56 +02:00
|
|
|
{ "bare-alias", NULL, "*enumerated or flags types or after <choices>*" },
|
2010-06-17 06:03:44 +02:00
|
|
|
{ "choice-alias", NULL, NULL },
|
|
|
|
{ "default-in-aliases", NULL, "*<default> contains string not in <choices>*" },
|
|
|
|
{ "choice-invalid-alias", NULL, "*'befor' is not in <choices>*" },
|
|
|
|
{ "choice-shadowed-alias", NULL, "*given when <choice value='before'/> was already*" },
|
|
|
|
{ "range", NULL, NULL },
|
|
|
|
{ "range-badtype", NULL, "*<range> not allowed for keys of type 's'*" },
|
|
|
|
{ "range-low-default", NULL, "*<default> is not contained in the specified range*" },
|
|
|
|
{ "range-high-default", NULL, "*<default> is not contained in the specified range*" },
|
|
|
|
{ "range-default-low", NULL, "*<default> is not contained in the specified range*" },
|
|
|
|
{ "range-default-high", NULL, "*<default> is not contained in the specified range*" },
|
2010-06-19 17:38:57 +02:00
|
|
|
{ "range-parse-error", NULL, "*invalid character in number*" },
|
2010-06-29 20:41:04 +02:00
|
|
|
{ "from-docs", NULL, NULL },
|
|
|
|
{ "extending", NULL, NULL },
|
Rework the build system for a new tests approach
Perform a substantial cleanup of the build system with respect to
building and installing testcases.
First, Makefile.decl has been renamed glib.mk and substantially
expanded. We intend to add more stuff here in the future, like canned
rules for mkenums, marshallers, resources, etc.
By default, tests are no longer compiled as part of 'make'. They will
be built when 'make check' is run. The old behaviour can be obtained
with --enable-always-build-tests.
--disable-modular-tests is gone (because tests are no longer built by
default). There is no longer any way to cause 'make check' to be a
no-op, but that's not very useful anyway.
A new glibtests.m4 file is introduced. Along with glib.mk, this
provides for consistent handling of --enable-installed-tests and
--enable-always-build-tests (mentioned above).
Port our various test-installing Makefiles to the new framework.
This patch substantially improves the situation in the toplevel tests/
directory. Things are now somewhat under control there. There were
some tests being built that weren't even being run and we run those now.
The long-running GObject performance tests in this directory have been
removed from 'make check' because they take too long.
As an experiment, 'make check' now runs the testcases on win32 builds,
by default. We can't run them under gtester (since it uses a pipe to
communicate with the subprocess) so just toss them in TESTS. Most of
them are passing on win32.
Things are not quite done here, but this patch is already a substantial
improvement. More to come.
2013-05-30 06:07:32 +02:00
|
|
|
{ "extend-missing", NULL, "*extends not yet existing schema*" },
|
2010-06-29 20:41:04 +02:00
|
|
|
{ "extend-nonlist", NULL, "*which is not a list*" },
|
Rework the build system for a new tests approach
Perform a substantial cleanup of the build system with respect to
building and installing testcases.
First, Makefile.decl has been renamed glib.mk and substantially
expanded. We intend to add more stuff here in the future, like canned
rules for mkenums, marshallers, resources, etc.
By default, tests are no longer compiled as part of 'make'. They will
be built when 'make check' is run. The old behaviour can be obtained
with --enable-always-build-tests.
--disable-modular-tests is gone (because tests are no longer built by
default). There is no longer any way to cause 'make check' to be a
no-op, but that's not very useful anyway.
A new glibtests.m4 file is introduced. Along with glib.mk, this
provides for consistent handling of --enable-installed-tests and
--enable-always-build-tests (mentioned above).
Port our various test-installing Makefiles to the new framework.
This patch substantially improves the situation in the toplevel tests/
directory. Things are now somewhat under control there. There were
some tests being built that weren't even being run and we run those now.
The long-running GObject performance tests in this directory have been
removed from 'make check' because they take too long.
As an experiment, 'make check' now runs the testcases on win32 builds,
by default. We can't run them under gtester (since it uses a pipe to
communicate with the subprocess) so just toss them in TESTS. Most of
them are passing on win32.
Things are not quite done here, but this patch is already a substantial
improvement. More to come.
2013-05-30 06:07:32 +02:00
|
|
|
{ "extend-self", NULL, "*not yet existing*" },
|
2010-06-29 20:41:04 +02:00
|
|
|
{ "extend-wrong-list-indirect", NULL, "*'y' does not extend 'x'*" },
|
|
|
|
{ "extend-wrong-list", NULL, "*'y' does not extend 'x'*" },
|
2011-09-12 05:25:20 +02:00
|
|
|
{ "key-in-list-indirect", NULL, "*cannot add keys to a 'list*" },
|
|
|
|
{ "key-in-list", NULL, "*cannot add keys to a 'list*" },
|
Rework the build system for a new tests approach
Perform a substantial cleanup of the build system with respect to
building and installing testcases.
First, Makefile.decl has been renamed glib.mk and substantially
expanded. We intend to add more stuff here in the future, like canned
rules for mkenums, marshallers, resources, etc.
By default, tests are no longer compiled as part of 'make'. They will
be built when 'make check' is run. The old behaviour can be obtained
with --enable-always-build-tests.
--disable-modular-tests is gone (because tests are no longer built by
default). There is no longer any way to cause 'make check' to be a
no-op, but that's not very useful anyway.
A new glibtests.m4 file is introduced. Along with glib.mk, this
provides for consistent handling of --enable-installed-tests and
--enable-always-build-tests (mentioned above).
Port our various test-installing Makefiles to the new framework.
This patch substantially improves the situation in the toplevel tests/
directory. Things are now somewhat under control there. There were
some tests being built that weren't even being run and we run those now.
The long-running GObject performance tests in this directory have been
removed from 'make check' because they take too long.
As an experiment, 'make check' now runs the testcases on win32 builds,
by default. We can't run them under gtester (since it uses a pipe to
communicate with the subprocess) so just toss them in TESTS. Most of
them are passing on win32.
Things are not quite done here, but this patch is already a substantial
improvement. More to come.
2013-05-30 06:07:32 +02:00
|
|
|
{ "list-of-missing", NULL, "*is list of not yet existing schema*" },
|
2010-06-30 02:24:39 +02:00
|
|
|
{ "extend-and-shadow", NULL, "*shadows*use <override>*" },
|
|
|
|
{ "extend-and-shadow-indirect", NULL, "*shadows*use <override>*" },
|
|
|
|
{ "override", NULL, NULL },
|
|
|
|
{ "override-missing", NULL, "*no <key name='bar'> to override*" },
|
|
|
|
{ "override-range-error", NULL, "*<override> is not contained in the specified range*"},
|
|
|
|
{ "override-then-key", NULL, "*shadows <key name='foo'> in <schema id='base'>*" },
|
|
|
|
{ "override-twice", NULL, "*<override name='foo'> already specified*" },
|
2010-07-02 00:58:56 +02:00
|
|
|
{ "override-type-error", NULL, "*invalid character in number*" },
|
|
|
|
{ "flags-aliased-default", NULL, "*<default> * not in the specified flags type*" },
|
|
|
|
{ "flags-bad-default", NULL, "*<default> * not in the specified flags type*" },
|
|
|
|
{ "flags-more-than-one-bit", NULL, "*flags values must have at most 1 bit set*" },
|
|
|
|
{ "flags-with-enum-attr", NULL, "*<enum id='flags'> not (yet) defined*" },
|
2010-11-26 21:05:20 +01:00
|
|
|
{ "flags-with-enum-tag", NULL, "*<flags id='flags'> not (yet) defined*" },
|
2015-04-02 00:55:54 +02:00
|
|
|
{ "summary-xmllang", NULL, "*Only one <summary> element allowed*" },
|
|
|
|
{ "description-xmllang", NULL, "*Only one <description> element allowed*" },
|
2015-04-09 04:11:27 +02:00
|
|
|
{ "summary-xmllang-and-attrs", NULL, "*attribute 'lang' invalid for element 'summary'*" },
|
2011-03-31 11:42:34 +02:00
|
|
|
{ "inherit-gettext-domain", NULL, NULL },
|
2011-11-07 06:14:28 +01:00
|
|
|
{ "range-type-test", NULL, NULL },
|
|
|
|
{ "cdata", NULL, NULL }
|
2010-04-21 06:43:55 +02:00
|
|
|
};
|
2010-04-19 17:31:21 +02:00
|
|
|
|
2010-11-26 21:05:20 +01:00
|
|
|
|
2010-04-19 17:31:21 +02:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2010-04-21 06:43:55 +02:00
|
|
|
guint i;
|
|
|
|
|
2010-04-19 17:31:21 +02:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
|
2010-04-21 06:43:55 +02:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (tests); ++i)
|
|
|
|
{
|
2012-11-24 21:58:36 +01:00
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
|
2010-04-21 06:43:55 +02:00
|
|
|
g_test_add_data_func (name, &tests[i], (gpointer) test_schema);
|
|
|
|
g_free (name);
|
2012-11-24 21:58:36 +01:00
|
|
|
|
|
|
|
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);
|
2010-04-21 06:43:55 +02:00
|
|
|
}
|
2010-04-19 17:31:21 +02:00
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
}
|