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

Function xstcTestInstance

ThirdParty/libxml2/vtklibxml2/runsuite.c:760–853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758 ************************************************************************/
759
760static int
761xstcTestInstance(xmlNodePtr cur, xmlSchemaPtr schemas,
762 const xmlChar *spath, const char *base) {
763 xmlChar *href = NULL;
764 xmlChar *path = NULL;
765 xmlChar *validity = NULL;
766 xmlSchemaValidCtxtPtr ctxt = NULL;
767 xmlDocPtr doc = NULL;
768 int ret = 0, mem;
769
770 xmlResetLastError();
771 testErrorsSize = 0; testErrors[0] = 0;
772 mem = xmlMemUsed();
773 href = getString(cur,
774 "string(ts:instanceDocument/@xlink:href)");
775 if ((href == NULL) || (href[0] == 0)) {
776 test_log("testGroup line %ld misses href for schemaDocument\n",
777 xmlGetLineNo(cur));
778 ret = -1;
779 goto done;
780 }
781 path = xmlBuildURI(href, BAD_CAST base);
782 if (path == NULL) {
783 fprintf(stderr,
784 "Failed to build path to schemas testGroup line %ld : %s\n",
785 xmlGetLineNo(cur), href);
786 ret = -1;
787 goto done;
788 }
789 if (checkTestFile((const char *) path) <= 0) {
790 test_log("schemas for testGroup line %ld is missing: %s\n",
791 xmlGetLineNo(cur), path);
792 ret = -1;
793 goto done;
794 }
795 validity = getString(cur,
796 "string(ts:expected/@validity)");
797 if (validity == NULL) {
798 fprintf(stderr, "instanceDocument line %ld misses expected validity\n",
799 xmlGetLineNo(cur));
800 ret = -1;
801 goto done;
802 }
803 nb_tests++;
804 doc = xmlReadFile((const char *) path, NULL, XML_PARSE_NOENT);
805 if (doc == NULL) {
806 fprintf(stderr, "instance %s fails to parse\n", path);
807 ret = -1;
808 nb_errors++;
809 goto done;
810 }
811
812 ctxt = xmlSchemaNewValidCtxt(schemas);
813 xmlSchemaSetValidErrors(ctxt, testErrorHandler, testErrorHandler, ctxt);
814 ret = xmlSchemaValidateDoc(ctxt, doc);
815
816 if (xmlStrEqual(validity, BAD_CAST "valid")) {
817 if (ret > 0) {

Callers 1

xstcTestGroupFunction · 0.85

Calls 15

xmlResetLastErrorFunction · 0.85
xmlMemUsedFunction · 0.85
xmlGetLineNoFunction · 0.85
xmlBuildURIFunction · 0.85
fprintfFunction · 0.85
xmlReadFileFunction · 0.85
xmlSchemaNewValidCtxtFunction · 0.85
xmlSchemaSetValidErrorsFunction · 0.85
xmlSchemaValidateDocFunction · 0.85
xmlStrEqualFunction · 0.85
xmlSchemaFreeValidCtxtFunction · 0.85
xmlFreeDocFunction · 0.85

Tested by

no test coverage detected