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

Function errParseTest

ThirdParty/libxml2/vtklibxml2/runtest.c:2179–2252  ·  view source on GitHub ↗

* errParseTest: * @filename: the file to parse * @result: the file with expected result * @err: the file with error messages * * Parse a file using the xmlReadFile API and check for errors. * * Returns 0 in case of success, an error code otherwise */

Source from the content-addressed store, hash-verified

2177 * Returns 0 in case of success, an error code otherwise
2178 */
2179static int
2180errParseTest(const char *filename, const char *result, const char *err,
2181 int options) {
2182 xmlParserCtxtPtr ctxt;
2183 xmlDocPtr doc;
2184 const char *base = NULL;
2185 int size, res = 0;
2186
2187 nb_tests++;
2188#ifdef LIBXML_HTML_ENABLED
2189 if (options & XML_PARSE_HTML) {
2190 ctxt = htmlNewParserCtxt();
2191 xmlCtxtSetErrorHandler(ctxt, testStructuredErrorHandler, NULL);
2192 doc = htmlCtxtReadFile(ctxt, filename, NULL, options);
2193 htmlFreeParserCtxt(ctxt);
2194 } else
2195#endif
2196 {
2197 ctxt = xmlNewParserCtxt();
2198 xmlCtxtSetErrorHandler(ctxt, testStructuredErrorHandler, NULL);
2199 doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
2200 xmlFreeParserCtxt(ctxt);
2201#ifdef LIBXML_XINCLUDE_ENABLED
2202 if (options & XML_PARSE_XINCLUDE) {
2203 xmlXIncludeCtxtPtr xinc = NULL;
2204
2205 xinc = xmlXIncludeNewContext(doc);
2206 xmlXIncludeSetErrorHandler(xinc, testStructuredErrorHandler, NULL);
2207 xmlXIncludeSetFlags(xinc, options);
2208 if (xmlXIncludeProcessNode(xinc, (xmlNodePtr) doc) < 0) {
2209 testErrorHandler(NULL, "%s : failed to parse\n", filename);
2210 xmlFreeDoc(doc);
2211 doc = NULL;
2212 }
2213 xmlXIncludeFreeContext(xinc);
2214 }
2215#endif
2216 }
2217 if (result) {
2218 if (doc == NULL) {
2219 base = "";
2220 size = 0;
2221 } else {
2222#ifdef LIBXML_HTML_ENABLED
2223 if (options & XML_PARSE_HTML) {
2224 htmlDocDumpMemory(doc, (xmlChar **) &base, &size);
2225 } else
2226#endif
2227 xmlDocDumpMemory(doc, (xmlChar **) &base, &size);
2228 }
2229 res = compareFileMem(result, base, size);
2230 }
2231 if (doc != NULL) {
2232 if (base != NULL)
2233 xmlFree((char *)base);
2234 xmlFreeDoc(doc);
2235 }
2236 if (res != 0) {

Callers

nothing calls this directly

Calls 15

htmlNewParserCtxtFunction · 0.85
xmlCtxtSetErrorHandlerFunction · 0.85
htmlCtxtReadFileFunction · 0.85
htmlFreeParserCtxtFunction · 0.85
xmlNewParserCtxtFunction · 0.85
xmlCtxtReadFileFunction · 0.85
xmlFreeParserCtxtFunction · 0.85
xmlXIncludeNewContextFunction · 0.85
xmlXIncludeSetFlagsFunction · 0.85
xmlXIncludeProcessNodeFunction · 0.85
xmlFreeDocFunction · 0.85

Tested by

no test coverage detected