* xpathDocTest: * @filename: the file to parse * @result: the file with expected result * @err: the file with error messages * * Parse a file containing XPath expressions and evaluate them against * a set of corresponding documents. * * Returns 0 in case of success, an error code otherwise */
| 2672 | * Returns 0 in case of success, an error code otherwise |
| 2673 | */ |
| 2674 | static int |
| 2675 | xpathDocTest(const char *filename, |
| 2676 | const char *resul ATTRIBUTE_UNUSED, |
| 2677 | const char *err ATTRIBUTE_UNUSED, |
| 2678 | int options) { |
| 2679 | |
| 2680 | char pattern[500]; |
| 2681 | char result[500]; |
| 2682 | glob_t globbuf; |
| 2683 | size_t i; |
| 2684 | int ret = 0, res; |
| 2685 | |
| 2686 | xpathDocument = xmlReadFile(filename, NULL, |
| 2687 | options | XML_PARSE_DTDATTR | XML_PARSE_NOENT); |
| 2688 | if (xpathDocument == NULL) { |
| 2689 | fprintf(stderr, "Failed to load %s\n", filename); |
| 2690 | return(-1); |
| 2691 | } |
| 2692 | |
| 2693 | res = snprintf(pattern, 499, "./test/XPath/tests/%s*", |
| 2694 | baseFilename(filename)); |
| 2695 | if (res >= 499) |
| 2696 | pattern[499] = 0; |
| 2697 | globbuf.gl_offs = 0; |
| 2698 | glob(pattern, GLOB_DOOFFS, NULL, &globbuf); |
| 2699 | for (i = 0;i < globbuf.gl_pathc;i++) { |
| 2700 | res = snprintf(result, 499, "result/XPath/tests/%s", |
| 2701 | baseFilename(globbuf.gl_pathv[i])); |
| 2702 | if (res >= 499) |
| 2703 | result[499] = 0; |
| 2704 | res = xpathCommonTest(globbuf.gl_pathv[i], &result[0], 0, 0); |
| 2705 | if (res != 0) |
| 2706 | ret = res; |
| 2707 | } |
| 2708 | globfree(&globbuf); |
| 2709 | |
| 2710 | xmlFreeDoc(xpathDocument); |
| 2711 | return(ret); |
| 2712 | } |
| 2713 | |
| 2714 | #ifdef LIBXML_XPTR_ENABLED |
| 2715 | /** |
nothing calls this directly
no test coverage detected