| 408 | } |
| 409 | |
| 410 | static int |
| 411 | xsdTestCase(xmlNodePtr tst) { |
| 412 | xmlNodePtr test, tmp, cur; |
| 413 | xmlBufferPtr buf; |
| 414 | xmlDocPtr doc = NULL; |
| 415 | xmlRelaxNGParserCtxtPtr pctxt; |
| 416 | xmlRelaxNGValidCtxtPtr ctxt; |
| 417 | xmlRelaxNGPtr rng = NULL; |
| 418 | int ret = 0, mem, memt; |
| 419 | xmlChar *dtd; |
| 420 | |
| 421 | resetEntities(); |
| 422 | testErrorsSize = 0; testErrors[0] = 0; |
| 423 | |
| 424 | tmp = getNext(tst, "./dir[1]"); |
| 425 | if (tmp != NULL) { |
| 426 | installDirs(tmp, NULL); |
| 427 | } |
| 428 | tmp = getNext(tst, "./resource[1]"); |
| 429 | if (tmp != NULL) { |
| 430 | installResources(tmp, NULL); |
| 431 | } |
| 432 | |
| 433 | cur = getNext(tst, "./correct[1]"); |
| 434 | if (cur == NULL) { |
| 435 | return(xsdIncorrectTestCase(tst)); |
| 436 | } |
| 437 | |
| 438 | test = getNext(cur, "./*"); |
| 439 | if (test == NULL) { |
| 440 | fprintf(stderr, "Failed to find test in correct line %ld\n", |
| 441 | xmlGetLineNo(cur)); |
| 442 | return(1); |
| 443 | } |
| 444 | |
| 445 | memt = xmlMemUsed(); |
| 446 | extraMemoryFromResolver = 0; |
| 447 | /* |
| 448 | * dump the schemas to a buffer, then reparse it and compile the schemas |
| 449 | */ |
| 450 | buf = xmlBufferCreate(); |
| 451 | if (buf == NULL) { |
| 452 | fprintf(stderr, "out of memory !\n"); |
| 453 | fatalError(); |
| 454 | } |
| 455 | xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT); |
| 456 | xmlNodeDump(buf, test->doc, test, 0, 0); |
| 457 | pctxt = xmlRelaxNGNewMemParserCtxt((const char *)buf->content, buf->use); |
| 458 | xmlRelaxNGSetParserErrors(pctxt, testErrorHandler, testErrorHandler, |
| 459 | pctxt); |
| 460 | rng = xmlRelaxNGParse(pctxt); |
| 461 | xmlRelaxNGFreeParserCtxt(pctxt); |
| 462 | if (extraMemoryFromResolver) |
| 463 | memt = 0; |
| 464 | |
| 465 | if (rng == NULL) { |
| 466 | test_log("Failed to parse RNGtest line %ld\n", |
| 467 | xmlGetLineNo(test)); |
no test coverage detected