MCPcopy Create free account
hub / github.com/Kitware/VTK / xsdIncorrectTestCase

Function xsdIncorrectTestCase

ThirdParty/libxml2/vtklibxml2/runsuite.c:290–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288 ************************************************************************/
289
290static int
291xsdIncorrectTestCase(xmlNodePtr cur) {
292 xmlNodePtr test;
293 xmlBufferPtr buf;
294 xmlRelaxNGParserCtxtPtr pctxt;
295 xmlRelaxNGPtr rng = NULL;
296 int ret = 0, memt;
297
298 cur = getNext(cur, "./incorrect[1]");
299 if (cur == NULL) {
300 return(0);
301 }
302
303 test = getNext(cur, "./*");
304 if (test == NULL) {
305 test_log("Failed to find test in correct line %ld\n",
306 xmlGetLineNo(cur));
307 return(1);
308 }
309
310 memt = xmlMemUsed();
311 extraMemoryFromResolver = 0;
312 /*
313 * dump the schemas to a buffer, then reparse it and compile the schemas
314 */
315 buf = xmlBufferCreate();
316 if (buf == NULL) {
317 fprintf(stderr, "out of memory !\n");
318 fatalError();
319 }
320 xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
321 xmlNodeDump(buf, test->doc, test, 0, 0);
322 pctxt = xmlRelaxNGNewMemParserCtxt((const char *)buf->content, buf->use);
323 xmlRelaxNGSetParserErrors(pctxt, testErrorHandler, testErrorHandler,
324 pctxt);
325 rng = xmlRelaxNGParse(pctxt);
326 xmlRelaxNGFreeParserCtxt(pctxt);
327 if (rng != NULL) {
328 test_log("Failed to detect incorrect RNG line %ld\n",
329 xmlGetLineNo(test));
330 ret = 1;
331 goto done;
332 }
333
334done:
335 if (buf != NULL)
336 xmlBufferFree(buf);
337 if (rng != NULL)
338 xmlRelaxNGFree(rng);
339 xmlResetLastError();
340 if ((memt < xmlMemUsed()) && (extraMemoryFromResolver == 0)) {
341 test_log("Validation of tests starting line %ld leaked %d\n",
342 xmlGetLineNo(cur), xmlMemUsed() - memt);
343 nb_leaks++;
344 }
345 return(ret);
346}
347

Callers 1

xsdTestCaseFunction · 0.85

Calls 15

getNextFunction · 0.85
xmlGetLineNoFunction · 0.85
xmlMemUsedFunction · 0.85
xmlBufferCreateFunction · 0.85
fprintfFunction · 0.85
xmlNodeDumpFunction · 0.85
xmlRelaxNGParseFunction · 0.85
xmlRelaxNGFreeParserCtxtFunction · 0.85
xmlBufferFreeFunction · 0.85

Tested by

no test coverage detected