Failure to parse the schema file would not trigger a test suite failure.
In addition to making the test fail it's necessary to split up the
parsing of the schema file into a separate test.
This is necessary as the XML validator uses libvirt errors to report
problems parsing of the actual schema RNG needs to be split out into a
separate function and called via virTestRun which has the
infrastructure to report them.
---
tests/virschematest.c | 64 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 46 insertions(+), 18 deletions(-)
diff --git a/tests/virschematest.c b/tests/virschematest.c
index a1901e7..dbd9f3b 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -114,24 +114,17 @@ testSchemaDir(const char *schema,
static int
-testSchemaDirs(const char *schema, ...)
+testSchemaDirs(const char *schema, virXMLValidatorPtr validator, ...)
{
- virXMLValidatorPtr validator = NULL;
va_list args;
int ret = 0;
- char *schema_path = NULL;
char *dir_path = NULL;
const char *dir;
- va_start(args, schema);
-
- if (virAsprintf(&schema_path, "%s/docs/schemas/%s", abs_topsrcdir,
schema) < 0)
- goto cleanup;
-
- if (!(validator = virXMLValidatorInit(schema_path)))
- goto cleanup;
+ va_start(args, validator);
while ((dir = va_arg(args, char *))) {
+ printf("\nDERP: %s\n", dir);
if (virAsprintf(&dir_path, "%s/%s", abs_srcdir, dir) < 0) {
ret = -1;
goto cleanup;
@@ -142,24 +135,59 @@ testSchemaDirs(const char *schema, ...)
}
cleanup:
- virXMLValidatorFree(validator);
- VIR_FREE(schema_path);
VIR_FREE(dir_path);
va_end(args);
return ret;
}
+struct testSchemaFileData {
+ virXMLValidatorPtr validator;
+ const char *schema;
+};
+
+static int
+testSchemaGrammar(const void *opaque)
+{
+ struct testSchemaFileData *data = (struct testSchemaFileData *) opaque;
+ char *schema_path;
+ int ret = -1;
+
+ if (virAsprintf(&schema_path, "%s/docs/schemas/%s",
+ abs_topsrcdir, data->schema) < 0)
+ return -1;
+
+ if (!(data->validator = virXMLValidatorInit(schema_path)))
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(schema_path);
+ return ret;
+}
+
+
static int
mymain(void)
{
int ret = 0;
-
-#define DO_TEST(schema, ...) \
- do { \
- if (testSchemaDirs(schema, __VA_ARGS__, NULL) < 0) \
- ret = -1; \
- } while (0) \
+ struct testSchemaFileData data;
+
+#define DO_TEST(sch, ...) \
+ do { \
+ data.schema = sch; \
+ if (virTestRun("test schema grammar file: " sch,
\
+ testSchemaGrammar, &data) == 0) { \
+ if (testSchemaDirs(sch, data.validator, __VA_ARGS__, NULL) < 0) \
+ ret = -1; \
+ \
+ virXMLValidatorFree(data.validator); \
+ data.validator = NULL; \
+ } else { \
+ ret = -1; \
+ } \
+ } while (0)
DO_TEST("capability.rng", "capabilityschemadata",
"xencapsdata");
DO_TEST("domain.rng", "domainschemadata",
"qemuargv2xmldata",
--
2.9.2