| OLD | NEW |
| 1 /* | 1 /* |
| 2 * runtest.c: C program to run libxml2 regression tests without | 2 * runtest.c: C program to run libxml2 regression tests without |
| 3 * requiring make or Python, and reducing platform dependancies | 3 * requiring make or Python, and reducing platform dependancies |
| 4 * to a strict minimum. | 4 * to a strict minimum. |
| 5 * | 5 * |
| 6 * To compile on Unixes: | 6 * To compile on Unixes: |
| 7 * cc -o runtest `xml2-config --cflags` runtest.c `xml2-config --libs` -lpthread | 7 * cc -o runtest `xml2-config --cflags` runtest.c `xml2-config --libs` -lpthread |
| 8 * | 8 * |
| 9 * See Copyright for the status of this software. | 9 * See Copyright for the status of this software. |
| 10 * | 10 * |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #include <libxml/catalog.h> | 74 #include <libxml/catalog.h> |
| 75 #include <string.h> | 75 #include <string.h> |
| 76 #endif | 76 #endif |
| 77 | 77 |
| 78 /* | 78 /* |
| 79 * O_BINARY is just for Windows compatibility - if it isn't defined | 79 * O_BINARY is just for Windows compatibility - if it isn't defined |
| 80 * on this system, avoid any compilation error | 80 * on this system, avoid any compilation error |
| 81 */ | 81 */ |
| 82 #ifdef O_BINARY | 82 #ifdef O_BINARY |
| 83 #define RD_FLAGS O_RDONLY | O_BINARY | 83 #define RD_FLAGS O_RDONLY | O_BINARY |
| 84 #define WR_FLAGS O_WRONLY | O_CREAT | O_TRUNC | O_BINARY |
| 84 #else | 85 #else |
| 85 #define»RD_FLAGS» O_RDONLY | 86 #define RD_FLAGS» O_RDONLY |
| 87 #define WR_FLAGS» O_WRONLY | O_CREAT | O_TRUNC |
| 86 #endif | 88 #endif |
| 87 | 89 |
| 88 typedef int (*functest) (const char *filename, const char *result, | 90 typedef int (*functest) (const char *filename, const char *result, |
| 89 const char *error, int options); | 91 const char *error, int options); |
| 90 | 92 |
| 91 typedef struct testDesc testDesc; | 93 typedef struct testDesc testDesc; |
| 92 typedef testDesc *testDescPtr; | 94 typedef testDesc *testDescPtr; |
| 93 struct testDesc { | 95 struct testDesc { |
| 94 const char *desc; /* descripton of the test */ | 96 const char *desc; /* descripton of the test */ |
| 95 functest func; /* function implementing the test */ | 97 functest func; /* function implementing the test */ |
| 96 const char *in; /* glob to path for input files */ | 98 const char *in; /* glob to path for input files */ |
| 97 const char *out; /* output directory */ | 99 const char *out; /* output directory */ |
| 98 const char *suffix;/* suffix for output files */ | 100 const char *suffix;/* suffix for output files */ |
| 99 const char *err; /* suffix for error output files */ | 101 const char *err; /* suffix for error output files */ |
| 100 int options; /* parser options for the test */ | 102 int options; /* parser options for the test */ |
| 101 }; | 103 }; |
| 102 | 104 |
| 105 static int update_results = 0; |
| 103 static int checkTestFile(const char *filename); | 106 static int checkTestFile(const char *filename); |
| 104 | 107 |
| 105 #if defined(_WIN32) && !defined(__CYGWIN__) | 108 #if defined(_WIN32) && !defined(__CYGWIN__) |
| 106 | 109 |
| 107 #include <windows.h> | 110 #include <windows.h> |
| 108 #include <io.h> | 111 #include <io.h> |
| 109 | 112 |
| 110 typedef struct | 113 typedef struct |
| 111 { | 114 { |
| 112 size_t gl_pathc; /* Count of paths matched so far */ | 115 size_t gl_pathc; /* Count of paths matched so far */ |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (!(buf.st_mode & _S_IFREG)) | 600 if (!(buf.st_mode & _S_IFREG)) |
| 598 return(0); | 601 return(0); |
| 599 #else | 602 #else |
| 600 if (!S_ISREG(buf.st_mode)) | 603 if (!S_ISREG(buf.st_mode)) |
| 601 return(0); | 604 return(0); |
| 602 #endif | 605 #endif |
| 603 | 606 |
| 604 return(1); | 607 return(1); |
| 605 } | 608 } |
| 606 | 609 |
| 607 static int compareFiles(const char *r1, const char *r2) { | 610 static int compareFiles(const char *r1 /* temp */, const char *r2 /* result */)
{ |
| 608 int res1, res2; | 611 int res1, res2; |
| 609 int fd1, fd2; | 612 int fd1, fd2; |
| 610 char bytes1[4096]; | 613 char bytes1[4096]; |
| 611 char bytes2[4096]; | 614 char bytes2[4096]; |
| 612 | 615 |
| 616 if (update_results) { |
| 617 fd1 = open(r1, RD_FLAGS); |
| 618 if (fd1 < 0) |
| 619 return(-1); |
| 620 fd2 = open(r2, WR_FLAGS, 0644); |
| 621 if (fd2 < 0) { |
| 622 close(fd1); |
| 623 return(-1); |
| 624 } |
| 625 do { |
| 626 res1 = read(fd1, bytes1, 4096); |
| 627 if (res1 <= 0) |
| 628 break; |
| 629 res2 = write(fd2, bytes1, res1); |
| 630 if (res2 <= 0 || res2 != res1) |
| 631 break; |
| 632 } while (1); |
| 633 close(fd2); |
| 634 close(fd1); |
| 635 return(res1 != 0); |
| 636 } |
| 637 |
| 613 fd1 = open(r1, RD_FLAGS); | 638 fd1 = open(r1, RD_FLAGS); |
| 614 if (fd1 < 0) | 639 if (fd1 < 0) |
| 615 return(-1); | 640 return(-1); |
| 616 fd2 = open(r2, RD_FLAGS); | 641 fd2 = open(r2, RD_FLAGS); |
| 617 if (fd2 < 0) { | 642 if (fd2 < 0) { |
| 618 close(fd1); | 643 close(fd1); |
| 619 return(-1); | 644 return(-1); |
| 620 } | 645 } |
| 621 while (1) { | 646 while (1) { |
| 622 res1 = read(fd1, bytes1, 4096); | 647 res1 = read(fd1, bytes1, 4096); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 639 return(0); | 664 return(0); |
| 640 } | 665 } |
| 641 | 666 |
| 642 static int compareFileMem(const char *filename, const char *mem, int size) { | 667 static int compareFileMem(const char *filename, const char *mem, int size) { |
| 643 int res; | 668 int res; |
| 644 int fd; | 669 int fd; |
| 645 char bytes[4096]; | 670 char bytes[4096]; |
| 646 int idx = 0; | 671 int idx = 0; |
| 647 struct stat info; | 672 struct stat info; |
| 648 | 673 |
| 649 if (stat(filename, &info) < 0) | 674 if (update_results) { |
| 675 fd = open(filename, WR_FLAGS, 0644); |
| 676 if (fd < 0) { |
| 677 » fprintf(stderr, "failed to open %s for writing", filename); |
| 678 return(-1); |
| 679 » } |
| 680 res = write(fd, mem, size); |
| 681 close(fd); |
| 682 return(res != size); |
| 683 } |
| 684 |
| 685 if (stat(filename, &info) < 0) { |
| 686 fprintf(stderr, "failed to stat %s\n", filename); |
| 650 return(-1); | 687 return(-1); |
| 651 if (info.st_size != size) | 688 } |
| 689 if (info.st_size != size) { |
| 690 fprintf(stderr, "file %s is %ld bytes, result is %d bytes\n", |
| 691 » filename, info.st_size, size); |
| 652 return(-1); | 692 return(-1); |
| 693 } |
| 653 fd = open(filename, RD_FLAGS); | 694 fd = open(filename, RD_FLAGS); |
| 654 if (fd < 0) | 695 if (fd < 0) { |
| 696 » fprintf(stderr, "failed to open %s for reading", filename); |
| 655 return(-1); | 697 return(-1); |
| 698 } |
| 656 while (idx < size) { | 699 while (idx < size) { |
| 657 res = read(fd, bytes, 4096); | 700 res = read(fd, bytes, 4096); |
| 658 if (res <= 0) | 701 if (res <= 0) |
| 659 break; | 702 break; |
| 660 if (res + idx > size) | 703 if (res + idx > size) |
| 661 break; | 704 break; |
| 662 if (memcmp(bytes, &mem[idx], res) != 0) { | 705 if (memcmp(bytes, &mem[idx], res) != 0) { |
| 663 int ix; | 706 int ix; |
| 664 for (ix=0; ix<res; ix++) | 707 for (ix=0; ix<res; ix++) |
| 665 if (bytes[ix] != mem[idx+ix]) | 708 if (bytes[ix] != mem[idx+ix]) |
| 666 break; | 709 break; |
| 667 fprintf(stderr,"Compare error at position %d\n", idx+ix); | 710 fprintf(stderr,"Compare error at position %d\n", idx+ix); |
| 668 close(fd); | 711 close(fd); |
| 669 return(1); | 712 return(1); |
| 670 } | 713 } |
| 671 idx += res; | 714 idx += res; |
| 672 } | 715 } |
| 673 close(fd); | 716 close(fd); |
| 717 if (idx != size) { |
| 718 fprintf(stderr,"Compare error index %d, size %d\n", idx, size); |
| 719 } |
| 674 return(idx != size); | 720 return(idx != size); |
| 675 } | 721 } |
| 676 | 722 |
| 677 static int loadMem(const char *filename, const char **mem, int *size) { | 723 static int loadMem(const char *filename, const char **mem, int *size) { |
| 678 int fd, res; | 724 int fd, res; |
| 679 struct stat info; | 725 struct stat info; |
| 680 char *base; | 726 char *base; |
| 681 int siz = 0; | 727 int siz = 0; |
| 682 if (stat(filename, &info) < 0) | 728 if (stat(filename, &info) < 0) |
| 683 return(-1); | 729 return(-1); |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 | 1866 |
| 1821 #ifdef LIBXML_HTML_ENABLED | 1867 #ifdef LIBXML_HTML_ENABLED |
| 1822 if (options & XML_PARSE_HTML) | 1868 if (options & XML_PARSE_HTML) |
| 1823 ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename, | 1869 ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename, |
| 1824 XML_CHAR_ENCODING_NONE); | 1870 XML_CHAR_ENCODING_NONE); |
| 1825 else | 1871 else |
| 1826 #endif | 1872 #endif |
| 1827 ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename); | 1873 ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename); |
| 1828 xmlCtxtUseOptions(ctxt, options); | 1874 xmlCtxtUseOptions(ctxt, options); |
| 1829 cur += 4; | 1875 cur += 4; |
| 1830 while (cur < size) { | 1876 do { |
| 1831 if (cur + 1024 >= size) { | 1877 if (cur + 1024 >= size) { |
| 1832 #ifdef LIBXML_HTML_ENABLED | 1878 #ifdef LIBXML_HTML_ENABLED |
| 1833 if (options & XML_PARSE_HTML) | 1879 if (options & XML_PARSE_HTML) |
| 1834 htmlParseChunk(ctxt, base + cur, size - cur, 1); | 1880 htmlParseChunk(ctxt, base + cur, size - cur, 1); |
| 1835 else | 1881 else |
| 1836 #endif | 1882 #endif |
| 1837 xmlParseChunk(ctxt, base + cur, size - cur, 1); | 1883 xmlParseChunk(ctxt, base + cur, size - cur, 1); |
| 1838 break; | 1884 break; |
| 1839 } else { | 1885 } else { |
| 1840 #ifdef LIBXML_HTML_ENABLED | 1886 #ifdef LIBXML_HTML_ENABLED |
| 1841 if (options & XML_PARSE_HTML) | 1887 if (options & XML_PARSE_HTML) |
| 1842 htmlParseChunk(ctxt, base + cur, 1024, 0); | 1888 htmlParseChunk(ctxt, base + cur, 1024, 0); |
| 1843 else | 1889 else |
| 1844 #endif | 1890 #endif |
| 1845 xmlParseChunk(ctxt, base + cur, 1024, 0); | 1891 xmlParseChunk(ctxt, base + cur, 1024, 0); |
| 1846 cur += 1024; | 1892 cur += 1024; |
| 1847 } | 1893 } |
| 1848 } | 1894 } while (cur < size); |
| 1849 doc = ctxt->myDoc; | 1895 doc = ctxt->myDoc; |
| 1850 #ifdef LIBXML_HTML_ENABLED | 1896 #ifdef LIBXML_HTML_ENABLED |
| 1851 if (options & XML_PARSE_HTML) | 1897 if (options & XML_PARSE_HTML) |
| 1852 res = 1; | 1898 res = 1; |
| 1853 else | 1899 else |
| 1854 #endif | 1900 #endif |
| 1855 res = ctxt->wellFormed; | 1901 res = ctxt->wellFormed; |
| 1856 xmlFreeParserCtxt(ctxt); | 1902 xmlFreeParserCtxt(ctxt); |
| 1857 free((char *)base); | 1903 free((char *)base); |
| 1858 if (!res) { | 1904 if (!res) { |
| 1859 xmlFreeDoc(doc); | 1905 xmlFreeDoc(doc); |
| 1860 fprintf(stderr, "Failed to parse %s\n", filename); | 1906 fprintf(stderr, "Failed to parse %s\n", filename); |
| 1861 return(-1); | 1907 return(-1); |
| 1862 } | 1908 } |
| 1863 #ifdef LIBXML_HTML_ENABLED | 1909 #ifdef LIBXML_HTML_ENABLED |
| 1864 if (options & XML_PARSE_HTML) | 1910 if (options & XML_PARSE_HTML) |
| 1865 htmlDocDumpMemory(doc, (xmlChar **) &base, &size); | 1911 htmlDocDumpMemory(doc, (xmlChar **) &base, &size); |
| 1866 else | 1912 else |
| 1867 #endif | 1913 #endif |
| 1868 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); | 1914 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); |
| 1869 xmlFreeDoc(doc); | 1915 xmlFreeDoc(doc); |
| 1870 res = compareFileMem(result, base, size); | 1916 res = compareFileMem(result, base, size); |
| 1871 if ((base == NULL) || (res != 0)) { | 1917 if ((base == NULL) || (res != 0)) { |
| 1872 if (base != NULL) | 1918 if (base != NULL) |
| 1873 xmlFree((char *)base); | 1919 xmlFree((char *)base); |
| 1874 fprintf(stderr, "Result for %s failed\n", filename); | 1920 fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 1875 return(-1); | 1921 return(-1); |
| 1876 } | 1922 } |
| 1877 xmlFree((char *)base); | 1923 xmlFree((char *)base); |
| 1878 if (err != NULL) { | 1924 if (err != NULL) { |
| 1879 res = compareFileMem(err, testErrors, testErrorsSize); | 1925 res = compareFileMem(err, testErrors, testErrorsSize); |
| 1880 if (res != 0) { | 1926 if (res != 0) { |
| 1881 fprintf(stderr, "Error for %s failed\n", filename); | 1927 fprintf(stderr, "Error for %s failed\n", filename); |
| 1882 return(-1); | 1928 return(-1); |
| 1883 } | 1929 } |
| 1884 } | 1930 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 unloadMem(base); | 1965 unloadMem(base); |
| 1920 if (doc == NULL) { | 1966 if (doc == NULL) { |
| 1921 return(1); | 1967 return(1); |
| 1922 } | 1968 } |
| 1923 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); | 1969 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); |
| 1924 xmlFreeDoc(doc); | 1970 xmlFreeDoc(doc); |
| 1925 res = compareFileMem(result, base, size); | 1971 res = compareFileMem(result, base, size); |
| 1926 if ((base == NULL) || (res != 0)) { | 1972 if ((base == NULL) || (res != 0)) { |
| 1927 if (base != NULL) | 1973 if (base != NULL) |
| 1928 xmlFree((char *)base); | 1974 xmlFree((char *)base); |
| 1929 fprintf(stderr, "Result for %s failed\n", filename); | 1975 fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 1930 return(-1); | 1976 return(-1); |
| 1931 } | 1977 } |
| 1932 xmlFree((char *)base); | 1978 xmlFree((char *)base); |
| 1933 return(0); | 1979 return(0); |
| 1934 } | 1980 } |
| 1935 | 1981 |
| 1936 /** | 1982 /** |
| 1937 * noentParseTest: | 1983 * noentParseTest: |
| 1938 * @filename: the file to parse | 1984 * @filename: the file to parse |
| 1939 * @result: the file with expected result | 1985 * @result: the file with expected result |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 size = 0; | 2076 size = 0; |
| 2031 } else { | 2077 } else { |
| 2032 #ifdef LIBXML_HTML_ENABLED | 2078 #ifdef LIBXML_HTML_ENABLED |
| 2033 if (options & XML_PARSE_HTML) { | 2079 if (options & XML_PARSE_HTML) { |
| 2034 htmlDocDumpMemory(doc, (xmlChar **) &base, &size); | 2080 htmlDocDumpMemory(doc, (xmlChar **) &base, &size); |
| 2035 } else | 2081 } else |
| 2036 #endif | 2082 #endif |
| 2037 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); | 2083 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); |
| 2038 } | 2084 } |
| 2039 res = compareFileMem(result, base, size); | 2085 res = compareFileMem(result, base, size); |
| 2086 if (res != 0) { |
| 2087 fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 2088 return(-1); |
| 2089 } |
| 2040 } | 2090 } |
| 2041 if (doc != NULL) { | 2091 if (doc != NULL) { |
| 2042 if (base != NULL) | 2092 if (base != NULL) |
| 2043 xmlFree((char *)base); | 2093 xmlFree((char *)base); |
| 2044 xmlFreeDoc(doc); | 2094 xmlFreeDoc(doc); |
| 2045 } | 2095 } |
| 2046 if (res != 0) { | |
| 2047 fprintf(stderr, "Result for %s failed\n", filename); | |
| 2048 return(-1); | |
| 2049 } | |
| 2050 if (err != NULL) { | 2096 if (err != NULL) { |
| 2051 res = compareFileMem(err, testErrors, testErrorsSize); | 2097 res = compareFileMem(err, testErrors, testErrorsSize); |
| 2052 if (res != 0) { | 2098 if (res != 0) { |
| 2053 fprintf(stderr, "Error for %s failed\n", filename); | 2099 fprintf(stderr, "Error for %s failed\n", filename); |
| 2054 return(-1); | 2100 return(-1); |
| 2055 } | 2101 } |
| 2056 } else if (options & XML_PARSE_DTDVALID) { | 2102 } else if (options & XML_PARSE_DTDVALID) { |
| 2057 if (testErrorsSize != 0) | 2103 if (testErrorsSize != 0) |
| 2058 fprintf(stderr, "Validation for %s failed\n", filename); | 2104 fprintf(stderr, "Validation for %s failed\n", filename); |
| 2059 } | 2105 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 } | 2198 } |
| 2153 xmlGetWarningsDefaultValue = 0; | 2199 xmlGetWarningsDefaultValue = 0; |
| 2154 if (t != NULL) { | 2200 if (t != NULL) { |
| 2155 fclose(t); | 2201 fclose(t); |
| 2156 ret = compareFiles(temp, result); | 2202 ret = compareFiles(temp, result); |
| 2157 if (temp != NULL) { | 2203 if (temp != NULL) { |
| 2158 unlink(temp); | 2204 unlink(temp); |
| 2159 free(temp); | 2205 free(temp); |
| 2160 } | 2206 } |
| 2161 if (ret) { | 2207 if (ret) { |
| 2162 » fprintf(stderr, "Result for %s failed\n", filename); | 2208 » fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 2163 return(-1); | 2209 return(-1); |
| 2164 } | 2210 } |
| 2165 } | 2211 } |
| 2166 if (err != NULL) { | 2212 if (err != NULL) { |
| 2167 ret = compareFileMem(err, testErrors, testErrorsSize); | 2213 ret = compareFileMem(err, testErrors, testErrorsSize); |
| 2168 if (ret != 0) { | 2214 if (ret != 0) { |
| 2169 fprintf(stderr, "Error for %s failed\n", filename); | 2215 fprintf(stderr, "Error for %s failed\n", filename); |
| 2170 printf("%s", testErrors); | 2216 printf("%s", testErrors); |
| 2171 return(-1); | 2217 return(-1); |
| 2172 } | 2218 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 expression) ; | 2401 expression) ; |
| 2356 testXPath(expression, xptr, expr); | 2402 testXPath(expression, xptr, expr); |
| 2357 } | 2403 } |
| 2358 } | 2404 } |
| 2359 | 2405 |
| 2360 fclose(input); | 2406 fclose(input); |
| 2361 fclose(xpathOutput); | 2407 fclose(xpathOutput); |
| 2362 if (result != NULL) { | 2408 if (result != NULL) { |
| 2363 ret = compareFiles(temp, result); | 2409 ret = compareFiles(temp, result); |
| 2364 if (ret) { | 2410 if (ret) { |
| 2365 » fprintf(stderr, "Result for %s failed\n", filename); | 2411 » fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 2366 } | 2412 } |
| 2367 } | 2413 } |
| 2368 | 2414 |
| 2369 if (temp != NULL) { | 2415 if (temp != NULL) { |
| 2370 unlink(temp); | 2416 unlink(temp); |
| 2371 free(temp); | 2417 free(temp); |
| 2372 } | 2418 } |
| 2373 return(ret); | 2419 return(ret); |
| 2374 } | 2420 } |
| 2375 | 2421 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 free(temp); | 2572 free(temp); |
| 2527 return(-1); | 2573 return(-1); |
| 2528 } | 2574 } |
| 2529 | 2575 |
| 2530 testXPath("id('bar')", 0, 0); | 2576 testXPath("id('bar')", 0, 0); |
| 2531 | 2577 |
| 2532 fclose(xpathOutput); | 2578 fclose(xpathOutput); |
| 2533 if (result != NULL) { | 2579 if (result != NULL) { |
| 2534 ret = compareFiles(temp, result); | 2580 ret = compareFiles(temp, result); |
| 2535 if (ret) { | 2581 if (ret) { |
| 2536 » fprintf(stderr, "Result for %s failed\n", filename); | 2582 » fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 2537 res = 1; | 2583 res = 1; |
| 2538 } | 2584 } |
| 2539 } | 2585 } |
| 2540 | 2586 |
| 2541 if (temp != NULL) { | 2587 if (temp != NULL) { |
| 2542 unlink(temp); | 2588 unlink(temp); |
| 2543 free(temp); | 2589 free(temp); |
| 2544 } | 2590 } |
| 2545 xmlFreeDoc(xpathDocument); | 2591 xmlFreeDoc(xpathDocument); |
| 2546 | 2592 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 nb_tests++; | 2700 nb_tests++; |
| 2655 handleURI(str, base, o); | 2701 handleURI(str, base, o); |
| 2656 } | 2702 } |
| 2657 | 2703 |
| 2658 fclose(f); | 2704 fclose(f); |
| 2659 fclose(o); | 2705 fclose(o); |
| 2660 | 2706 |
| 2661 if (result != NULL) { | 2707 if (result != NULL) { |
| 2662 ret = compareFiles(temp, result); | 2708 ret = compareFiles(temp, result); |
| 2663 if (ret) { | 2709 if (ret) { |
| 2664 » fprintf(stderr, "Result for %s failed\n", filename); | 2710 » fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 2665 res = 1; | 2711 res = 1; |
| 2666 } | 2712 } |
| 2667 } | 2713 } |
| 2668 if (err != NULL) { | 2714 if (err != NULL) { |
| 2669 ret = compareFileMem(err, testErrors, testErrorsSize); | 2715 ret = compareFileMem(err, testErrors, testErrorsSize); |
| 2670 if (ret != 0) { | 2716 if (ret != 0) { |
| 2671 fprintf(stderr, "Error for %s failed\n", filename); | 2717 fprintf(stderr, "Error for %s failed\n", filename); |
| 2672 res = 1; | 2718 res = 1; |
| 2673 } | 2719 } |
| 2674 } | 2720 } |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3423 xmlDocPtr doc; | 3469 xmlDocPtr doc; |
| 3424 | 3470 |
| 3425 len = strlen(filename); | 3471 len = strlen(filename); |
| 3426 len -= 4; | 3472 len -= 4; |
| 3427 memcpy(xml, filename, len); | 3473 memcpy(xml, filename, len); |
| 3428 xml[len] = 0; | 3474 xml[len] = 0; |
| 3429 snprintf(result, 499, "result/pattern/%s", baseFilename(xml)); | 3475 snprintf(result, 499, "result/pattern/%s", baseFilename(xml)); |
| 3430 result[499] = 0; | 3476 result[499] = 0; |
| 3431 memcpy(xml + len, ".xml", 5); | 3477 memcpy(xml + len, ".xml", 5); |
| 3432 | 3478 |
| 3433 if (!checkTestFile(xml)) { | 3479 if (!checkTestFile(xml) && !update_results) { |
| 3434 fprintf(stderr, "Missing xml file %s\n", xml); | 3480 fprintf(stderr, "Missing xml file %s\n", xml); |
| 3435 return(-1); | 3481 return(-1); |
| 3436 } | 3482 } |
| 3437 if (!checkTestFile(result)) { | 3483 if (!checkTestFile(result) && !update_results) { |
| 3438 fprintf(stderr, "Missing result file %s\n", result); | 3484 fprintf(stderr, "Missing result file %s\n", result); |
| 3439 return(-1); | 3485 return(-1); |
| 3440 } | 3486 } |
| 3441 f = fopen(filename, "rb"); | 3487 f = fopen(filename, "rb"); |
| 3442 if (f == NULL) { | 3488 if (f == NULL) { |
| 3443 fprintf(stderr, "Failed to open %s\n", filename); | 3489 fprintf(stderr, "Failed to open %s\n", filename); |
| 3444 return(-1); | 3490 return(-1); |
| 3445 } | 3491 } |
| 3446 temp = resultFilename(filename, "", ".res"); | 3492 temp = resultFilename(filename, "", ".res"); |
| 3447 if (temp == NULL) { | 3493 if (temp == NULL) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3526 xmlFreePattern(patternc); | 3572 xmlFreePattern(patternc); |
| 3527 | 3573 |
| 3528 } | 3574 } |
| 3529 } | 3575 } |
| 3530 | 3576 |
| 3531 fclose(f); | 3577 fclose(f); |
| 3532 fclose(o); | 3578 fclose(o); |
| 3533 | 3579 |
| 3534 ret = compareFiles(temp, result); | 3580 ret = compareFiles(temp, result); |
| 3535 if (ret) { | 3581 if (ret) { |
| 3536 » fprintf(stderr, "Result for %s failed\n", filename); | 3582 » fprintf(stderr, "Result for %s failed in %s\n", filename, result); |
| 3537 ret = 1; | 3583 ret = 1; |
| 3538 } | 3584 } |
| 3539 if (temp != NULL) { | 3585 if (temp != NULL) { |
| 3540 unlink(temp); | 3586 unlink(temp); |
| 3541 free(temp); | 3587 free(temp); |
| 3542 } | 3588 } |
| 3543 return(ret); | 3589 return(ret); |
| 3544 } | 3590 } |
| 3545 #endif /* READER */ | 3591 #endif /* READER */ |
| 3546 #endif /* PATTERN */ | 3592 #endif /* PATTERN */ |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3798 char *ns = NULL; | 3844 char *ns = NULL; |
| 3799 int ret = 0; | 3845 int ret = 0; |
| 3800 | 3846 |
| 3801 base = baseFilename(filename); | 3847 base = baseFilename(filename); |
| 3802 len = strlen(base); | 3848 len = strlen(base); |
| 3803 len -= 4; | 3849 len -= 4; |
| 3804 memcpy(prefix, base, len); | 3850 memcpy(prefix, base, len); |
| 3805 prefix[len] = 0; | 3851 prefix[len] = 0; |
| 3806 | 3852 |
| 3807 snprintf(buf, 499, "result/c14n/%s/%s", subdir,prefix); | 3853 snprintf(buf, 499, "result/c14n/%s/%s", subdir,prefix); |
| 3808 if (!checkTestFile(buf)) { | 3854 if (!checkTestFile(buf) && !update_results) { |
| 3809 fprintf(stderr, "Missing result file %s", buf); | 3855 fprintf(stderr, "Missing result file %s", buf); |
| 3810 return(-1); | 3856 return(-1); |
| 3811 } | 3857 } |
| 3812 result = strdup(buf); | 3858 result = strdup(buf); |
| 3813 snprintf(buf, 499, "test/c14n/%s/%s.xpath", subdir,prefix); | 3859 snprintf(buf, 499, "test/c14n/%s/%s.xpath", subdir,prefix); |
| 3814 if (checkTestFile(buf)) { | 3860 if (checkTestFile(buf)) { |
| 3815 xpath = strdup(buf); | 3861 xpath = strdup(buf); |
| 3816 } | 3862 } |
| 3817 snprintf(buf, 499, "test/c14n/%s/%s.ns", subdir,prefix); | 3863 snprintf(buf, 499, "test/c14n/%s/%s.ns", subdir,prefix); |
| 3818 if (checkTestFile(buf)) { | 3864 if (checkTestFile(buf)) { |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4347 if (tst->err != NULL) { | 4393 if (tst->err != NULL) { |
| 4348 error = resultFilename(globbuf.gl_pathv[i], tst->out, | 4394 error = resultFilename(globbuf.gl_pathv[i], tst->out, |
| 4349 tst->err); | 4395 tst->err); |
| 4350 if (error == NULL) { | 4396 if (error == NULL) { |
| 4351 fprintf(stderr, "Out of memory !\n"); | 4397 fprintf(stderr, "Out of memory !\n"); |
| 4352 fatalError(); | 4398 fatalError(); |
| 4353 } | 4399 } |
| 4354 } else { | 4400 } else { |
| 4355 error = NULL; | 4401 error = NULL; |
| 4356 } | 4402 } |
| 4357 » if ((result) &&(!checkTestFile(result))) { | 4403 » if ((result) &&(!checkTestFile(result)) && !update_results) { |
| 4358 fprintf(stderr, "Missing result file %s\n", result); | 4404 fprintf(stderr, "Missing result file %s\n", result); |
| 4359 » } else if ((error) &&(!checkTestFile(error))) { | 4405 » } else if ((error) &&(!checkTestFile(error)) && !update_results) { |
| 4360 fprintf(stderr, "Missing error file %s\n", error); | 4406 fprintf(stderr, "Missing error file %s\n", error); |
| 4361 } else { | 4407 } else { |
| 4362 mem = xmlMemUsed(); | 4408 mem = xmlMemUsed(); |
| 4363 extraMemoryFromResolver = 0; | 4409 extraMemoryFromResolver = 0; |
| 4364 testErrorsSize = 0; | 4410 testErrorsSize = 0; |
| 4365 testErrors[0] = 0; | 4411 testErrors[0] = 0; |
| 4366 res = tst->func(globbuf.gl_pathv[i], result, error, | 4412 res = tst->func(globbuf.gl_pathv[i], result, error, |
| 4367 tst->options | XML_PARSE_COMPACT); | 4413 tst->options | XML_PARSE_COMPACT); |
| 4368 xmlResetLastError(); | 4414 xmlResetLastError(); |
| 4369 if (res != 0) { | 4415 if (res != 0) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4433 int | 4479 int |
| 4434 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { | 4480 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
| 4435 int i, a, ret = 0; | 4481 int i, a, ret = 0; |
| 4436 int subset = 0; | 4482 int subset = 0; |
| 4437 | 4483 |
| 4438 initializeLibxml2(); | 4484 initializeLibxml2(); |
| 4439 | 4485 |
| 4440 for (a = 1; a < argc;a++) { | 4486 for (a = 1; a < argc;a++) { |
| 4441 if (!strcmp(argv[a], "-v")) | 4487 if (!strcmp(argv[a], "-v")) |
| 4442 verbose = 1; | 4488 verbose = 1; |
| 4489 else if (!strcmp(argv[a], "-u")) |
| 4490 update_results = 1; |
| 4443 else if (!strcmp(argv[a], "-quiet")) | 4491 else if (!strcmp(argv[a], "-quiet")) |
| 4444 tests_quiet = 1; | 4492 tests_quiet = 1; |
| 4445 else { | 4493 else { |
| 4446 for (i = 0; testDescriptions[i].func != NULL; i++) { | 4494 for (i = 0; testDescriptions[i].func != NULL; i++) { |
| 4447 if (strstr(testDescriptions[i].desc, argv[a])) { | 4495 if (strstr(testDescriptions[i].desc, argv[a])) { |
| 4448 ret += runtest(i); | 4496 ret += runtest(i); |
| 4449 subset++; | 4497 subset++; |
| 4450 } | 4498 } |
| 4451 } | 4499 } |
| 4452 } | 4500 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4471 return(ret); | 4519 return(ret); |
| 4472 } | 4520 } |
| 4473 | 4521 |
| 4474 #else /* ! LIBXML_OUTPUT_ENABLED */ | 4522 #else /* ! LIBXML_OUTPUT_ENABLED */ |
| 4475 int | 4523 int |
| 4476 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { | 4524 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
| 4477 fprintf(stderr, "runtest requires output to be enabled in libxml2\n"); | 4525 fprintf(stderr, "runtest requires output to be enabled in libxml2\n"); |
| 4478 return(1); | 4526 return(1); |
| 4479 } | 4527 } |
| 4480 #endif | 4528 #endif |
| OLD | NEW |