From cba18f8ac2265660764592ebfb1547d20720d4a5 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 15 Aug 2016 09:51:10 +0200 Subject: [PATCH] virschematest: Make sure that validator is initialized It may happen that a developer wants to run just a specific subset of tests: tests $ VIR_TEST_RANGE=22 ../run ./virschematest This now fails miserably: ==6840== Invalid read of size 8 ==6840== at 0x4F397C0: virXMLValidatorValidate (virxml.c:1216) ==6840== by 0x402B72: testSchemaFile (virschematest.c:53) ==6840== by 0x403737: virTestRun (testutils.c:180) ==6840== by 0x402CF5: testSchemaDir (virschematest.c:98) ==6840== by 0x402EB1: testSchemaDirs (virschematest.c:131) ==6840== by 0x40314D: mymain (virschematest.c:194) ==6840== by 0x4051AF: virTestMain (testutils.c:982) ==6840== by 0x4035A9: main (virschematest.c:217) ==6840== Address 0x10 is not stack'd, malloc'd or (recently) free'd Problem is, we are trying to do two types of tests here: validate RNG schema itself, and validate XML files against RNG schemas. And the latter tries to re-use a resource allocated in the former. Therefore if the former is skipped (due to VIR_TEST_RANGE) we have to allocate the resource manually. Signed-off-by: Michal Privoznik --- tests/virschematest.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/virschematest.c b/tests/virschematest.c index c9cc314c62..b31a5bca91 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -180,6 +180,12 @@ mymain(void) data.schema = sch; \ if (virTestRun("test schema grammar file: " sch, \ testSchemaGrammar, &data) == 0) { \ + /* initialize the validator even if the schema test \ + * was skipped because of VIR_TEST_RANGE */ \ + if (!data.validator && testSchemaGrammar(&data) < 0) { \ + ret = -1; \ + break; \ + } \ if (testSchemaDirs(sch, data.validator, __VA_ARGS__, NULL) < 0) \ ret = -1; \ \