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

Function xmlidDocTest

ThirdParty/libxml2/vtklibxml2/runtest.c:2780–2838  ·  view source on GitHub ↗

* xmlidDocTest: * @filename: the file to parse * @result: the file with expected result * @err: the file with error messages * * Parse a file containing xml:id and check for errors and verify * that XPath queries will work on them as expected. * * Returns 0 in case of success, an error code otherwise */

Source from the content-addressed store, hash-verified

2778 * Returns 0 in case of success, an error code otherwise
2779 */
2780static int
2781xmlidDocTest(const char *filename,
2782 const char *result,
2783 const char *err,
2784 int options) {
2785 xmlParserCtxtPtr ctxt;
2786 int res = 0;
2787 int ret = 0;
2788 char *temp;
2789
2790 ctxt = xmlNewParserCtxt();
2791 xmlCtxtSetErrorHandler(ctxt, testStructuredErrorHandler, NULL);
2792 xpathDocument = xmlCtxtReadFile(ctxt, filename, NULL,
2793 options | XML_PARSE_DTDATTR | XML_PARSE_NOENT);
2794 xmlFreeParserCtxt(ctxt);
2795 if (xpathDocument == NULL) {
2796 fprintf(stderr, "Failed to load %s\n", filename);
2797 return(-1);
2798 }
2799
2800 temp = resultFilename(filename, temp_directory, ".res");
2801 if (temp == NULL) {
2802 fprintf(stderr, "Out of memory\n");
2803 fatalError();
2804 }
2805 xpathOutput = fopen(temp, "wb");
2806 if (xpathOutput == NULL) {
2807 fprintf(stderr, "failed to open output file %s\n", temp);
2808 xmlFreeDoc(xpathDocument);
2809 free(temp);
2810 return(-1);
2811 }
2812
2813 testXPath("id('bar')", 0, 0);
2814
2815 fclose(xpathOutput);
2816 if (result != NULL) {
2817 ret = compareFiles(temp, result);
2818 if (ret) {
2819 fprintf(stderr, "Result for %s failed in %s\n", filename, result);
2820 res = 1;
2821 }
2822 }
2823
2824 if (temp != NULL) {
2825 unlink(temp);
2826 free(temp);
2827 }
2828 xmlFreeDoc(xpathDocument);
2829
2830 if (err != NULL) {
2831 ret = compareFileMem(err, testErrors, testErrorsSize);
2832 if (ret != 0) {
2833 fprintf(stderr, "Error for %s failed\n", filename);
2834 res = 1;
2835 }
2836 }
2837 return(res);

Callers

nothing calls this directly

Calls 10

xmlNewParserCtxtFunction · 0.85
xmlCtxtSetErrorHandlerFunction · 0.85
xmlCtxtReadFileFunction · 0.85
xmlFreeParserCtxtFunction · 0.85
fprintfFunction · 0.85
resultFilenameFunction · 0.85
xmlFreeDocFunction · 0.85
compareFileMemFunction · 0.85
fatalErrorFunction · 0.70
compareFilesFunction · 0.70

Tested by

no test coverage detected