| 288 | ************************************************************************/ |
| 289 | |
| 290 | static int |
| 291 | xsdIncorrectTestCase(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 | |
| 334 | done: |
| 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 |
no test coverage detected