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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 int errfunc(const char *epath, int eerrno), | 122 int errfunc(const char *epath, int eerrno), |
123 glob_t *pglob) { | 123 glob_t *pglob) { |
124 glob_t *ret; | 124 glob_t *ret; |
125 WIN32_FIND_DATA FindFileData; | 125 WIN32_FIND_DATA FindFileData; |
126 HANDLE hFind; | 126 HANDLE hFind; |
127 unsigned int nb_paths = 0; | 127 unsigned int nb_paths = 0; |
128 char directory[500]; | 128 char directory[500]; |
129 int len; | 129 int len; |
130 | 130 |
131 if ((pattern == NULL) || (pglob == NULL)) return(-1); | 131 if ((pattern == NULL) || (pglob == NULL)) return(-1); |
132 | 132 |
133 strncpy(directory, pattern, 499); | 133 strncpy(directory, pattern, 499); |
134 for (len = strlen(directory);len >= 0;len--) { | 134 for (len = strlen(directory);len >= 0;len--) { |
135 if (directory[len] == '/') { | 135 if (directory[len] == '/') { |
136 len++; | 136 len++; |
137 directory[len] = 0; | 137 directory[len] = 0; |
138 break; | 138 break; |
139 } | 139 } |
140 } | 140 } |
141 if (len <= 0) | 141 if (len <= 0) |
142 len = 0; | 142 len = 0; |
143 | 143 |
144 | 144 |
145 ret = pglob; | 145 ret = pglob; |
146 memset(ret, 0, sizeof(glob_t)); | 146 memset(ret, 0, sizeof(glob_t)); |
147 | 147 |
148 hFind = FindFirstFileA(pattern, &FindFileData); | 148 hFind = FindFirstFileA(pattern, &FindFileData); |
149 if (hFind == INVALID_HANDLE_VALUE) | 149 if (hFind == INVALID_HANDLE_VALUE) |
150 return(0); | 150 return(0); |
151 nb_paths = 20; | 151 nb_paths = 20; |
152 ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *)); | 152 ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *)); |
153 if (ret->gl_pathv == NULL) { | 153 if (ret->gl_pathv == NULL) { |
154 FindClose(hFind); | 154 FindClose(hFind); |
155 return(-1); | 155 return(-1); |
156 } | 156 } |
157 strncpy(directory + len, FindFileData.cFileName, 499 - len); | 157 strncpy(directory + len, FindFileData.cFileName, 499 - len); |
158 ret->gl_pathv[ret->gl_pathc] = strdup(directory); | 158 ret->gl_pathv[ret->gl_pathc] = strdup(directory); |
159 if (ret->gl_pathv[ret->gl_pathc] == NULL) | 159 if (ret->gl_pathv[ret->gl_pathc] == NULL) |
(...skipping 14 matching lines...) Expand all Loading... |
174 if (ret->gl_pathv[ret->gl_pathc] == NULL) | 174 if (ret->gl_pathv[ret->gl_pathc] == NULL) |
175 break; | 175 break; |
176 ret->gl_pathc++; | 176 ret->gl_pathc++; |
177 } | 177 } |
178 ret->gl_pathv[ret->gl_pathc] = NULL; | 178 ret->gl_pathv[ret->gl_pathc] = NULL; |
179 | 179 |
180 done: | 180 done: |
181 FindClose(hFind); | 181 FindClose(hFind); |
182 return(0); | 182 return(0); |
183 } | 183 } |
184 | 184 |
185 | 185 |
186 | 186 |
187 static void globfree(glob_t *pglob) { | 187 static void globfree(glob_t *pglob) { |
188 unsigned int i; | 188 unsigned int i; |
189 if (pglob == NULL) | 189 if (pglob == NULL) |
190 return; | 190 return; |
191 | 191 |
192 for (i = 0;i < pglob->gl_pathc;i++) { | 192 for (i = 0;i < pglob->gl_pathc;i++) { |
193 if (pglob->gl_pathv[i] != NULL) | 193 if (pglob->gl_pathv[i] != NULL) |
194 free(pglob->gl_pathv[i]); | 194 free(pglob->gl_pathv[i]); |
195 } | 195 } |
196 } | 196 } |
197 #define vsnprintf _vsnprintf | 197 #define vsnprintf _vsnprintf |
198 #define snprintf _snprintf | 198 #define snprintf _snprintf |
199 #else | 199 #else |
200 #include <glob.h> | 200 #include <glob.h> |
201 #endif | 201 #endif |
(...skipping 13 matching lines...) Expand all Loading... |
215 fatalError(void) { | 215 fatalError(void) { |
216 fprintf(stderr, "Exitting tests on fatal error\n"); | 216 fprintf(stderr, "Exitting tests on fatal error\n"); |
217 exit(1); | 217 exit(1); |
218 } | 218 } |
219 | 219 |
220 /* | 220 /* |
221 * We need to trap calls to the resolver to not account memory for the catalog | 221 * We need to trap calls to the resolver to not account memory for the catalog |
222 * which is shared to the current running test. We also don't want to have | 222 * which is shared to the current running test. We also don't want to have |
223 * network downloads modifying tests. | 223 * network downloads modifying tests. |
224 */ | 224 */ |
225 static xmlParserInputPtr | 225 static xmlParserInputPtr |
226 testExternalEntityLoader(const char *URL, const char *ID, | 226 testExternalEntityLoader(const char *URL, const char *ID, |
227 xmlParserCtxtPtr ctxt) { | 227 xmlParserCtxtPtr ctxt) { |
228 xmlParserInputPtr ret; | 228 xmlParserInputPtr ret; |
229 | 229 |
230 if (checkTestFile(URL)) { | 230 if (checkTestFile(URL)) { |
231 ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); | 231 ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); |
232 } else { | 232 } else { |
233 int memused = xmlMemUsed(); | 233 int memused = xmlMemUsed(); |
234 ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); | 234 ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); |
235 extraMemoryFromResolver += xmlMemUsed() - memused; | 235 extraMemoryFromResolver += xmlMemUsed() - memused; |
236 } | 236 } |
237 | 237 |
238 return(ret); | 238 return(ret); |
239 } | 239 } |
240 | 240 |
241 /* | 241 /* |
242 * Trapping the error messages at the generic level to grab the equivalent of | 242 * Trapping the error messages at the generic level to grab the equivalent of |
243 * stderr messages on CLI tools. | 243 * stderr messages on CLI tools. |
244 */ | 244 */ |
245 static char testErrors[32769]; | 245 static char testErrors[32769]; |
246 static int testErrorsSize = 0; | 246 static int testErrorsSize = 0; |
247 | 247 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 testErrors[testErrorsSize] = 0; | 285 testErrors[testErrorsSize] = 0; |
286 } else { | 286 } else { |
287 testErrorsSize += res; | 287 testErrorsSize += res; |
288 } | 288 } |
289 testErrors[testErrorsSize] = 0; | 289 testErrors[testErrorsSize] = 0; |
290 } | 290 } |
291 | 291 |
292 /** | 292 /** |
293 * xmlParserPrintFileContext: | 293 * xmlParserPrintFileContext: |
294 * @input: an xmlParserInputPtr input | 294 * @input: an xmlParserInputPtr input |
295 * | 295 * |
296 * Displays current context within the input content for error tracking | 296 * Displays current context within the input content for error tracking |
297 */ | 297 */ |
298 | 298 |
299 static void | 299 static void |
300 xmlParserPrintFileContextInternal(xmlParserInputPtr input , | 300 xmlParserPrintFileContextInternal(xmlParserInputPtr input , |
301 xmlGenericErrorFunc chanl, void *data ) { | 301 xmlGenericErrorFunc chanl, void *data ) { |
302 const xmlChar *cur, *base; | 302 const xmlChar *cur, *base; |
303 unsigned int n, col; /* GCC warns if signed, because compared with si
zeof() */ | 303 unsigned int n, col; /* GCC warns if signed, because compared with si
zeof() */ |
304 xmlChar content[81]; /* space for 80 chars + line terminator */ | 304 xmlChar content[81]; /* space for 80 chars + line terminator */ |
305 xmlChar *ctnt; | 305 xmlChar *ctnt; |
306 | 306 |
307 if (input == NULL) return; | 307 if (input == NULL) return; |
308 cur = input->cur; | 308 cur = input->cur; |
309 base = input->base; | 309 base = input->base; |
310 /* skip backwards over any end-of-lines */ | 310 /* skip backwards over any end-of-lines */ |
311 while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { | 311 while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { |
312 cur--; | 312 cur--; |
313 } | 313 } |
314 n = 0; | 314 n = 0; |
315 /* search backwards for beginning-of-line (to max buff size) */ | 315 /* search backwards for beginning-of-line (to max buff size) */ |
316 while ((n++ < (sizeof(content)-1)) && (cur > base) && | 316 while ((n++ < (sizeof(content)-1)) && (cur > base) && |
317 » (*(cur) != '\n') && (*(cur) != '\r')) | 317 (*(cur) != '\n') && (*(cur) != '\r')) |
318 cur--; | 318 cur--; |
319 if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; | 319 if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; |
320 /* calculate the error position in terms of the current position */ | 320 /* calculate the error position in terms of the current position */ |
321 col = input->cur - cur; | 321 col = input->cur - cur; |
322 /* search forward for end-of-line (to max buff size) */ | 322 /* search forward for end-of-line (to max buff size) */ |
323 n = 0; | 323 n = 0; |
324 ctnt = content; | 324 ctnt = content; |
325 /* copy selected text to our buffer */ | 325 /* copy selected text to our buffer */ |
326 while ((*cur != 0) && (*(cur) != '\n') && | 326 while ((*cur != 0) && (*(cur) != '\n') && |
327 » (*(cur) != '\r') && (n < sizeof(content)-1)) { | 327 (*(cur) != '\r') && (n < sizeof(content)-1)) { |
328 *ctnt++ = *cur++; | 328 *ctnt++ = *cur++; |
329 n++; | 329 n++; |
330 } | 330 } |
331 *ctnt = 0; | 331 *ctnt = 0; |
332 /* print out the selected text */ | 332 /* print out the selected text */ |
333 chanl(data ,"%s\n", content); | 333 chanl(data ,"%s\n", content); |
334 /* create blank line with problem pointer */ | 334 /* create blank line with problem pointer */ |
335 n = 0; | 335 n = 0; |
336 ctnt = content; | 336 ctnt = content; |
337 /* (leave buffer space for pointer + line terminator) */ | 337 /* (leave buffer space for pointer + line terminator) */ |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 const char *base; | 566 const char *base; |
567 char res[500]; | 567 char res[500]; |
568 char suffixbuff[500]; | 568 char suffixbuff[500]; |
569 | 569 |
570 /************* | 570 /************* |
571 if ((filename[0] == 't') && (filename[1] == 'e') && | 571 if ((filename[0] == 't') && (filename[1] == 'e') && |
572 (filename[2] == 's') && (filename[3] == 't') && | 572 (filename[2] == 's') && (filename[3] == 't') && |
573 (filename[4] == '/')) | 573 (filename[4] == '/')) |
574 filename = &filename[5]; | 574 filename = &filename[5]; |
575 *************/ | 575 *************/ |
576 | 576 |
577 base = baseFilename(filename); | 577 base = baseFilename(filename); |
578 if (suffix == NULL) | 578 if (suffix == NULL) |
579 suffix = ".tmp"; | 579 suffix = ".tmp"; |
580 if (out == NULL) | 580 if (out == NULL) |
581 out = ""; | 581 out = ""; |
582 | 582 |
583 strncpy(suffixbuff,suffix,499); | 583 strncpy(suffixbuff,suffix,499); |
584 #ifdef VMS | 584 #ifdef VMS |
585 if(strstr(base,".") && suffixbuff[0]=='.') | 585 if(strstr(base,".") && suffixbuff[0]=='.') |
586 suffixbuff[0]='_'; | 586 suffixbuff[0]='_'; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 return(0); | 643 return(0); |
644 } | 644 } |
645 | 645 |
646 static int compareFileMem(const char *filename, const char *mem, int size) { | 646 static int compareFileMem(const char *filename, const char *mem, int size) { |
647 int res; | 647 int res; |
648 int fd; | 648 int fd; |
649 char bytes[4096]; | 649 char bytes[4096]; |
650 int idx = 0; | 650 int idx = 0; |
651 struct stat info; | 651 struct stat info; |
652 | 652 |
653 if (stat(filename, &info) < 0) | 653 if (stat(filename, &info) < 0) |
654 return(-1); | 654 return(-1); |
655 if (info.st_size != size) | 655 if (info.st_size != size) |
656 return(-1); | 656 return(-1); |
657 fd = open(filename, RD_FLAGS); | 657 fd = open(filename, RD_FLAGS); |
658 if (fd < 0) | 658 if (fd < 0) |
659 return(-1); | 659 return(-1); |
660 while (idx < size) { | 660 while (idx < size) { |
661 res = read(fd, bytes, 4096); | 661 res = read(fd, bytes, 4096); |
662 if (res <= 0) | 662 if (res <= 0) |
663 break; | 663 break; |
664 » if (res + idx > size) | 664 » if (res + idx > size) |
665 break; | 665 break; |
666 if (memcmp(bytes, &mem[idx], res) != 0) { | 666 if (memcmp(bytes, &mem[idx], res) != 0) { |
667 int ix; | 667 int ix; |
668 for (ix=0; ix<res; ix++) | 668 for (ix=0; ix<res; ix++) |
669 if (bytes[ix] != mem[idx+ix]) | 669 if (bytes[ix] != mem[idx+ix]) |
670 break; | 670 break; |
671 fprintf(stderr,"Compare error at position %d\n", idx+ix); | 671 fprintf(stderr,"Compare error at position %d\n", idx+ix); |
672 close(fd); | 672 close(fd); |
673 return(1); | 673 return(1); |
674 } | 674 } |
675 idx += res; | 675 idx += res; |
676 } | 676 } |
677 close(fd); | 677 close(fd); |
678 return(idx != size); | 678 return(idx != size); |
679 } | 679 } |
680 | 680 |
681 static int loadMem(const char *filename, const char **mem, int *size) { | 681 static int loadMem(const char *filename, const char **mem, int *size) { |
682 int fd, res; | 682 int fd, res; |
683 struct stat info; | 683 struct stat info; |
684 char *base; | 684 char *base; |
685 int siz = 0; | 685 int siz = 0; |
686 if (stat(filename, &info) < 0) | 686 if (stat(filename, &info) < 0) |
687 return(-1); | 687 return(-1); |
688 base = malloc(info.st_size + 1); | 688 base = malloc(info.st_size + 1); |
689 if (base == NULL) | 689 if (base == NULL) |
690 return(-1); | 690 return(-1); |
691 if ((fd = open(filename, RD_FLAGS)) < 0) { | 691 if ((fd = open(filename, RD_FLAGS)) < 0) { |
692 free(base); | 692 free(base); |
693 return(-1); | 693 return(-1); |
694 } | 694 } |
695 while ((res = read(fd, &base[siz], info.st_size - siz)) > 0) { | 695 while ((res = read(fd, &base[siz], info.st_size - siz)) > 0) { |
696 siz += res; | 696 siz += res; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. | 886 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. |
887 */ | 887 */ |
888 static xmlParserInputPtr | 888 static xmlParserInputPtr |
889 resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
lChar *systemId) | 889 resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
lChar *systemId) |
890 { | 890 { |
891 callbacks++; | 891 callbacks++; |
892 if (quiet) | 892 if (quiet) |
893 return(NULL); | 893 return(NULL); |
894 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ | 894 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ |
895 | 895 |
896 | 896 |
897 fprintf(SAXdebug, "SAX.resolveEntity("); | 897 fprintf(SAXdebug, "SAX.resolveEntity("); |
898 if (publicId != NULL) | 898 if (publicId != NULL) |
899 fprintf(SAXdebug, "%s", (char *)publicId); | 899 fprintf(SAXdebug, "%s", (char *)publicId); |
900 else | 900 else |
901 fprintf(SAXdebug, " "); | 901 fprintf(SAXdebug, " "); |
902 if (systemId != NULL) | 902 if (systemId != NULL) |
903 fprintf(SAXdebug, ", %s)\n", (char *)systemId); | 903 fprintf(SAXdebug, ", %s)\n", (char *)systemId); |
904 else | 904 else |
905 fprintf(SAXdebug, ", )\n"); | 905 fprintf(SAXdebug, ", )\n"); |
906 /********* | 906 /********* |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 if (quiet) | 946 if (quiet) |
947 return(NULL); | 947 return(NULL); |
948 fprintf(SAXdebug, "SAX.getParameterEntity(%s)\n", name); | 948 fprintf(SAXdebug, "SAX.getParameterEntity(%s)\n", name); |
949 return(NULL); | 949 return(NULL); |
950 } | 950 } |
951 | 951 |
952 | 952 |
953 /** | 953 /** |
954 * entityDeclDebug: | 954 * entityDeclDebug: |
955 * @ctxt: An XML parser context | 955 * @ctxt: An XML parser context |
956 * @name: the entity name | 956 * @name: the entity name |
957 * @type: the entity type | 957 * @type: the entity type |
958 * @publicId: The public ID of the entity | 958 * @publicId: The public ID of the entity |
959 * @systemId: The system ID of the entity | 959 * @systemId: The system ID of the entity |
960 * @content: the entity value (without processing). | 960 * @content: the entity value (without processing). |
961 * | 961 * |
962 * An entity definition has been parsed | 962 * An entity definition has been parsed |
963 */ | 963 */ |
964 static void | 964 static void |
965 entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, | 965 entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, |
966 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) | 966 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) |
967 { | 967 { |
968 const xmlChar *nullstr = BAD_CAST "(null)"; | 968 const xmlChar *nullstr = BAD_CAST "(null)"; |
969 /* not all libraries handle printing null pointers nicely */ | 969 /* not all libraries handle printing null pointers nicely */ |
970 if (publicId == NULL) | 970 if (publicId == NULL) |
971 publicId = nullstr; | 971 publicId = nullstr; |
972 if (systemId == NULL) | 972 if (systemId == NULL) |
973 systemId = nullstr; | 973 systemId = nullstr; |
974 if (content == NULL) | 974 if (content == NULL) |
975 content = (xmlChar *)nullstr; | 975 content = (xmlChar *)nullstr; |
976 callbacks++; | 976 callbacks++; |
977 if (quiet) | 977 if (quiet) |
978 return; | 978 return; |
979 fprintf(SAXdebug, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", | 979 fprintf(SAXdebug, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", |
980 name, type, publicId, systemId, content); | 980 name, type, publicId, systemId, content); |
981 } | 981 } |
982 | 982 |
983 /** | 983 /** |
984 * attributeDeclDebug: | 984 * attributeDeclDebug: |
985 * @ctxt: An XML parser context | 985 * @ctxt: An XML parser context |
986 * @name: the attribute name | 986 * @name: the attribute name |
987 * @type: the attribute type | 987 * @type: the attribute type |
988 * | 988 * |
989 * An attribute definition has been parsed | 989 * An attribute definition has been parsed |
990 */ | 990 */ |
991 static void | 991 static void |
992 attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, | 992 attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, |
993 const xmlChar * name, int type, int def, | 993 const xmlChar * name, int type, int def, |
994 const xmlChar * defaultValue, xmlEnumerationPtr tree) | 994 const xmlChar * defaultValue, xmlEnumerationPtr tree) |
995 { | 995 { |
996 callbacks++; | 996 callbacks++; |
997 if (quiet) | 997 if (quiet) |
998 return; | 998 return; |
999 if (defaultValue == NULL) | 999 if (defaultValue == NULL) |
1000 fprintf(SAXdebug, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", | 1000 fprintf(SAXdebug, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", |
1001 elem, name, type, def); | 1001 elem, name, type, def); |
1002 else | 1002 else |
1003 fprintf(SAXdebug, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", | 1003 fprintf(SAXdebug, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", |
1004 elem, name, type, def, defaultValue); | 1004 elem, name, type, def, defaultValue); |
1005 xmlFreeEnumeration(tree); | 1005 xmlFreeEnumeration(tree); |
1006 } | 1006 } |
1007 | 1007 |
1008 /** | 1008 /** |
1009 * elementDeclDebug: | 1009 * elementDeclDebug: |
1010 * @ctxt: An XML parser context | 1010 * @ctxt: An XML parser context |
1011 * @name: the element name | 1011 * @name: the element name |
1012 * @type: the element type | 1012 * @type: the element type |
1013 * @content: the element value (without processing). | 1013 * @content: the element value (without processing). |
1014 * | 1014 * |
1015 * An element definition has been parsed | 1015 * An element definition has been parsed |
1016 */ | 1016 */ |
1017 static void | 1017 static void |
1018 elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, | 1018 elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, |
1019 xmlElementContentPtr content ATTRIBUTE_UNUSED) | 1019 xmlElementContentPtr content ATTRIBUTE_UNUSED) |
1020 { | 1020 { |
1021 callbacks++; | 1021 callbacks++; |
1022 if (quiet) | 1022 if (quiet) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 output[i] = 0; | 1188 output[i] = 0; |
1189 | 1189 |
1190 fprintf(SAXdebug, "SAX.characters(%s, %d)\n", output, len); | 1190 fprintf(SAXdebug, "SAX.characters(%s, %d)\n", output, len); |
1191 } | 1191 } |
1192 | 1192 |
1193 /** | 1193 /** |
1194 * referenceDebug: | 1194 * referenceDebug: |
1195 * @ctxt: An XML parser context | 1195 * @ctxt: An XML parser context |
1196 * @name: The entity name | 1196 * @name: The entity name |
1197 * | 1197 * |
1198 * called when an entity reference is detected. | 1198 * called when an entity reference is detected. |
1199 */ | 1199 */ |
1200 static void | 1200 static void |
1201 referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) | 1201 referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) |
1202 { | 1202 { |
1203 callbacks++; | 1203 callbacks++; |
1204 if (quiet) | 1204 if (quiet) |
1205 return; | 1205 return; |
1206 fprintf(SAXdebug, "SAX.reference(%s)\n", name); | 1206 fprintf(SAXdebug, "SAX.reference(%s)\n", name); |
1207 } | 1207 } |
1208 | 1208 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 fprintf(SAXdebug, "SAX.startElementNs(%s", (char *) localname); | 1424 fprintf(SAXdebug, "SAX.startElementNs(%s", (char *) localname); |
1425 if (prefix == NULL) | 1425 if (prefix == NULL) |
1426 fprintf(SAXdebug, ", NULL"); | 1426 fprintf(SAXdebug, ", NULL"); |
1427 else | 1427 else |
1428 fprintf(SAXdebug, ", %s", (char *) prefix); | 1428 fprintf(SAXdebug, ", %s", (char *) prefix); |
1429 if (URI == NULL) | 1429 if (URI == NULL) |
1430 fprintf(SAXdebug, ", NULL"); | 1430 fprintf(SAXdebug, ", NULL"); |
1431 else | 1431 else |
1432 fprintf(SAXdebug, ", '%s'", (char *) URI); | 1432 fprintf(SAXdebug, ", '%s'", (char *) URI); |
1433 fprintf(SAXdebug, ", %d", nb_namespaces); | 1433 fprintf(SAXdebug, ", %d", nb_namespaces); |
1434 | 1434 |
1435 if (namespaces != NULL) { | 1435 if (namespaces != NULL) { |
1436 for (i = 0;i < nb_namespaces * 2;i++) { | 1436 for (i = 0;i < nb_namespaces * 2;i++) { |
1437 fprintf(SAXdebug, ", xmlns"); | 1437 fprintf(SAXdebug, ", xmlns"); |
1438 if (namespaces[i] != NULL) | 1438 if (namespaces[i] != NULL) |
1439 fprintf(SAXdebug, ":%s", namespaces[i]); | 1439 fprintf(SAXdebug, ":%s", namespaces[i]); |
1440 i++; | 1440 i++; |
1441 fprintf(SAXdebug, "='%s'", namespaces[i]); | 1441 fprintf(SAXdebug, "='%s'", namespaces[i]); |
1442 } | 1442 } |
1443 } | 1443 } |
1444 fprintf(SAXdebug, ", %d, %d", nb_attributes, nb_defaulted); | 1444 fprintf(SAXdebug, ", %d, %d", nb_attributes, nb_defaulted); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 ret = xmlSAXUserParseFile(debugSAX2Handler, NULL, filename); | 1697 ret = xmlSAXUserParseFile(debugSAX2Handler, NULL, filename); |
1698 } | 1698 } |
1699 if (ret == XML_WAR_UNDECLARED_ENTITY) { | 1699 if (ret == XML_WAR_UNDECLARED_ENTITY) { |
1700 fprintf(SAXdebug, "xmlSAXUserParseFile returned error %d\n", ret); | 1700 fprintf(SAXdebug, "xmlSAXUserParseFile returned error %d\n", ret); |
1701 ret = 0; | 1701 ret = 0; |
1702 } | 1702 } |
1703 fclose(SAXdebug); | 1703 fclose(SAXdebug); |
1704 if (compareFiles(temp, result)) { | 1704 if (compareFiles(temp, result)) { |
1705 fprintf(stderr, "Got a difference for %s\n", filename); | 1705 fprintf(stderr, "Got a difference for %s\n", filename); |
1706 ret = 1; | 1706 ret = 1; |
1707 } else | 1707 } |
1708 unlink(temp); | 1708 if (temp != NULL) { |
1709 free(temp); | 1709 unlink(temp); |
1710 | 1710 free(temp); |
| 1711 } |
| 1712 |
1711 /* switch back to structured error handling */ | 1713 /* switch back to structured error handling */ |
1712 xmlSetGenericErrorFunc(NULL, NULL); | 1714 xmlSetGenericErrorFunc(NULL, NULL); |
1713 xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); | 1715 xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); |
1714 | 1716 |
1715 return(ret); | 1717 return(ret); |
1716 } | 1718 } |
1717 #endif | 1719 #endif |
1718 | 1720 |
1719 /************************************************************************ | 1721 /************************************************************************ |
1720 * * | 1722 * * |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 doc = xmlReadFile(temp, NULL, 0); | 1774 doc = xmlReadFile(temp, NULL, 0); |
1773 #endif | 1775 #endif |
1774 if (doc == NULL) | 1776 if (doc == NULL) |
1775 return(1); | 1777 return(1); |
1776 xmlSaveFile(temp, doc); | 1778 xmlSaveFile(temp, doc); |
1777 if (compareFiles(temp, result)) { | 1779 if (compareFiles(temp, result)) { |
1778 res = 1; | 1780 res = 1; |
1779 } | 1781 } |
1780 xmlFreeDoc(doc); | 1782 xmlFreeDoc(doc); |
1781 | 1783 |
1782 unlink(temp); | 1784 if (temp != NULL) { |
1783 free(temp); | 1785 unlink(temp); |
| 1786 free(temp); |
| 1787 } |
1784 return(res); | 1788 return(res); |
1785 } | 1789 } |
1786 | 1790 |
1787 #ifdef LIBXML_PUSH_ENABLED | 1791 #ifdef LIBXML_PUSH_ENABLED |
1788 /** | 1792 /** |
1789 * pushParseTest: | 1793 * pushParseTest: |
1790 * @filename: the file to parse | 1794 * @filename: the file to parse |
1791 * @result: the file with expected result | 1795 * @result: the file with expected result |
1792 * @err: the file with error messages: unused | 1796 * @err: the file with error messages: unused |
1793 * | 1797 * |
(...skipping 13 matching lines...) Expand all Loading... |
1807 int cur = 0; | 1811 int cur = 0; |
1808 | 1812 |
1809 nb_tests++; | 1813 nb_tests++; |
1810 /* | 1814 /* |
1811 * load the document in memory and work from there. | 1815 * load the document in memory and work from there. |
1812 */ | 1816 */ |
1813 if (loadMem(filename, &base, &size) != 0) { | 1817 if (loadMem(filename, &base, &size) != 0) { |
1814 fprintf(stderr, "Failed to load %s\n", filename); | 1818 fprintf(stderr, "Failed to load %s\n", filename); |
1815 return(-1); | 1819 return(-1); |
1816 } | 1820 } |
1817 | 1821 |
1818 #ifdef LIBXML_HTML_ENABLED | 1822 #ifdef LIBXML_HTML_ENABLED |
1819 if (options & XML_PARSE_HTML) | 1823 if (options & XML_PARSE_HTML) |
1820 ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename, | 1824 ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename, |
1821 XML_CHAR_ENCODING_NONE); | 1825 XML_CHAR_ENCODING_NONE); |
1822 else | 1826 else |
1823 #endif | 1827 #endif |
1824 ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename); | 1828 ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename); |
1825 xmlCtxtUseOptions(ctxt, options); | 1829 xmlCtxtUseOptions(ctxt, options); |
1826 cur += 4; | 1830 cur += 4; |
1827 while (cur < size) { | 1831 while (cur < size) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 int size, res; | 1908 int size, res; |
1905 | 1909 |
1906 nb_tests++; | 1910 nb_tests++; |
1907 /* | 1911 /* |
1908 * load and parse the memory | 1912 * load and parse the memory |
1909 */ | 1913 */ |
1910 if (loadMem(filename, &base, &size) != 0) { | 1914 if (loadMem(filename, &base, &size) != 0) { |
1911 fprintf(stderr, "Failed to load %s\n", filename); | 1915 fprintf(stderr, "Failed to load %s\n", filename); |
1912 return(-1); | 1916 return(-1); |
1913 } | 1917 } |
1914 | 1918 |
1915 doc = xmlReadMemory(base, size, filename, NULL, 0); | 1919 doc = xmlReadMemory(base, size, filename, NULL, 0); |
1916 unloadMem(base); | 1920 unloadMem(base); |
1917 if (doc == NULL) { | 1921 if (doc == NULL) { |
1918 return(1); | 1922 return(1); |
1919 } | 1923 } |
1920 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); | 1924 xmlDocDumpMemory(doc, (xmlChar **) &base, &size); |
1921 xmlFreeDoc(doc); | 1925 xmlFreeDoc(doc); |
1922 res = compareFileMem(result, base, size); | 1926 res = compareFileMem(result, base, size); |
1923 if ((base == NULL) || (res != 0)) { | 1927 if ((base == NULL) || (res != 0)) { |
1924 if (base != NULL) | 1928 if (base != NULL) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 */ | 1977 */ |
1974 doc = xmlReadFile(filename, NULL, options); | 1978 doc = xmlReadFile(filename, NULL, options); |
1975 if (doc == NULL) | 1979 if (doc == NULL) |
1976 return(1); | 1980 return(1); |
1977 xmlSaveFile(temp, doc); | 1981 xmlSaveFile(temp, doc); |
1978 if (compareFiles(temp, result)) { | 1982 if (compareFiles(temp, result)) { |
1979 res = 1; | 1983 res = 1; |
1980 } | 1984 } |
1981 xmlFreeDoc(doc); | 1985 xmlFreeDoc(doc); |
1982 | 1986 |
1983 unlink(temp); | 1987 if (temp != NULL) { |
1984 free(temp); | 1988 unlink(temp); |
| 1989 free(temp); |
| 1990 } |
1985 return(res); | 1991 return(res); |
1986 } | 1992 } |
1987 | 1993 |
1988 /** | 1994 /** |
1989 * errParseTest: | 1995 * errParseTest: |
1990 * @filename: the file to parse | 1996 * @filename: the file to parse |
1991 * @result: the file with expected result | 1997 * @result: the file with expected result |
1992 * @err: the file with error messages | 1998 * @err: the file with error messages |
1993 * | 1999 * |
1994 * Parse a file using the xmlReadFile API and check for errors. | 2000 * Parse a file using the xmlReadFile API and check for errors. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 | 2075 |
2070 type = xmlTextReaderNodeType(reader); | 2076 type = xmlTextReaderNodeType(reader); |
2071 empty = xmlTextReaderIsEmptyElement(reader); | 2077 empty = xmlTextReaderIsEmptyElement(reader); |
2072 | 2078 |
2073 name = xmlTextReaderConstName(reader); | 2079 name = xmlTextReaderConstName(reader); |
2074 if (name == NULL) | 2080 if (name == NULL) |
2075 name = BAD_CAST "--"; | 2081 name = BAD_CAST "--"; |
2076 | 2082 |
2077 value = xmlTextReaderConstValue(reader); | 2083 value = xmlTextReaderConstValue(reader); |
2078 | 2084 |
2079 | 2085 |
2080 fprintf(out, "%d %d %s %d %d", | 2086 fprintf(out, "%d %d %s %d %d", |
2081 xmlTextReaderDepth(reader), | 2087 xmlTextReaderDepth(reader), |
2082 type, | 2088 type, |
2083 name, | 2089 name, |
2084 empty, | 2090 empty, |
2085 xmlTextReaderHasValue(reader)); | 2091 xmlTextReaderHasValue(reader)); |
2086 if (value == NULL) | 2092 if (value == NULL) |
2087 fprintf(out, "\n"); | 2093 fprintf(out, "\n"); |
2088 else { | 2094 else { |
2089 fprintf(out, " %s\n", value); | 2095 fprintf(out, " %s\n", value); |
2090 } | 2096 } |
(...skipping 22 matching lines...) Expand all Loading... |
2113 return(-1); | 2119 return(-1); |
2114 } | 2120 } |
2115 } | 2121 } |
2116 #ifdef LIBXML_SCHEMAS_ENABLED | 2122 #ifdef LIBXML_SCHEMAS_ENABLED |
2117 if (rng != NULL) { | 2123 if (rng != NULL) { |
2118 ret = xmlTextReaderRelaxNGValidate(reader, rng); | 2124 ret = xmlTextReaderRelaxNGValidate(reader, rng); |
2119 if (ret < 0) { | 2125 if (ret < 0) { |
2120 testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n", | 2126 testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n", |
2121 rng); | 2127 rng); |
2122 fclose(t); | 2128 fclose(t); |
2123 » unlink(temp); | 2129 if (temp != NULL) { |
2124 » free(temp); | 2130 unlink(temp); |
| 2131 free(temp); |
| 2132 } |
2125 return(0); | 2133 return(0); |
2126 } | 2134 } |
2127 } | 2135 } |
2128 #endif | 2136 #endif |
2129 xmlGetWarningsDefaultValue = 1; | 2137 xmlGetWarningsDefaultValue = 1; |
2130 ret = xmlTextReaderRead(reader); | 2138 ret = xmlTextReaderRead(reader); |
2131 while (ret == 1) { | 2139 while (ret == 1) { |
2132 if ((t != NULL) && (rng == NULL)) | 2140 if ((t != NULL) && (rng == NULL)) |
2133 processNode(t, reader); | 2141 processNode(t, reader); |
2134 ret = xmlTextReaderRead(reader); | 2142 ret = xmlTextReaderRead(reader); |
2135 } | 2143 } |
2136 if (ret != 0) { | 2144 if (ret != 0) { |
2137 testErrorHandler(NULL, "%s : failed to parse\n", filename); | 2145 testErrorHandler(NULL, "%s : failed to parse\n", filename); |
2138 } | 2146 } |
2139 if (rng != NULL) { | 2147 if (rng != NULL) { |
2140 if (xmlTextReaderIsValid(reader) != 1) { | 2148 if (xmlTextReaderIsValid(reader) != 1) { |
2141 testErrorHandler(NULL, "%s fails to validate\n", filename); | 2149 testErrorHandler(NULL, "%s fails to validate\n", filename); |
2142 } else { | 2150 } else { |
2143 testErrorHandler(NULL, "%s validates\n", filename); | 2151 testErrorHandler(NULL, "%s validates\n", filename); |
2144 } | 2152 } |
2145 } | 2153 } |
2146 xmlGetWarningsDefaultValue = 0; | 2154 xmlGetWarningsDefaultValue = 0; |
2147 if (t != NULL) { | 2155 if (t != NULL) { |
2148 fclose(t); | 2156 fclose(t); |
2149 ret = compareFiles(temp, result); | 2157 ret = compareFiles(temp, result); |
2150 » unlink(temp); | 2158 if (temp != NULL) { |
2151 » free(temp); | 2159 unlink(temp); |
| 2160 free(temp); |
| 2161 } |
2152 if (ret) { | 2162 if (ret) { |
2153 fprintf(stderr, "Result for %s failed\n", filename); | 2163 fprintf(stderr, "Result for %s failed\n", filename); |
2154 return(-1); | 2164 return(-1); |
2155 } | 2165 } |
2156 } | 2166 } |
2157 if (err != NULL) { | 2167 if (err != NULL) { |
2158 ret = compareFileMem(err, testErrors, testErrorsSize); | 2168 ret = compareFileMem(err, testErrors, testErrorsSize); |
2159 if (ret != 0) { | 2169 if (ret != 0) { |
2160 fprintf(stderr, "Error for %s failed\n", filename); | 2170 fprintf(stderr, "Error for %s failed\n", filename); |
2161 printf("%s", testErrors); | 2171 printf("%s", testErrors); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2258 * * | 2268 * * |
2259 ************************************************************************/ | 2269 ************************************************************************/ |
2260 | 2270 |
2261 static FILE *xpathOutput; | 2271 static FILE *xpathOutput; |
2262 static xmlDocPtr xpathDocument; | 2272 static xmlDocPtr xpathDocument; |
2263 | 2273 |
2264 static void | 2274 static void |
2265 testXPath(const char *str, int xptr, int expr) { | 2275 testXPath(const char *str, int xptr, int expr) { |
2266 xmlXPathObjectPtr res; | 2276 xmlXPathObjectPtr res; |
2267 xmlXPathContextPtr ctxt; | 2277 xmlXPathContextPtr ctxt; |
2268 | 2278 |
2269 nb_tests++; | 2279 nb_tests++; |
2270 #if defined(LIBXML_XPTR_ENABLED) | 2280 #if defined(LIBXML_XPTR_ENABLED) |
2271 if (xptr) { | 2281 if (xptr) { |
2272 ctxt = xmlXPtrNewContext(xpathDocument, NULL, NULL); | 2282 ctxt = xmlXPtrNewContext(xpathDocument, NULL, NULL); |
2273 res = xmlXPtrEval(BAD_CAST str, ctxt); | 2283 res = xmlXPtrEval(BAD_CAST str, ctxt); |
2274 } else { | 2284 } else { |
2275 #endif | 2285 #endif |
2276 ctxt = xmlXPathNewContext(xpathDocument); | 2286 ctxt = xmlXPathNewContext(xpathDocument); |
2277 ctxt->node = xmlDocGetRootElement(xpathDocument); | 2287 ctxt->node = xmlDocGetRootElement(xpathDocument); |
2278 if (expr) | 2288 if (expr) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2329 input = fopen(filename, "rb"); | 2339 input = fopen(filename, "rb"); |
2330 if (input == NULL) { | 2340 if (input == NULL) { |
2331 xmlGenericError(xmlGenericErrorContext, | 2341 xmlGenericError(xmlGenericErrorContext, |
2332 "Cannot open %s for reading\n", filename); | 2342 "Cannot open %s for reading\n", filename); |
2333 free(temp); | 2343 free(temp); |
2334 return(-1); | 2344 return(-1); |
2335 } | 2345 } |
2336 while (fgets(expression, 4500, input) != NULL) { | 2346 while (fgets(expression, 4500, input) != NULL) { |
2337 len = strlen(expression); | 2347 len = strlen(expression); |
2338 len--; | 2348 len--; |
2339 » while ((len >= 0) && | 2349 » while ((len >= 0) && |
2340 ((expression[len] == '\n') || (expression[len] == '\t') || | 2350 ((expression[len] == '\n') || (expression[len] == '\t') || |
2341 (expression[len] == '\r') || (expression[len] == ' '))) len--; | 2351 (expression[len] == '\r') || (expression[len] == ' '))) len--; |
2342 » expression[len + 1] = 0; | 2352 » expression[len + 1] = 0; |
2343 if (len >= 0) { | 2353 if (len >= 0) { |
2344 fprintf(xpathOutput, | 2354 fprintf(xpathOutput, |
2345 "\n========================\nExpression: %s\n", | 2355 "\n========================\nExpression: %s\n", |
2346 expression) ; | 2356 expression) ; |
2347 testXPath(expression, xptr, expr); | 2357 testXPath(expression, xptr, expr); |
2348 } | 2358 } |
2349 } | 2359 } |
2350 | 2360 |
2351 fclose(input); | 2361 fclose(input); |
2352 fclose(xpathOutput); | 2362 fclose(xpathOutput); |
2353 if (result != NULL) { | 2363 if (result != NULL) { |
2354 ret = compareFiles(temp, result); | 2364 ret = compareFiles(temp, result); |
2355 if (ret) { | 2365 if (ret) { |
2356 fprintf(stderr, "Result for %s failed\n", filename); | 2366 fprintf(stderr, "Result for %s failed\n", filename); |
2357 } | 2367 } |
2358 } | 2368 } |
2359 | 2369 |
2360 unlink(temp); | 2370 if (temp != NULL) { |
2361 free(temp); | 2371 unlink(temp); |
| 2372 free(temp); |
| 2373 } |
2362 return(ret); | 2374 return(ret); |
2363 } | 2375 } |
2364 | 2376 |
2365 /** | 2377 /** |
2366 * xpathExprTest: | 2378 * xpathExprTest: |
2367 * @filename: the file to parse | 2379 * @filename: the file to parse |
2368 * @result: the file with expected result | 2380 * @result: the file with expected result |
2369 * @err: the file with error messages | 2381 * @err: the file with error messages |
2370 * | 2382 * |
2371 * Parse a file containing XPath standalone expressions and evaluate them | 2383 * Parse a file containing XPath standalone expressions and evaluate them |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 | 2532 |
2521 fclose(xpathOutput); | 2533 fclose(xpathOutput); |
2522 if (result != NULL) { | 2534 if (result != NULL) { |
2523 ret = compareFiles(temp, result); | 2535 ret = compareFiles(temp, result); |
2524 if (ret) { | 2536 if (ret) { |
2525 fprintf(stderr, "Result for %s failed\n", filename); | 2537 fprintf(stderr, "Result for %s failed\n", filename); |
2526 res = 1; | 2538 res = 1; |
2527 } | 2539 } |
2528 } | 2540 } |
2529 | 2541 |
2530 unlink(temp); | 2542 if (temp != NULL) { |
2531 free(temp); | 2543 unlink(temp); |
| 2544 free(temp); |
| 2545 } |
2532 xmlFreeDoc(xpathDocument); | 2546 xmlFreeDoc(xpathDocument); |
2533 | 2547 |
2534 if (err != NULL) { | 2548 if (err != NULL) { |
2535 ret = compareFileMem(err, testErrors, testErrorsSize); | 2549 ret = compareFileMem(err, testErrors, testErrorsSize); |
2536 if (ret != 0) { | 2550 if (ret != 0) { |
2537 fprintf(stderr, "Error for %s failed\n", filename); | 2551 fprintf(stderr, "Error for %s failed\n", filename); |
2538 res = 1; | 2552 res = 1; |
2539 } | 2553 } |
2540 } | 2554 } |
2541 return(res); | 2555 return(res); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2607 o = fopen(temp, "wb"); | 2621 o = fopen(temp, "wb"); |
2608 if (o == NULL) { | 2622 if (o == NULL) { |
2609 fprintf(stderr, "failed to open output file %s\n", temp); | 2623 fprintf(stderr, "failed to open output file %s\n", temp); |
2610 free(temp); | 2624 free(temp); |
2611 return(-1); | 2625 return(-1); |
2612 } | 2626 } |
2613 f = fopen(filename, "rb"); | 2627 f = fopen(filename, "rb"); |
2614 if (f == NULL) { | 2628 if (f == NULL) { |
2615 fprintf(stderr, "failed to open input file %s\n", filename); | 2629 fprintf(stderr, "failed to open input file %s\n", filename); |
2616 fclose(o); | 2630 fclose(o); |
2617 » unlink(temp); | 2631 if (temp != NULL) { |
2618 free(temp); | 2632 unlink(temp); |
| 2633 free(temp); |
| 2634 } |
2619 return(-1); | 2635 return(-1); |
2620 } | 2636 } |
2621 | 2637 |
2622 while (1) { | 2638 while (1) { |
2623 /* | 2639 /* |
2624 * read one line in string buffer. | 2640 * read one line in string buffer. |
2625 */ | 2641 */ |
2626 if (fgets (&str[0], sizeof (str) - 1, f) == NULL) | 2642 if (fgets (&str[0], sizeof (str) - 1, f) == NULL) |
2627 break; | 2643 break; |
2628 | 2644 |
(...skipping 22 matching lines...) Expand all Loading... |
2651 } | 2667 } |
2652 } | 2668 } |
2653 if (err != NULL) { | 2669 if (err != NULL) { |
2654 ret = compareFileMem(err, testErrors, testErrorsSize); | 2670 ret = compareFileMem(err, testErrors, testErrorsSize); |
2655 if (ret != 0) { | 2671 if (ret != 0) { |
2656 fprintf(stderr, "Error for %s failed\n", filename); | 2672 fprintf(stderr, "Error for %s failed\n", filename); |
2657 res = 1; | 2673 res = 1; |
2658 } | 2674 } |
2659 } | 2675 } |
2660 | 2676 |
2661 unlink(temp); | 2677 if (temp != NULL) { |
2662 free(temp); | 2678 unlink(temp); |
| 2679 free(temp); |
| 2680 } |
2663 return(res); | 2681 return(res); |
2664 } | 2682 } |
2665 | 2683 |
2666 /** | 2684 /** |
2667 * uriParseTest: | 2685 * uriParseTest: |
2668 * @filename: the file to parse | 2686 * @filename: the file to parse |
2669 * @result: the file with expected result | 2687 * @result: the file with expected result |
2670 * @err: the file with error messages | 2688 * @err: the file with error messages |
2671 * | 2689 * |
2672 * Parse a file containing URI and check for errors | 2690 * Parse a file containing URI and check for errors |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 fprintf(schemasOutput, "%s validation generated an internal error\n", | 2944 fprintf(schemasOutput, "%s validation generated an internal error\n", |
2927 filename); | 2945 filename); |
2928 } | 2946 } |
2929 fclose(schemasOutput); | 2947 fclose(schemasOutput); |
2930 if (result) { | 2948 if (result) { |
2931 if (compareFiles(temp, result)) { | 2949 if (compareFiles(temp, result)) { |
2932 fprintf(stderr, "Result for %s on %s failed\n", filename, sch); | 2950 fprintf(stderr, "Result for %s on %s failed\n", filename, sch); |
2933 ret = 1; | 2951 ret = 1; |
2934 } | 2952 } |
2935 } | 2953 } |
2936 unlink(temp); | 2954 if (temp != NULL) { |
2937 free(temp); | 2955 unlink(temp); |
| 2956 free(temp); |
| 2957 } |
2938 | 2958 |
2939 if ((validResult != 0) && (err != NULL)) { | 2959 if ((validResult != 0) && (err != NULL)) { |
2940 if (compareFileMem(err, testErrors, testErrorsSize)) { | 2960 if (compareFileMem(err, testErrors, testErrorsSize)) { |
2941 fprintf(stderr, "Error for %s on %s failed\n", filename, sch); | 2961 fprintf(stderr, "Error for %s on %s failed\n", filename, sch); |
2942 ret = 1; | 2962 ret = 1; |
2943 } | 2963 } |
2944 } | 2964 } |
2945 | 2965 |
2946 xmlSchemaFreeValidCtxt(ctxt); | 2966 xmlSchemaFreeValidCtxt(ctxt); |
2947 xmlFreeDoc(doc); | 2967 xmlFreeDoc(doc); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3093 ret = xmlRelaxNGValidateDoc(ctxt, doc); | 3113 ret = xmlRelaxNGValidateDoc(ctxt, doc); |
3094 if (ret == 0) { | 3114 if (ret == 0) { |
3095 testErrorHandler(NULL, "%s validates\n", filename); | 3115 testErrorHandler(NULL, "%s validates\n", filename); |
3096 } else if (ret > 0) { | 3116 } else if (ret > 0) { |
3097 testErrorHandler(NULL, "%s fails to validate\n", filename); | 3117 testErrorHandler(NULL, "%s fails to validate\n", filename); |
3098 } else { | 3118 } else { |
3099 testErrorHandler(NULL, "%s validation generated an internal error\n", | 3119 testErrorHandler(NULL, "%s validation generated an internal error\n", |
3100 filename); | 3120 filename); |
3101 } | 3121 } |
3102 fclose(schemasOutput); | 3122 fclose(schemasOutput); |
| 3123 ret = 0; |
3103 if (result) { | 3124 if (result) { |
3104 if (compareFiles(temp, result)) { | 3125 if (compareFiles(temp, result)) { |
3105 fprintf(stderr, "Result for %s on %s failed\n", filename, sch); | 3126 fprintf(stderr, "Result for %s on %s failed\n", filename, sch); |
3106 ret = 1; | 3127 ret = 1; |
3107 } | 3128 } |
3108 } | 3129 } |
3109 unlink(temp); | 3130 if (temp != NULL) { |
3110 free(temp); | 3131 unlink(temp); |
| 3132 free(temp); |
| 3133 } |
3111 | 3134 |
3112 if (err != NULL) { | 3135 if (err != NULL) { |
3113 if (compareFileMem(err, testErrors, testErrorsSize)) { | 3136 if (compareFileMem(err, testErrors, testErrorsSize)) { |
3114 fprintf(stderr, "Error for %s on %s failed\n", filename, sch); | 3137 fprintf(stderr, "Error for %s on %s failed\n", filename, sch); |
3115 ret = 1; | 3138 ret = 1; |
3116 printf("%s", testErrors); | 3139 printf("%s", testErrors); |
3117 } | 3140 } |
3118 } | 3141 } |
3119 | 3142 |
3120 | 3143 |
(...skipping 14 matching lines...) Expand all Loading... |
3135 static int | 3158 static int |
3136 rngTest(const char *filename, | 3159 rngTest(const char *filename, |
3137 const char *resul ATTRIBUTE_UNUSED, | 3160 const char *resul ATTRIBUTE_UNUSED, |
3138 const char *errr ATTRIBUTE_UNUSED, | 3161 const char *errr ATTRIBUTE_UNUSED, |
3139 int options) { | 3162 int options) { |
3140 const char *base = baseFilename(filename); | 3163 const char *base = baseFilename(filename); |
3141 const char *base2; | 3164 const char *base2; |
3142 const char *instance; | 3165 const char *instance; |
3143 xmlRelaxNGParserCtxtPtr ctxt; | 3166 xmlRelaxNGParserCtxtPtr ctxt; |
3144 xmlRelaxNGPtr schemas; | 3167 xmlRelaxNGPtr schemas; |
3145 int res = 0, len, ret; | 3168 int res = 0, len, ret = 0; |
3146 char pattern[500]; | 3169 char pattern[500]; |
3147 char prefix[500]; | 3170 char prefix[500]; |
3148 char result[500]; | 3171 char result[500]; |
3149 char err[500]; | 3172 char err[500]; |
3150 glob_t globbuf; | 3173 glob_t globbuf; |
3151 size_t i; | 3174 size_t i; |
3152 char count = 0; | 3175 char count = 0; |
3153 | 3176 |
3154 /* first compile the schemas if possible */ | 3177 /* first compile the schemas if possible */ |
3155 ctxt = xmlRelaxNGNewParserCtxt(filename); | 3178 ctxt = xmlRelaxNGNewParserCtxt(filename); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3200 nb_tests++; | 3223 nb_tests++; |
3201 ret = rngOneTest(filename, instance, result, err, | 3224 ret = rngOneTest(filename, instance, result, err, |
3202 options, schemas); | 3225 options, schemas); |
3203 if (res != 0) | 3226 if (res != 0) |
3204 ret = res; | 3227 ret = res; |
3205 } | 3228 } |
3206 } | 3229 } |
3207 globfree(&globbuf); | 3230 globfree(&globbuf); |
3208 xmlRelaxNGFree(schemas); | 3231 xmlRelaxNGFree(schemas); |
3209 | 3232 |
3210 return(res); | 3233 return(ret); |
3211 } | 3234 } |
3212 | 3235 |
3213 #ifdef LIBXML_READER_ENABLED | 3236 #ifdef LIBXML_READER_ENABLED |
3214 /** | 3237 /** |
3215 * rngStreamTest: | 3238 * rngStreamTest: |
3216 * @filename: the schemas file | 3239 * @filename: the schemas file |
3217 * @result: the file with expected result | 3240 * @result: the file with expected result |
3218 * @err: the file with error messages | 3241 * @err: the file with error messages |
3219 * | 3242 * |
3220 * Parse a set of files with streaming, applying an RNG schemas | 3243 * Parse a set of files with streaming, applying an RNG schemas |
3221 * | 3244 * |
3222 * Returns 0 in case of success, an error code otherwise | 3245 * Returns 0 in case of success, an error code otherwise |
3223 */ | 3246 */ |
3224 static int | 3247 static int |
3225 rngStreamTest(const char *filename, | 3248 rngStreamTest(const char *filename, |
3226 const char *resul ATTRIBUTE_UNUSED, | 3249 const char *resul ATTRIBUTE_UNUSED, |
3227 const char *errr ATTRIBUTE_UNUSED, | 3250 const char *errr ATTRIBUTE_UNUSED, |
3228 int options) { | 3251 int options) { |
3229 const char *base = baseFilename(filename); | 3252 const char *base = baseFilename(filename); |
3230 const char *base2; | 3253 const char *base2; |
(...skipping 19 matching lines...) Expand all Loading... |
3250 } | 3273 } |
3251 len -= 4; /* remove trailing .rng */ | 3274 len -= 4; /* remove trailing .rng */ |
3252 memcpy(prefix, base, len); | 3275 memcpy(prefix, base, len); |
3253 prefix[len] = 0; | 3276 prefix[len] = 0; |
3254 | 3277 |
3255 /* | 3278 /* |
3256 * strictly unifying the error messages is nearly impossible this | 3279 * strictly unifying the error messages is nearly impossible this |
3257 * hack is also done in the Makefile | 3280 * hack is also done in the Makefile |
3258 */ | 3281 */ |
3259 if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) || | 3282 if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) || |
3260 (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377"))) | 3283 (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")) || |
| 3284 (!strcmp(prefix, "tutor8_2"))) |
3261 disable_err = 1; | 3285 disable_err = 1; |
3262 | 3286 |
3263 snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix); | 3287 snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix); |
3264 pattern[499] = 0; | 3288 pattern[499] = 0; |
3265 | 3289 |
3266 globbuf.gl_offs = 0; | 3290 globbuf.gl_offs = 0; |
3267 glob(pattern, GLOB_DOOFFS, NULL, &globbuf); | 3291 glob(pattern, GLOB_DOOFFS, NULL, &globbuf); |
3268 for (i = 0;i < globbuf.gl_pathc;i++) { | 3292 for (i = 0;i < globbuf.gl_pathc;i++) { |
3269 testErrorsSize = 0; | 3293 testErrorsSize = 0; |
3270 testErrors[0] = 0; | 3294 testErrors[0] = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 ************************************************************************/ | 3338 ************************************************************************/ |
3315 static void patternNode(FILE *out, xmlTextReaderPtr reader, | 3339 static void patternNode(FILE *out, xmlTextReaderPtr reader, |
3316 const char *pattern, xmlPatternPtr patternc, | 3340 const char *pattern, xmlPatternPtr patternc, |
3317 xmlStreamCtxtPtr patstream) { | 3341 xmlStreamCtxtPtr patstream) { |
3318 xmlChar *path = NULL; | 3342 xmlChar *path = NULL; |
3319 int match = -1; | 3343 int match = -1; |
3320 int type, empty; | 3344 int type, empty; |
3321 | 3345 |
3322 type = xmlTextReaderNodeType(reader); | 3346 type = xmlTextReaderNodeType(reader); |
3323 empty = xmlTextReaderIsEmptyElement(reader); | 3347 empty = xmlTextReaderIsEmptyElement(reader); |
3324 » | 3348 |
3325 if (type == XML_READER_TYPE_ELEMENT) { | 3349 if (type == XML_READER_TYPE_ELEMENT) { |
3326 /* do the check only on element start */ | 3350 /* do the check only on element start */ |
3327 match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); | 3351 match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); |
3328 | 3352 |
3329 if (match) { | 3353 if (match) { |
3330 path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); | 3354 path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); |
3331 fprintf(out, "Node %s matches pattern %s\n", path, pattern); | 3355 fprintf(out, "Node %s matches pattern %s\n", path, pattern); |
3332 } | 3356 } |
3333 } | 3357 } |
3334 if (patstream != NULL) { | 3358 if (patstream != NULL) { |
(...skipping 11 matching lines...) Expand all Loading... |
3346 if (path == NULL) { | 3370 if (path == NULL) { |
3347 path = xmlGetNodePath( | 3371 path = xmlGetNodePath( |
3348 xmlTextReaderCurrentNode(reader)); | 3372 xmlTextReaderCurrentNode(reader)); |
3349 } | 3373 } |
3350 fprintf(out, | 3374 fprintf(out, |
3351 "xmlPatternMatch and xmlStreamPush disagree\n"); | 3375 "xmlPatternMatch and xmlStreamPush disagree\n"); |
3352 fprintf(out, | 3376 fprintf(out, |
3353 " pattern %s node %s\n", | 3377 " pattern %s node %s\n", |
3354 pattern, path); | 3378 pattern, path); |
3355 } | 3379 } |
3356 | |
3357 | 3380 |
3358 » } | 3381 |
| 3382 » } |
3359 if ((type == XML_READER_TYPE_END_ELEMENT) || | 3383 if ((type == XML_READER_TYPE_END_ELEMENT) || |
3360 ((type == XML_READER_TYPE_ELEMENT) && (empty))) { | 3384 ((type == XML_READER_TYPE_ELEMENT) && (empty))) { |
3361 ret = xmlStreamPop(patstream); | 3385 ret = xmlStreamPop(patstream); |
3362 if (ret < 0) { | 3386 if (ret < 0) { |
3363 fprintf(out, "xmlStreamPop() failure\n"); | 3387 fprintf(out, "xmlStreamPop() failure\n"); |
3364 xmlFreeStreamCtxt(patstream); | 3388 xmlFreeStreamCtxt(patstream); |
3365 patstream = NULL; | 3389 patstream = NULL; |
3366 } | 3390 } |
3367 } | 3391 } |
3368 } | 3392 } |
3369 if (path != NULL) | 3393 if (path != NULL) |
3370 xmlFree(path); | 3394 xmlFree(path); |
3371 } | 3395 } |
3372 | 3396 |
3373 /** | 3397 /** |
3374 * patternTest: | 3398 * patternTest: |
3375 * @filename: the schemas file | 3399 * @filename: the schemas file |
3376 * @result: the file with expected result | 3400 * @result: the file with expected result |
3377 * @err: the file with error messages | 3401 * @err: the file with error messages |
3378 * | 3402 * |
3379 * Parse a set of files with streaming, applying an RNG schemas | 3403 * Parse a set of files with streaming, applying an RNG schemas |
3380 * | 3404 * |
3381 * Returns 0 in case of success, an error code otherwise | 3405 * Returns 0 in case of success, an error code otherwise |
3382 */ | 3406 */ |
3383 static int | 3407 static int |
3384 patternTest(const char *filename, | 3408 patternTest(const char *filename, |
3385 const char *resul ATTRIBUTE_UNUSED, | 3409 const char *resul ATTRIBUTE_UNUSED, |
3386 const char *err ATTRIBUTE_UNUSED, | 3410 const char *err ATTRIBUTE_UNUSED, |
3387 int options) { | 3411 int options) { |
3388 xmlPatternPtr patternc = NULL; | 3412 xmlPatternPtr patternc = NULL; |
3389 xmlStreamCtxtPtr patstream = NULL; | 3413 xmlStreamCtxtPtr patstream = NULL; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3456 const xmlChar *namespaces[22]; | 3480 const xmlChar *namespaces[22]; |
3457 int j; | 3481 int j; |
3458 xmlNsPtr ns; | 3482 xmlNsPtr ns; |
3459 | 3483 |
3460 root = xmlDocGetRootElement(doc); | 3484 root = xmlDocGetRootElement(doc); |
3461 for (ns = root->nsDef, j = 0;ns != NULL && j < 20;ns=ns->next) { | 3485 for (ns = root->nsDef, j = 0;ns != NULL && j < 20;ns=ns->next) { |
3462 namespaces[j++] = ns->href; | 3486 namespaces[j++] = ns->href; |
3463 namespaces[j++] = ns->prefix; | 3487 namespaces[j++] = ns->prefix; |
3464 } | 3488 } |
3465 namespaces[j++] = NULL; | 3489 namespaces[j++] = NULL; |
3466 » namespaces[j++] = NULL; | 3490 » namespaces[j] = NULL; |
3467 | 3491 |
3468 patternc = xmlPatterncompile((const xmlChar *) str, doc->dict, | 3492 patternc = xmlPatterncompile((const xmlChar *) str, doc->dict, |
3469 0, &namespaces[0]); | 3493 0, &namespaces[0]); |
3470 if (patternc == NULL) { | 3494 if (patternc == NULL) { |
3471 testErrorHandler(NULL, | 3495 testErrorHandler(NULL, |
3472 "Pattern %s failed to compile\n", str); | 3496 "Pattern %s failed to compile\n", str); |
3473 xmlFreeDoc(doc); | 3497 xmlFreeDoc(doc); |
3474 ret = 1; | 3498 ret = 1; |
3475 continue; | 3499 continue; |
3476 } | 3500 } |
(...skipping 27 matching lines...) Expand all Loading... |
3504 } | 3528 } |
3505 | 3529 |
3506 fclose(f); | 3530 fclose(f); |
3507 fclose(o); | 3531 fclose(o); |
3508 | 3532 |
3509 ret = compareFiles(temp, result); | 3533 ret = compareFiles(temp, result); |
3510 if (ret) { | 3534 if (ret) { |
3511 fprintf(stderr, "Result for %s failed\n", filename); | 3535 fprintf(stderr, "Result for %s failed\n", filename); |
3512 ret = 1; | 3536 ret = 1; |
3513 } | 3537 } |
3514 unlink(temp); | 3538 if (temp != NULL) { |
3515 free(temp); | 3539 unlink(temp); |
| 3540 free(temp); |
| 3541 } |
3516 return(ret); | 3542 return(ret); |
3517 } | 3543 } |
3518 #endif /* READER */ | 3544 #endif /* READER */ |
3519 #endif /* PATTERN */ | 3545 #endif /* PATTERN */ |
3520 #ifdef LIBXML_C14N_ENABLED | 3546 #ifdef LIBXML_C14N_ENABLED |
3521 /************************************************************************ | 3547 /************************************************************************ |
3522 * * | 3548 * * |
3523 * Canonicalization tests * | 3549 * Canonicalization tests * |
3524 * * | 3550 * * |
3525 ************************************************************************/ | 3551 ************************************************************************/ |
3526 static xmlXPathObjectPtr | 3552 static xmlXPathObjectPtr |
3527 load_xpath_expr (xmlDocPtr parent_doc, const char* filename) { | 3553 load_xpath_expr (xmlDocPtr parent_doc, const char* filename) { |
3528 xmlXPathObjectPtr xpath; | 3554 xmlXPathObjectPtr xpath; |
3529 xmlDocPtr doc; | 3555 xmlDocPtr doc; |
3530 xmlChar *expr; | 3556 xmlChar *expr; |
3531 xmlXPathContextPtr ctx; | 3557 xmlXPathContextPtr ctx; |
3532 xmlNodePtr node; | 3558 xmlNodePtr node; |
3533 xmlNsPtr ns; | 3559 xmlNsPtr ns; |
3534 | 3560 |
3535 /* | 3561 /* |
3536 * load XPath expr as a file | 3562 * load XPath expr as a file |
3537 */ | 3563 */ |
3538 xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; | 3564 xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; |
3539 xmlSubstituteEntitiesDefault(1); | 3565 xmlSubstituteEntitiesDefault(1); |
3540 | 3566 |
3541 doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); | 3567 doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); |
3542 if (doc == NULL) { | 3568 if (doc == NULL) { |
3543 fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); | 3569 fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); |
3544 return(NULL); | 3570 return(NULL); |
3545 } | 3571 } |
3546 | 3572 |
3547 /* | 3573 /* |
3548 * Check the document is of the right kind | 3574 * Check the document is of the right kind |
3549 */ | 3575 */ |
3550 if(xmlDocGetRootElement(doc) == NULL) { | 3576 if(xmlDocGetRootElement(doc) == NULL) { |
3551 fprintf(stderr,"Error: empty document for file \"%s\"\n", filename); | 3577 fprintf(stderr,"Error: empty document for file \"%s\"\n", filename); |
3552 xmlFreeDoc(doc); | 3578 xmlFreeDoc(doc); |
3553 return(NULL); | 3579 return(NULL); |
3554 } | 3580 } |
3555 | 3581 |
3556 node = doc->children; | 3582 node = doc->children; |
3557 while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) { | 3583 while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) { |
3558 node = node->next; | 3584 node = node->next; |
3559 } | 3585 } |
3560 | 3586 |
3561 if(node == NULL) { | 3587 if(node == NULL) { |
3562 fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", fi
lename); | 3588 fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", fi
lename); |
3563 xmlFreeDoc(doc); | 3589 xmlFreeDoc(doc); |
3564 return(NULL); | 3590 return(NULL); |
3565 } | 3591 } |
3566 | 3592 |
3567 expr = xmlNodeGetContent(node); | 3593 expr = xmlNodeGetContent(node); |
3568 if(expr == NULL) { | 3594 if(expr == NULL) { |
3569 fprintf(stderr,"Error: XPath content element is NULL \"%s\"\n", filename
); | 3595 fprintf(stderr,"Error: XPath content element is NULL \"%s\"\n", filename
); |
3570 xmlFreeDoc(doc); | 3596 xmlFreeDoc(doc); |
3571 return(NULL); | 3597 return(NULL); |
3572 } | 3598 } |
3573 | 3599 |
3574 ctx = xmlXPathNewContext(parent_doc); | 3600 ctx = xmlXPathNewContext(parent_doc); |
3575 if(ctx == NULL) { | 3601 if(ctx == NULL) { |
3576 fprintf(stderr,"Error: unable to create new context\n"); | 3602 fprintf(stderr,"Error: unable to create new context\n"); |
3577 xmlFree(expr); | 3603 xmlFree(expr); |
3578 xmlFreeDoc(doc); | 3604 xmlFreeDoc(doc); |
3579 return(NULL); | 3605 return(NULL); |
3580 } | 3606 } |
3581 | 3607 |
3582 /* | 3608 /* |
3583 * Register namespaces | 3609 * Register namespaces |
3584 */ | 3610 */ |
3585 ns = node->nsDef; | 3611 ns = node->nsDef; |
3586 while(ns != NULL) { | 3612 while(ns != NULL) { |
3587 if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) { | 3613 if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) { |
3588 fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and
href=\"%s\"\n", ns->prefix, ns->href); | 3614 fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and
href=\"%s\"\n", ns->prefix, ns->href); |
3589 » xmlFree(expr); | 3615 xmlFree(expr); |
3590 » xmlXPathFreeContext(ctx); | 3616 » xmlXPathFreeContext(ctx); |
3591 » xmlFreeDoc(doc); | 3617 » xmlFreeDoc(doc); |
3592 return(NULL); | 3618 return(NULL); |
3593 } | 3619 } |
3594 ns = ns->next; | 3620 ns = ns->next; |
3595 } | 3621 } |
3596 | 3622 |
3597 /* | 3623 /* |
3598 * Evaluate xpath | 3624 * Evaluate xpath |
3599 */ | 3625 */ |
3600 xpath = xmlXPathEvalExpression(expr, ctx); | 3626 xpath = xmlXPathEvalExpression(expr, ctx); |
3601 if(xpath == NULL) { | 3627 if(xpath == NULL) { |
3602 fprintf(stderr,"Error: unable to evaluate xpath expression\n"); | 3628 fprintf(stderr,"Error: unable to evaluate xpath expression\n"); |
3603 » xmlFree(expr); | 3629 xmlFree(expr); |
3604 xmlXPathFreeContext(ctx); | 3630 xmlXPathFreeContext(ctx); |
3605 xmlFreeDoc(doc); | 3631 xmlFreeDoc(doc); |
3606 return(NULL); | 3632 return(NULL); |
3607 } | 3633 } |
3608 | 3634 |
3609 /* print_xpath_nodes(xpath->nodesetval); */ | 3635 /* print_xpath_nodes(xpath->nodesetval); */ |
3610 | 3636 |
3611 xmlFree(expr); | 3637 xmlFree(expr); |
3612 xmlXPathFreeContext(ctx); | 3638 xmlXPathFreeContext(ctx); |
3613 xmlFreeDoc(doc); | 3639 xmlFreeDoc(doc); |
3614 return(xpath); | 3640 return(xpath); |
3615 } | 3641 } |
3616 | 3642 |
3617 /* | 3643 /* |
3618 * Macro used to grow the current buffer. | 3644 * Macro used to grow the current buffer. |
3619 */ | 3645 */ |
3620 #define xxx_growBufferReentrant() {
\ | 3646 #define xxx_growBufferReentrant() {
\ |
3621 buffer_size *= 2; \ | 3647 buffer_size *= 2; \ |
3622 buffer = (xmlChar **) \ | 3648 buffer = (xmlChar **) \ |
3623 » » xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));» \ | 3649 » xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));» \ |
3624 if (buffer == NULL) { \ | 3650 if (buffer == NULL) { \ |
3625 perror("realloc failed"); \ | 3651 perror("realloc failed"); \ |
3626 return(NULL); \ | 3652 return(NULL); \ |
3627 } \ | 3653 } \ |
3628 } | 3654 } |
3629 | 3655 |
3630 static xmlChar ** | 3656 static xmlChar ** |
3631 parse_list(xmlChar *str) { | 3657 parse_list(xmlChar *str) { |
3632 xmlChar **buffer; | 3658 xmlChar **buffer; |
3633 xmlChar **out = NULL; | 3659 xmlChar **out = NULL; |
3634 int buffer_size = 0; | 3660 int buffer_size = 0; |
3635 int len; | 3661 int len; |
3636 | 3662 |
3637 if(str == NULL) { | 3663 if(str == NULL) { |
3638 return(NULL); | 3664 return(NULL); |
3639 } | 3665 } |
3640 | 3666 |
3641 len = xmlStrlen(str); | 3667 len = xmlStrlen(str); |
3642 if((str[0] == '\'') && (str[len - 1] == '\'')) { | 3668 if((str[0] == '\'') && (str[len - 1] == '\'')) { |
3643 str[len - 1] = '\0'; | 3669 str[len - 1] = '\0'; |
3644 str++; | 3670 str++; |
3645 len -= 2; | |
3646 } | 3671 } |
3647 /* | 3672 /* |
3648 * allocate an translation buffer. | 3673 * allocate an translation buffer. |
3649 */ | 3674 */ |
3650 buffer_size = 1000; | 3675 buffer_size = 1000; |
3651 buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*)); | 3676 buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*)); |
3652 if (buffer == NULL) { | 3677 if (buffer == NULL) { |
3653 perror("malloc failed"); | 3678 perror("malloc failed"); |
3654 return(NULL); | 3679 return(NULL); |
3655 } | 3680 } |
3656 out = buffer; | 3681 out = buffer; |
3657 | 3682 |
3658 while(*str != '\0') { | 3683 while(*str != '\0') { |
3659 if (out - buffer > buffer_size - 10) { | 3684 if (out - buffer > buffer_size - 10) { |
3660 int indx = out - buffer; | 3685 int indx = out - buffer; |
3661 | 3686 |
3662 xxx_growBufferReentrant(); | 3687 xxx_growBufferReentrant(); |
3663 out = &buffer[indx]; | 3688 out = &buffer[indx]; |
3664 } | 3689 } |
3665 (*out++) = str; | 3690 (*out++) = str; |
3666 while(*str != ',' && *str != '\0') ++str; | 3691 while(*str != ',' && *str != '\0') ++str; |
3667 if(*str == ',') *(str++) = '\0'; | 3692 if(*str == ',') *(str++) = '\0'; |
3668 } | 3693 } |
3669 (*out) = NULL; | 3694 (*out) = NULL; |
3670 return buffer; | 3695 return buffer; |
3671 } | 3696 } |
3672 | 3697 |
3673 static int | 3698 static int |
3674 c14nRunTest(const char* xml_filename, int with_comments, int exclusive, | 3699 c14nRunTest(const char* xml_filename, int with_comments, int mode, |
3675 const char* xpath_filename, const char *ns_filename, | 3700 const char* xpath_filename, const char *ns_filename, |
3676 const char* result_file) { | 3701 const char* result_file) { |
3677 xmlDocPtr doc; | 3702 xmlDocPtr doc; |
3678 xmlXPathObjectPtr xpath = NULL; | 3703 xmlXPathObjectPtr xpath = NULL; |
3679 xmlChar *result = NULL; | 3704 xmlChar *result = NULL; |
3680 int ret; | 3705 int ret; |
3681 xmlChar **inclusive_namespaces = NULL; | 3706 xmlChar **inclusive_namespaces = NULL; |
3682 const char *nslist = NULL; | 3707 const char *nslist = NULL; |
3683 int nssize; | 3708 int nssize; |
3684 | 3709 |
3685 | 3710 |
3686 /* | 3711 /* |
3687 * build an XML tree from a the file; we need to add default | 3712 * build an XML tree from a the file; we need to add default |
3688 * attributes and resolve all character and entities references | 3713 * attributes and resolve all character and entities references |
3689 */ | 3714 */ |
3690 xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; | 3715 xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; |
3691 xmlSubstituteEntitiesDefault(1); | 3716 xmlSubstituteEntitiesDefault(1); |
3692 | 3717 |
3693 doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); | 3718 doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); |
3694 if (doc == NULL) { | 3719 if (doc == NULL) { |
3695 fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename); | 3720 fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename); |
3696 return(-1); | 3721 return(-1); |
3697 } | 3722 } |
3698 | 3723 |
3699 /* | 3724 /* |
3700 * Check the document is of the right kind | 3725 * Check the document is of the right kind |
3701 */ | 3726 */ |
3702 if(xmlDocGetRootElement(doc) == NULL) { | 3727 if(xmlDocGetRootElement(doc) == NULL) { |
3703 fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename); | 3728 fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename); |
3704 xmlFreeDoc(doc); | 3729 xmlFreeDoc(doc); |
3705 return(-1); | 3730 return(-1); |
3706 } | 3731 } |
3707 | 3732 |
3708 /* | 3733 /* |
3709 * load xpath file if specified | 3734 * load xpath file if specified |
3710 */ | 3735 */ |
3711 if(xpath_filename) { | 3736 if(xpath_filename) { |
3712 xpath = load_xpath_expr(doc, xpath_filename); | 3737 xpath = load_xpath_expr(doc, xpath_filename); |
3713 if(xpath == NULL) { | 3738 if(xpath == NULL) { |
3714 fprintf(stderr,"Error: unable to evaluate xpath expression\n"); | 3739 fprintf(stderr,"Error: unable to evaluate xpath expression\n"); |
3715 » xmlFreeDoc(doc); | 3740 » xmlFreeDoc(doc); |
3716 return(-1); | 3741 return(-1); |
3717 } | 3742 } |
3718 } | 3743 } |
3719 | 3744 |
3720 if (ns_filename != NULL) { | 3745 if (ns_filename != NULL) { |
3721 if (loadMem(ns_filename, &nslist, &nssize)) { | 3746 if (loadMem(ns_filename, &nslist, &nssize)) { |
3722 fprintf(stderr,"Error: unable to evaluate xpath expression\n"); | 3747 fprintf(stderr,"Error: unable to evaluate xpath expression\n"); |
3723 if(xpath != NULL) xmlXPathFreeObject(xpath); | 3748 if(xpath != NULL) xmlXPathFreeObject(xpath); |
3724 » xmlFreeDoc(doc); | 3749 » xmlFreeDoc(doc); |
3725 return(-1); | 3750 return(-1); |
3726 } | 3751 } |
3727 inclusive_namespaces = parse_list((xmlChar *) nslist); | 3752 inclusive_namespaces = parse_list((xmlChar *) nslist); |
3728 } | 3753 } |
3729 | 3754 |
3730 /* | 3755 /* |
3731 * Canonical form | 3756 * Canonical form |
3732 */ | 3757 */ |
3733 /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename);
*/ | 3758 /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename);
*/ |
3734 ret = xmlC14NDocDumpMemory(doc, | 3759 ret = xmlC14NDocDumpMemory(doc, |
3735 » (xpath) ? xpath->nodesetval : NULL, | 3760 » (xpath) ? xpath->nodesetval : NULL, |
3736 » exclusive, inclusive_namespaces, | 3761 » mode, inclusive_namespaces, |
3737 with_comments, &result); | 3762 with_comments, &result); |
3738 if (ret >= 0) { | 3763 if (ret >= 0) { |
3739 if(result != NULL) { | 3764 if(result != NULL) { |
3740 if (compareFileMem(result_file, (const char *) result, ret)) { | 3765 if (compareFileMem(result_file, (const char *) result, ret)) { |
3741 fprintf(stderr, "Result mismatch for %s\n", xml_filename); | 3766 fprintf(stderr, "Result mismatch for %s\n", xml_filename); |
| 3767 fprintf(stderr, "RESULT:\n%s\n", (const char*)result); |
3742 ret = -1; | 3768 ret = -1; |
3743 } | 3769 } |
3744 } | 3770 } |
3745 } else { | 3771 } else { |
3746 fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n
", xml_filename, ret); | 3772 fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n
", xml_filename, ret); |
3747 ret = -1; | 3773 ret = -1; |
3748 } | 3774 } |
3749 | 3775 |
3750 /* | 3776 /* |
3751 * Cleanup | 3777 * Cleanup |
3752 */ | 3778 */ |
3753 if (result != NULL) xmlFree(result); | 3779 if (result != NULL) xmlFree(result); |
3754 if(xpath != NULL) xmlXPathFreeObject(xpath); | 3780 if(xpath != NULL) xmlXPathFreeObject(xpath); |
3755 if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces); | 3781 if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces); |
3756 if (nslist != NULL) free((char *) nslist); | 3782 if (nslist != NULL) free((char *) nslist); |
3757 xmlFreeDoc(doc); | 3783 xmlFreeDoc(doc); |
3758 | 3784 |
3759 return(ret); | 3785 return(ret); |
3760 } | 3786 } |
3761 | 3787 |
3762 static int | 3788 static int |
3763 c14nCommonTest(const char *filename, int with_comments, int exclusive, | 3789 c14nCommonTest(const char *filename, int with_comments, int mode, |
3764 const char *subdir) { | 3790 const char *subdir) { |
3765 char buf[500]; | 3791 char buf[500]; |
3766 char prefix[500]; | 3792 char prefix[500]; |
3767 const char *base; | 3793 const char *base; |
3768 int len; | 3794 int len; |
3769 char *result = NULL; | 3795 char *result = NULL; |
3770 char *xpath = NULL; | 3796 char *xpath = NULL; |
3771 char *ns = NULL; | 3797 char *ns = NULL; |
3772 int ret = 0; | 3798 int ret = 0; |
3773 | 3799 |
(...skipping 12 matching lines...) Expand all Loading... |
3786 snprintf(buf, 499, "test/c14n/%s/%s.xpath", subdir,prefix); | 3812 snprintf(buf, 499, "test/c14n/%s/%s.xpath", subdir,prefix); |
3787 if (checkTestFile(buf)) { | 3813 if (checkTestFile(buf)) { |
3788 xpath = strdup(buf); | 3814 xpath = strdup(buf); |
3789 } | 3815 } |
3790 snprintf(buf, 499, "test/c14n/%s/%s.ns", subdir,prefix); | 3816 snprintf(buf, 499, "test/c14n/%s/%s.ns", subdir,prefix); |
3791 if (checkTestFile(buf)) { | 3817 if (checkTestFile(buf)) { |
3792 ns = strdup(buf); | 3818 ns = strdup(buf); |
3793 } | 3819 } |
3794 | 3820 |
3795 nb_tests++; | 3821 nb_tests++; |
3796 if (c14nRunTest(filename, with_comments, exclusive, | 3822 if (c14nRunTest(filename, with_comments, mode, |
3797 xpath, ns, result) < 0) | 3823 xpath, ns, result) < 0) |
3798 ret = 1; | 3824 ret = 1; |
3799 | 3825 |
3800 if (result != NULL) free(result); | 3826 if (result != NULL) free(result); |
3801 if (xpath != NULL) free(xpath); | 3827 if (xpath != NULL) free(xpath); |
3802 if (ns != NULL) free(ns); | 3828 if (ns != NULL) free(ns); |
3803 return(ret); | 3829 return(ret); |
3804 } | 3830 } |
3805 | 3831 |
3806 static int | 3832 static int |
3807 c14nWithCommentTest(const char *filename, | 3833 c14nWithCommentTest(const char *filename, |
3808 const char *resul ATTRIBUTE_UNUSED, | 3834 const char *resul ATTRIBUTE_UNUSED, |
3809 const char *err ATTRIBUTE_UNUSED, | 3835 const char *err ATTRIBUTE_UNUSED, |
3810 int options ATTRIBUTE_UNUSED) { | 3836 int options ATTRIBUTE_UNUSED) { |
3811 return(c14nCommonTest(filename, 1, 0, "with-comments")); | 3837 return(c14nCommonTest(filename, 1, XML_C14N_1_0, "with-comments")); |
3812 } | 3838 } |
3813 static int | 3839 static int |
3814 c14nWithoutCommentTest(const char *filename, | 3840 c14nWithoutCommentTest(const char *filename, |
3815 const char *resul ATTRIBUTE_UNUSED, | 3841 const char *resul ATTRIBUTE_UNUSED, |
3816 const char *err ATTRIBUTE_UNUSED, | 3842 const char *err ATTRIBUTE_UNUSED, |
3817 int options ATTRIBUTE_UNUSED) { | 3843 int options ATTRIBUTE_UNUSED) { |
3818 return(c14nCommonTest(filename, 0, 0, "without-comments")); | 3844 return(c14nCommonTest(filename, 0, XML_C14N_1_0, "without-comments")); |
3819 } | 3845 } |
3820 static int | 3846 static int |
3821 c14nExcWithoutCommentTest(const char *filename, | 3847 c14nExcWithoutCommentTest(const char *filename, |
3822 const char *resul ATTRIBUTE_UNUSED, | 3848 const char *resul ATTRIBUTE_UNUSED, |
3823 const char *err ATTRIBUTE_UNUSED, | 3849 const char *err ATTRIBUTE_UNUSED, |
3824 int options ATTRIBUTE_UNUSED) { | 3850 int options ATTRIBUTE_UNUSED) { |
3825 return(c14nCommonTest(filename, 0, 1, "exc-without-comments")); | 3851 return(c14nCommonTest(filename, 0, XML_C14N_EXCLUSIVE_1_0, "exc-without-comm
ents")); |
| 3852 } |
| 3853 static int |
| 3854 c14n11WithoutCommentTest(const char *filename, |
| 3855 const char *resul ATTRIBUTE_UNUSED, |
| 3856 » » const char *err ATTRIBUTE_UNUSED, |
| 3857 » » int options ATTRIBUTE_UNUSED) { |
| 3858 return(c14nCommonTest(filename, 0, XML_C14N_1_1, "1-1-without-comments")); |
3826 } | 3859 } |
3827 #endif | 3860 #endif |
3828 #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined
(LIBXML_SAX1_ENABLED) | 3861 #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined
(LIBXML_SAX1_ENABLED) |
3829 /************************************************************************ | 3862 /************************************************************************ |
3830 * * | 3863 * * |
3831 * Catalog and threads test * | 3864 * Catalog and threads test * |
3832 * * | 3865 * * |
3833 ************************************************************************/ | 3866 ************************************************************************/ |
3834 | 3867 |
3835 /* | 3868 /* |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3896 if (xmlGenericErrorContext != stderr) { | 3929 if (xmlGenericErrorContext != stderr) { |
3897 printf("xmlGenericErrorContext override failed\n"); | 3930 printf("xmlGenericErrorContext override failed\n"); |
3898 okay = 0; | 3931 okay = 0; |
3899 } | 3932 } |
3900 } | 3933 } |
3901 if (okay == 0) | 3934 if (okay == 0) |
3902 return ((void *) Failed); | 3935 return ((void *) Failed); |
3903 return ((void *) Okay); | 3936 return ((void *) Okay); |
3904 } | 3937 } |
3905 | 3938 |
3906 #if defined(linux) || defined(solaris) | 3939 #if defined(linux) || defined(__sun) || defined(__APPLE_CC__) |
3907 | 3940 |
3908 #include <pthread.h> | 3941 #include <pthread.h> |
3909 | 3942 |
3910 static pthread_t tid[MAX_ARGC]; | 3943 static pthread_t tid[MAX_ARGC]; |
3911 | 3944 |
3912 static int | 3945 static int |
3913 testThread(void) | 3946 testThread(void) |
3914 { | 3947 { |
3915 unsigned int i, repeat; | 3948 unsigned int i, repeat; |
3916 unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]); | 3949 unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]); |
3917 void *results[MAX_ARGC]; | 3950 void *results[MAX_ARGC]; |
3918 int ret; | 3951 int ret; |
3919 int res = 0; | 3952 int res = 0; |
3920 | 3953 |
3921 xmlInitParser(); | 3954 xmlInitParser(); |
3922 | 3955 |
3923 for (repeat = 0; repeat < 500; repeat++) { | 3956 for (repeat = 0; repeat < 500; repeat++) { |
3924 xmlLoadCatalog(catalog); | 3957 xmlLoadCatalog(catalog); |
3925 nb_tests++; | 3958 nb_tests++; |
3926 | 3959 |
3927 for (i = 0; i < num_threads; i++) { | 3960 for (i = 0; i < num_threads; i++) { |
3928 results[i] = NULL; | 3961 results[i] = NULL; |
3929 tid[i] = (pthread_t) - 1; | 3962 tid[i] = (pthread_t) - 1; |
3930 } | 3963 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3986 | 4019 |
3987 for (i = 0; i < num_threads; i++) { | 4020 for (i = 0; i < num_threads; i++) { |
3988 results[i] = 0; | 4021 results[i] = 0; |
3989 tid[i] = (HANDLE) - 1; | 4022 tid[i] = (HANDLE) - 1; |
3990 } | 4023 } |
3991 | 4024 |
3992 for (i = 0; i < num_threads; i++) { | 4025 for (i = 0; i < num_threads; i++) { |
3993 DWORD useless; | 4026 DWORD useless; |
3994 | 4027 |
3995 tid[i] = CreateThread(NULL, 0, | 4028 tid[i] = CreateThread(NULL, 0, |
3996 win32_thread_specific_data, | 4029 win32_thread_specific_data, |
3997 (void *) testfiles[i], 0, | 4030 (void *) testfiles[i], 0, |
3998 &useless); | 4031 &useless); |
3999 if (tid[i] == NULL) { | 4032 if (tid[i] == NULL) { |
4000 fprintf(stderr, "CreateThread failed\n"); | 4033 fprintf(stderr, "CreateThread failed\n"); |
4001 return(1); | 4034 return(1); |
4002 } | 4035 } |
4003 } | 4036 } |
4004 | 4037 |
4005 if (WaitForMultipleObjects(num_threads, tid, TRUE, INFINITE) == | 4038 if (WaitForMultipleObjects(num_threads, tid, TRUE, INFINITE) == |
4006 WAIT_FAILED) { | 4039 WAIT_FAILED) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4084 } | 4117 } |
4085 #else | 4118 #else |
4086 static int | 4119 static int |
4087 testThread(void) | 4120 testThread(void) |
4088 { | 4121 { |
4089 fprintf(stderr, | 4122 fprintf(stderr, |
4090 "Specific platform thread support not detected\n"); | 4123 "Specific platform thread support not detected\n"); |
4091 return (-1); | 4124 return (-1); |
4092 } | 4125 } |
4093 #endif | 4126 #endif |
4094 static int | 4127 static int |
4095 threadsTest(const char *filename ATTRIBUTE_UNUSED, | 4128 threadsTest(const char *filename ATTRIBUTE_UNUSED, |
4096 const char *resul ATTRIBUTE_UNUSED, | 4129 const char *resul ATTRIBUTE_UNUSED, |
4097 const char *err ATTRIBUTE_UNUSED, | 4130 const char *err ATTRIBUTE_UNUSED, |
4098 int options ATTRIBUTE_UNUSED) { | 4131 int options ATTRIBUTE_UNUSED) { |
4099 return(testThread()); | 4132 return(testThread()); |
4100 } | 4133 } |
4101 #endif | 4134 #endif |
4102 /************************************************************************ | 4135 /************************************************************************ |
4103 * * | 4136 * * |
4104 * Tests Descriptions * | 4137 * Tests Descriptions * |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4176 XML_PARSE_DTDVALID }, | 4209 XML_PARSE_DTDVALID }, |
4177 { "General documents valid regression tests" , | 4210 { "General documents valid regression tests" , |
4178 errParseTest, "./test/valid/*", "result/valid/", "", ".err", | 4211 errParseTest, "./test/valid/*", "result/valid/", "", ".err", |
4179 XML_PARSE_DTDVALID }, | 4212 XML_PARSE_DTDVALID }, |
4180 #endif | 4213 #endif |
4181 #ifdef LIBXML_XINCLUDE_ENABLED | 4214 #ifdef LIBXML_XINCLUDE_ENABLED |
4182 { "XInclude regression tests" , | 4215 { "XInclude regression tests" , |
4183 errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL, | 4216 errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL, |
4184 /* Ignore errors at this point ".err", */ | 4217 /* Ignore errors at this point ".err", */ |
4185 XML_PARSE_XINCLUDE }, | 4218 XML_PARSE_XINCLUDE }, |
| 4219 #ifdef LIBXML_READER_ENABLED |
4186 { "XInclude xmlReader regression tests", | 4220 { "XInclude xmlReader regression tests", |
4187 streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr", | 4221 streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr", |
4188 /* Ignore errors at this point ".err", */ | 4222 /* Ignore errors at this point ".err", */ |
4189 NULL, XML_PARSE_XINCLUDE }, | 4223 NULL, XML_PARSE_XINCLUDE }, |
| 4224 #endif |
4190 { "XInclude regression tests stripping include nodes" , | 4225 { "XInclude regression tests stripping include nodes" , |
4191 errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL, | 4226 errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL, |
4192 /* Ignore errors at this point ".err", */ | 4227 /* Ignore errors at this point ".err", */ |
4193 XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, | 4228 XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, |
| 4229 #ifdef LIBXML_READER_ENABLED |
4194 { "XInclude xmlReader regression tests stripping include nodes", | 4230 { "XInclude xmlReader regression tests stripping include nodes", |
4195 streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr", | 4231 streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr", |
4196 /* Ignore errors at this point ".err", */ | 4232 /* Ignore errors at this point ".err", */ |
4197 NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, | 4233 NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, |
4198 #endif | 4234 #endif |
| 4235 #endif |
4199 #ifdef LIBXML_XPATH_ENABLED | 4236 #ifdef LIBXML_XPATH_ENABLED |
4200 #ifdef LIBXML_DEBUG_ENABLED | 4237 #ifdef LIBXML_DEBUG_ENABLED |
4201 { "XPath expressions regression tests" , | 4238 { "XPath expressions regression tests" , |
4202 xpathExprTest, "./test/XPath/expr/*", "result/XPath/expr/", "", NULL, | 4239 xpathExprTest, "./test/XPath/expr/*", "result/XPath/expr/", "", NULL, |
4203 0 }, | 4240 0 }, |
4204 { "XPath document queries regression tests" , | 4241 { "XPath document queries regression tests" , |
4205 xpathDocTest, "./test/XPath/docs/*", NULL, NULL, NULL, | 4242 xpathDocTest, "./test/XPath/docs/*", NULL, NULL, NULL, |
4206 0 }, | 4243 0 }, |
4207 #ifdef LIBXML_XPTR_ENABLED | 4244 #ifdef LIBXML_XPTR_ENABLED |
4208 { "XPointer document queries regression tests" , | 4245 { "XPointer document queries regression tests" , |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4246 #ifdef LIBXML_C14N_ENABLED | 4283 #ifdef LIBXML_C14N_ENABLED |
4247 { "C14N with comments regression tests" , | 4284 { "C14N with comments regression tests" , |
4248 c14nWithCommentTest, "./test/c14n/with-comments/*.xml", NULL, NULL, NULL, | 4285 c14nWithCommentTest, "./test/c14n/with-comments/*.xml", NULL, NULL, NULL, |
4249 0 }, | 4286 0 }, |
4250 { "C14N without comments regression tests" , | 4287 { "C14N without comments regression tests" , |
4251 c14nWithoutCommentTest, "./test/c14n/without-comments/*.xml", NULL, NULL,
NULL, | 4288 c14nWithoutCommentTest, "./test/c14n/without-comments/*.xml", NULL, NULL,
NULL, |
4252 0 }, | 4289 0 }, |
4253 { "C14N exclusive without comments regression tests" , | 4290 { "C14N exclusive without comments regression tests" , |
4254 c14nExcWithoutCommentTest, "./test/c14n/exc-without-comments/*.xml", NULL,
NULL, NULL, | 4291 c14nExcWithoutCommentTest, "./test/c14n/exc-without-comments/*.xml", NULL,
NULL, NULL, |
4255 0 }, | 4292 0 }, |
| 4293 { "C14N 1.1 without comments regression tests" , |
| 4294 c14n11WithoutCommentTest, "./test/c14n/1-1-without-comments/*.xml", NULL,
NULL, NULL, |
| 4295 0 }, |
4256 #endif | 4296 #endif |
4257 #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined
(LIBXML_SAX1_ENABLED) | 4297 #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined
(LIBXML_SAX1_ENABLED) |
4258 { "Catalog and Threads regression tests" , | 4298 { "Catalog and Threads regression tests" , |
4259 threadsTest, NULL, NULL, NULL, NULL, | 4299 threadsTest, NULL, NULL, NULL, NULL, |
4260 0 }, | 4300 0 }, |
4261 #endif | 4301 #endif |
4262 {NULL, NULL, NULL, NULL, NULL, NULL, 0} | 4302 {NULL, NULL, NULL, NULL, NULL, NULL, 0} |
4263 }; | 4303 }; |
4264 | 4304 |
4265 /************************************************************************ | 4305 /************************************************************************ |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4381 return(ret); | 4421 return(ret); |
4382 } | 4422 } |
4383 | 4423 |
4384 int | 4424 int |
4385 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { | 4425 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
4386 int i, a, ret = 0; | 4426 int i, a, ret = 0; |
4387 int subset = 0; | 4427 int subset = 0; |
4388 | 4428 |
4389 initializeLibxml2(); | 4429 initializeLibxml2(); |
4390 | 4430 |
4391 | |
4392 for (a = 1; a < argc;a++) { | 4431 for (a = 1; a < argc;a++) { |
4393 if (!strcmp(argv[a], "-v")) | 4432 if (!strcmp(argv[a], "-v")) |
4394 verbose = 1; | 4433 verbose = 1; |
4395 else if (!strcmp(argv[a], "-quiet")) | 4434 else if (!strcmp(argv[a], "-quiet")) |
4396 tests_quiet = 1; | 4435 tests_quiet = 1; |
4397 else { | 4436 else { |
4398 for (i = 0; testDescriptions[i].func != NULL; i++) { | 4437 for (i = 0; testDescriptions[i].func != NULL; i++) { |
4399 if (strstr(testDescriptions[i].desc, argv[a])) { | 4438 if (strstr(testDescriptions[i].desc, argv[a])) { |
4400 ret += runtest(i); | 4439 ret += runtest(i); |
4401 subset++; | 4440 subset++; |
(...skipping 21 matching lines...) Expand all Loading... |
4423 return(ret); | 4462 return(ret); |
4424 } | 4463 } |
4425 | 4464 |
4426 #else /* ! LIBXML_OUTPUT_ENABLED */ | 4465 #else /* ! LIBXML_OUTPUT_ENABLED */ |
4427 int | 4466 int |
4428 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { | 4467 main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
4429 fprintf(stderr, "runtest requires output to be enabled in libxml2\n"); | 4468 fprintf(stderr, "runtest requires output to be enabled in libxml2\n"); |
4430 return(1); | 4469 return(1); |
4431 } | 4470 } |
4432 #endif | 4471 #endif |
OLD | NEW |