1
0
mirror of https://github.com/GNOME/libxml2.git synced 2025-05-09 13:21:24 +08:00

tests: Don't use deprecated symbols

This commit is contained in:
Nick Wellnhofer 2023-09-20 15:49:03 +02:00
parent 692a5c40ce
commit 209516acbf
7 changed files with 10 additions and 105 deletions

View File

@ -184,18 +184,11 @@ parseGjobFile(char *filename ATTRIBUTE_UNUSED) {
xmlNsPtr ns; xmlNsPtr ns;
xmlNodePtr cur; xmlNodePtr cur;
#ifdef LIBXML_SAX1_ENABLED
/* /*
* build an XML tree from a the file; * build an XML tree from a the file;
*/ */
doc = xmlParseFile(filename); doc = xmlReadFile(filename, NULL, XML_PARSE_NOBLANKS);
if (doc == NULL) return(NULL); if (doc == NULL) return(NULL);
#else
/*
* the library has been compiled without some of the old interfaces
*/
return(NULL);
#endif /* LIBXML_SAX1_ENABLED */
/* /*
* Check the document is of the right kind * Check the document is of the right kind
@ -291,7 +284,6 @@ int main(int argc, char **argv) {
/* COMPAT: Do not generate nodes for formatting spaces */ /* COMPAT: Do not generate nodes for formatting spaces */
LIBXML_TEST_VERSION LIBXML_TEST_VERSION
xmlKeepBlanksDefault(0);
for (i = 1; i < argc ; i++) { for (i = 1; i < argc ; i++) {
cur = parseGjobFile(argv[i]); cur = parseGjobFile(argv[i]);

View File

@ -201,9 +201,6 @@ static xmlXPathContextPtr ctxtXPath;
static void static void
initializeLibxml2(void) { initializeLibxml2(void) {
xmlGetWarningsDefaultValue = 0;
xmlPedanticParserDefault(0);
xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
xmlInitParser(); xmlInitParser();
xmlSetExternalEntityLoader(testExternalEntityLoader); xmlSetExternalEntityLoader(testExternalEntityLoader);

View File

@ -558,7 +558,6 @@ initializeLibxml2(void) {
xmlMemStrdup = NULL; xmlMemStrdup = NULL;
xmlInitParser(); xmlInitParser();
xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
xmlPedanticParserDefault(0);
xmlSetExternalEntityLoader(testExternalEntityLoader); xmlSetExternalEntityLoader(testExternalEntityLoader);
xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
#ifdef LIBXML_SCHEMAS_ENABLED #ifdef LIBXML_SCHEMAS_ENABLED
@ -4065,9 +4064,6 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
/* /*
* load XPath expr as a file * load XPath expr as a file
*/ */
xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
xmlSubstituteEntitiesDefault(1);
doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT);
if (doc == NULL) { if (doc == NULL) {
fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
@ -4216,9 +4212,6 @@ c14nRunTest(const char* xml_filename, int with_comments, int mode,
* build an XML tree from a the file; we need to add default * build an XML tree from a the file; we need to add default
* attributes and resolve all character and entities references * attributes and resolve all character and entities references
*/ */
xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
xmlSubstituteEntitiesDefault(1);
doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT);
if (doc == NULL) { if (doc == NULL) {
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename); fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
@ -4391,13 +4384,6 @@ static xmlThreadParams threadParams[] = {
static const unsigned int num_threads = sizeof(threadParams) / static const unsigned int num_threads = sizeof(threadParams) /
sizeof(threadParams[0]); sizeof(threadParams[0]);
#ifndef xmlDoValidityCheckingDefaultValue
#error xmlDoValidityCheckingDefaultValue is not a macro
#endif
#ifndef xmlGenericErrorContext
#error xmlGenericErrorContext is not a macro
#endif
static void * static void *
thread_specific_data(void *private_data) thread_specific_data(void *private_data)
{ {
@ -4406,43 +4392,13 @@ thread_specific_data(void *private_data)
const char *filename = params->filename; const char *filename = params->filename;
int okay = 1; int okay = 1;
if (!strcmp(filename, "test/threads/invalid.xml")) { myDoc = xmlReadFile(filename, NULL, XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
xmlDoValidityCheckingDefaultValue = 0;
xmlGenericErrorContext = stdout;
} else {
xmlDoValidityCheckingDefaultValue = 1;
xmlGenericErrorContext = stderr;
}
#ifdef LIBXML_SAX1_ENABLED
myDoc = xmlParseFile(filename);
#else
myDoc = xmlReadFile(filename, NULL, XML_WITH_CATALOG);
#endif
if (myDoc) { if (myDoc) {
xmlFreeDoc(myDoc); xmlFreeDoc(myDoc);
} else { } else {
printf("parse failed\n"); printf("parse failed\n");
okay = 0; okay = 0;
} }
if (!strcmp(filename, "test/threads/invalid.xml")) {
if (xmlDoValidityCheckingDefaultValue != 0) {
printf("ValidityCheckingDefaultValue override failed\n");
okay = 0;
}
if (xmlGenericErrorContext != stdout) {
printf("xmlGenericErrorContext override failed\n");
okay = 0;
}
} else {
if (xmlDoValidityCheckingDefaultValue != 1) {
printf("ValidityCheckingDefaultValue override failed\n");
okay = 0;
}
if (xmlGenericErrorContext != stderr) {
printf("xmlGenericErrorContext override failed\n");
okay = 0;
}
}
params->okay = okay; params->okay = okay;
return(NULL); return(NULL);
} }

View File

@ -148,9 +148,6 @@ static xmlXPathContextPtr ctxtXPath;
static void static void
initializeLibxml2(void) { initializeLibxml2(void) {
xmlGetWarningsDefaultValue = 0;
xmlPedanticParserDefault(0);
xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
xmlInitParser(); xmlInitParser();
xmlSetExternalEntityLoader(testExternalEntityLoader); xmlSetExternalEntityLoader(testExternalEntityLoader);
@ -252,8 +249,10 @@ xmlconfTestNotNSWF(const char *id, const char *filename, int options) {
nb_errors++; nb_errors++;
ret = 0; ret = 0;
} else { } else {
if ((xmlLastError.code == XML_ERR_OK) || xmlError *error = xmlGetLastError();
(xmlLastError.domain != XML_FROM_NAMESPACE)) {
if ((error->code == XML_ERR_OK) ||
(error->domain != XML_FROM_NAMESPACE)) {
test_log("test %s : %s failed to detect namespace error\n", test_log("test %s : %s failed to detect namespace error\n",
id, filename); id, filename);
nb_errors++; nb_errors++;

View File

@ -43,13 +43,6 @@ static xmlThreadParams threadParams[] = {
static const unsigned int num_threads = sizeof(threadParams) / static const unsigned int num_threads = sizeof(threadParams) /
sizeof(threadParams[0]); sizeof(threadParams[0]);
#ifndef xmlDoValidityCheckingDefaultValue
#error xmlDoValidityCheckingDefaultValue is not a macro
#endif
#ifndef xmlGenericErrorContext
#error xmlGenericErrorContext is not a macro
#endif
static void * static void *
thread_specific_data(void *private_data) thread_specific_data(void *private_data)
{ {
@ -57,6 +50,7 @@ thread_specific_data(void *private_data)
xmlThreadParams *params = (xmlThreadParams *) private_data; xmlThreadParams *params = (xmlThreadParams *) private_data;
const char *filename = params->filename; const char *filename = params->filename;
int okay = 1; int okay = 1;
int options = 0;
if (xmlCheckThreadLocalStorage() != 0) { if (xmlCheckThreadLocalStorage() != 0) {
printf("xmlCheckThreadLocalStorage failed\n"); printf("xmlCheckThreadLocalStorage failed\n");
@ -64,43 +58,16 @@ thread_specific_data(void *private_data)
return(NULL); return(NULL);
} }
if (!strcmp(filename, "test/threads/invalid.xml")) { if (strcmp(filename, "test/threads/invalid.xml") != 0) {
xmlDoValidityCheckingDefaultValue = 0; options |= XML_PARSE_DTDVALID;
xmlGenericErrorContext = stdout;
} else {
xmlDoValidityCheckingDefaultValue = 1;
xmlGenericErrorContext = stderr;
} }
#ifdef LIBXML_SAX1_ENABLED myDoc = xmlReadFile(filename, NULL, options);
myDoc = xmlParseFile(filename);
#else
myDoc = xmlReadFile(filename, NULL, XML_WITH_CATALOG);
#endif
if (myDoc) { if (myDoc) {
xmlFreeDoc(myDoc); xmlFreeDoc(myDoc);
} else { } else {
printf("parse failed\n"); printf("parse failed\n");
okay = 0; okay = 0;
} }
if (!strcmp(filename, "test/threads/invalid.xml")) {
if (xmlDoValidityCheckingDefaultValue != 0) {
printf("ValidityCheckingDefaultValue override failed\n");
okay = 0;
}
if (xmlGenericErrorContext != stdout) {
printf("xmlGenericErrorContext override failed\n");
okay = 0;
}
} else {
if (xmlDoValidityCheckingDefaultValue != 1) {
printf("ValidityCheckingDefaultValue override failed\n");
okay = 0;
}
if (xmlGenericErrorContext != stderr) {
printf("xmlGenericErrorContext override failed\n");
okay = 0;
}
}
params->okay = okay; params->okay = okay;
return(NULL); return(NULL);
} }

View File

@ -659,9 +659,6 @@ testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, xmlErrorPtr err) {
static void static void
initializeLibxml2(void) { initializeLibxml2(void) {
xmlGetWarningsDefaultValue = 0;
xmlPedanticParserDefault(0);
xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
xmlInitParser(); xmlInitParser();
xmlSetExternalEntityLoader(testExternalEntityLoader); xmlSetExternalEntityLoader(testExternalEntityLoader);

View File

@ -627,9 +627,6 @@ testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, xmlErrorPtr err) {
static void static void
initializeLibxml2(void) { initializeLibxml2(void) {
xmlGetWarningsDefaultValue = 0;
xmlPedanticParserDefault(0);
xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
xmlInitParser(); xmlInitParser();
xmlSetExternalEntityLoader(testExternalEntityLoader); xmlSetExternalEntityLoader(testExternalEntityLoader);