diff options
Diffstat (limited to 'third_party/libxml/testapi.c')
-rw-r--r-- | third_party/libxml/testapi.c | 540 |
1 files changed, 423 insertions, 117 deletions
diff --git a/third_party/libxml/testapi.c b/third_party/libxml/testapi.c index 8a50e88..da6ce1b 100644 --- a/third_party/libxml/testapi.c +++ b/third_party/libxml/testapi.c @@ -212,7 +212,7 @@ void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra); name resolution delays, so we use these */ #define REMOTE1GOOD "http://localhost/" -#define REMOTE1BAD "http://missing. example.org/" +#define REMOTE1BAD "http:http://http" #define REMOTE2GOOD "ftp://localhost/foo" #define gen_nb_void_ptr 2 @@ -494,10 +494,11 @@ static void des_xmlParserInputBufferPtr(int no ATTRIBUTE_UNUSED, xmlParserInputB xmlFreeParserInputBuffer(val); } -#define gen_nb_xmlDocPtr 3 +#define gen_nb_xmlDocPtr 4 static xmlDocPtr gen_xmlDocPtr(int no, int nr ATTRIBUTE_UNUSED) { if (no == 0) return(xmlNewDoc(BAD_CAST "1.0")); if (no == 1) return(xmlReadMemory("<foo/>", 6, "test", NULL, 0)); + if (no == 2) return(xmlReadMemory("<!DOCTYPE foo []> <foo/>", 24, "test", NULL, 0)); return(NULL); } static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val, int nr ATTRIBUTE_UNUSED) { @@ -598,9 +599,10 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val, #endif #define gen_nb_xmlBufferPtr 3 +static const char *static_buf_content = "a static buffer"; static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) { if (no == 0) return(xmlBufferCreate()); - if (no == 1) return(xmlBufferCreateStatic((void *)"a static buffer", 13)); + if (no == 1) return(xmlBufferCreateStatic((void *)static_buf_content, 13)); return(NULL); } static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) { @@ -720,6 +722,23 @@ static void des_xmlExpNodePtr(int no ATTRIBUTE_UNUSED, xmlExpNodePtr val ATTRIBU #endif +#if defined(LIBXML_SCHEMAS_ENABLED) +#define gen_nb_xmlSchemaPtr 1 +static xmlSchemaPtr gen_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, xmlSchemaPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlSchemaValidCtxtPtr 1 +static xmlSchemaValidCtxtPtr gen_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#endif /* LIBXML_SCHEMAS_ENABLED */ + #define gen_nb_xmlHashDeallocator 2 static void test_xmlHashDeallocator(void *payload ATTRIBUTE_UNUSED, xmlChar *name ATTRIBUTE_UNUSED) { @@ -972,6 +991,13 @@ static void des_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, xmlParserNodeIn static void desret_const_xmlParserNodeInfo_ptr(const xmlParserNodeInfo *val ATTRIBUTE_UNUSED) { } +#define gen_nb_void_ptr_ptr 1 +static void ** gen_void_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_void_ptr_ptr(int no ATTRIBUTE_UNUSED, void ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + /************************************************************************ * * * WARNING: end of the manually maintained part of the test code * @@ -1010,11 +1036,12 @@ static xmlAttributeType gen_xmlAttributeType(int no, int nr ATTRIBUTE_UNUSED) { static void des_xmlAttributeType(int no ATTRIBUTE_UNUSED, xmlAttributeType val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } -#define gen_nb_xmlBufferAllocationScheme 3 +#define gen_nb_xmlBufferAllocationScheme 4 static xmlBufferAllocationScheme gen_xmlBufferAllocationScheme(int no, int nr ATTRIBUTE_UNUSED) { if (no == 1) return(XML_BUFFER_ALLOC_DOUBLEIT); if (no == 2) return(XML_BUFFER_ALLOC_EXACT); if (no == 3) return(XML_BUFFER_ALLOC_IMMUTABLE); + if (no == 4) return(XML_BUFFER_ALLOC_IO); return(0); } @@ -5325,8 +5352,8 @@ test_xmlC14NDocDumpMemory(void) { int n_doc; xmlNodeSetPtr nodes; /* the nodes set to be included in the canonized image or NULL if all document nodes should be included */ int n_nodes; - int exclusive; /* the exclusive flag (0 - non-exclusive canonicalization; otherwise - exclusive canonicalization) */ - int n_exclusive; + int mode; /* the c14n mode (see @xmlC14NMode) */ + int n_mode; xmlChar ** inclusive_ns_prefixes; /* the list of inclusive namespace prefixes ended with a NULL or NULL if there is no inclusive namespaces (only for exclusive canonicalization, ignored otherwise) */ int n_inclusive_ns_prefixes; int with_comments; /* include comments in the result (!=0) or not (==0) */ @@ -5336,24 +5363,24 @@ test_xmlC14NDocDumpMemory(void) { for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { - for (n_exclusive = 0;n_exclusive < gen_nb_int;n_exclusive++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { for (n_inclusive_ns_prefixes = 0;n_inclusive_ns_prefixes < gen_nb_xmlChar_ptr_ptr;n_inclusive_ns_prefixes++) { for (n_with_comments = 0;n_with_comments < gen_nb_int;n_with_comments++) { for (n_doc_txt_ptr = 0;n_doc_txt_ptr < gen_nb_xmlChar_ptr_ptr;n_doc_txt_ptr++) { mem_base = xmlMemBlocks(); doc = gen_xmlDocPtr(n_doc, 0); nodes = gen_xmlNodeSetPtr(n_nodes, 1); - exclusive = gen_int(n_exclusive, 2); + mode = gen_int(n_mode, 2); inclusive_ns_prefixes = gen_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, 3); with_comments = gen_int(n_with_comments, 4); doc_txt_ptr = gen_xmlChar_ptr_ptr(n_doc_txt_ptr, 5); - ret_val = xmlC14NDocDumpMemory(doc, nodes, exclusive, inclusive_ns_prefixes, with_comments, doc_txt_ptr); + ret_val = xmlC14NDocDumpMemory(doc, nodes, mode, inclusive_ns_prefixes, with_comments, doc_txt_ptr); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNodeSetPtr(n_nodes, nodes, 1); - des_int(n_exclusive, exclusive, 2); + des_int(n_mode, mode, 2); des_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, inclusive_ns_prefixes, 3); des_int(n_with_comments, with_comments, 4); des_xmlChar_ptr_ptr(n_doc_txt_ptr, doc_txt_ptr, 5); @@ -5364,7 +5391,7 @@ test_xmlC14NDocDumpMemory(void) { test_ret++; printf(" %d", n_doc); printf(" %d", n_nodes); - printf(" %d", n_exclusive); + printf(" %d", n_mode); printf(" %d", n_inclusive_ns_prefixes); printf(" %d", n_with_comments); printf(" %d", n_doc_txt_ptr); @@ -5394,8 +5421,8 @@ test_xmlC14NDocSave(void) { int n_doc; xmlNodeSetPtr nodes; /* the nodes set to be included in the canonized image or NULL if all document nodes should be included */ int n_nodes; - int exclusive; /* the exclusive flag (0 - non-exclusive canonicalization; otherwise - exclusive canonicalization) */ - int n_exclusive; + int mode; /* the c14n mode (see @xmlC14NMode) */ + int n_mode; xmlChar ** inclusive_ns_prefixes; /* the list of inclusive namespace prefixes ended with a NULL or NULL if there is no inclusive namespaces (only for exclusive canonicalization, ignored otherwise) */ int n_inclusive_ns_prefixes; int with_comments; /* include comments in the result (!=0) or not (==0) */ @@ -5407,7 +5434,7 @@ test_xmlC14NDocSave(void) { for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { - for (n_exclusive = 0;n_exclusive < gen_nb_int;n_exclusive++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { for (n_inclusive_ns_prefixes = 0;n_inclusive_ns_prefixes < gen_nb_xmlChar_ptr_ptr;n_inclusive_ns_prefixes++) { for (n_with_comments = 0;n_with_comments < gen_nb_int;n_with_comments++) { for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { @@ -5415,18 +5442,18 @@ test_xmlC14NDocSave(void) { mem_base = xmlMemBlocks(); doc = gen_xmlDocPtr(n_doc, 0); nodes = gen_xmlNodeSetPtr(n_nodes, 1); - exclusive = gen_int(n_exclusive, 2); + mode = gen_int(n_mode, 2); inclusive_ns_prefixes = gen_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, 3); with_comments = gen_int(n_with_comments, 4); filename = gen_fileoutput(n_filename, 5); compression = gen_int(n_compression, 6); - ret_val = xmlC14NDocSave(doc, nodes, exclusive, inclusive_ns_prefixes, with_comments, filename, compression); + ret_val = xmlC14NDocSave(doc, nodes, mode, inclusive_ns_prefixes, with_comments, filename, compression); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNodeSetPtr(n_nodes, nodes, 1); - des_int(n_exclusive, exclusive, 2); + des_int(n_mode, mode, 2); des_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, inclusive_ns_prefixes, 3); des_int(n_with_comments, with_comments, 4); des_fileoutput(n_filename, filename, 5); @@ -5438,7 +5465,7 @@ test_xmlC14NDocSave(void) { test_ret++; printf(" %d", n_doc); printf(" %d", n_nodes); - printf(" %d", n_exclusive); + printf(" %d", n_mode); printf(" %d", n_inclusive_ns_prefixes); printf(" %d", n_with_comments); printf(" %d", n_filename); @@ -5470,8 +5497,8 @@ test_xmlC14NDocSaveTo(void) { int n_doc; xmlNodeSetPtr nodes; /* the nodes set to be included in the canonized image or NULL if all document nodes should be included */ int n_nodes; - int exclusive; /* the exclusive flag (0 - non-exclusive canonicalization; otherwise - exclusive canonicalization) */ - int n_exclusive; + int mode; /* the c14n mode (see @xmlC14NMode) */ + int n_mode; xmlChar ** inclusive_ns_prefixes; /* the list of inclusive namespace prefixes ended with a NULL or NULL if there is no inclusive namespaces (only for exclusive canonicalization, ignored otherwise) */ int n_inclusive_ns_prefixes; int with_comments; /* include comments in the result (!=0) or not (==0) */ @@ -5481,24 +5508,24 @@ test_xmlC14NDocSaveTo(void) { for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { - for (n_exclusive = 0;n_exclusive < gen_nb_int;n_exclusive++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { for (n_inclusive_ns_prefixes = 0;n_inclusive_ns_prefixes < gen_nb_xmlChar_ptr_ptr;n_inclusive_ns_prefixes++) { for (n_with_comments = 0;n_with_comments < gen_nb_int;n_with_comments++) { for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { mem_base = xmlMemBlocks(); doc = gen_xmlDocPtr(n_doc, 0); nodes = gen_xmlNodeSetPtr(n_nodes, 1); - exclusive = gen_int(n_exclusive, 2); + mode = gen_int(n_mode, 2); inclusive_ns_prefixes = gen_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, 3); with_comments = gen_int(n_with_comments, 4); buf = gen_xmlOutputBufferPtr(n_buf, 5); - ret_val = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes, with_comments, buf); + ret_val = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes, with_comments, buf); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNodeSetPtr(n_nodes, nodes, 1); - des_int(n_exclusive, exclusive, 2); + des_int(n_mode, mode, 2); des_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, inclusive_ns_prefixes, 3); des_int(n_with_comments, with_comments, 4); des_xmlOutputBufferPtr(n_buf, buf, 5); @@ -5509,7 +5536,7 @@ test_xmlC14NDocSaveTo(void) { test_ret++; printf(" %d", n_doc); printf(" %d", n_nodes); - printf(" %d", n_exclusive); + printf(" %d", n_mode); printf(" %d", n_inclusive_ns_prefixes); printf(" %d", n_with_comments); printf(" %d", n_buf); @@ -6164,7 +6191,6 @@ test_xmlCatalogResolve(void) { int test_ret = 0; #if defined(LIBXML_CATALOG_ENABLED) - int mem_base; xmlChar * ret_val; xmlChar * pubID; /* the public ID string */ int n_pubID; @@ -6173,7 +6199,6 @@ test_xmlCatalogResolve(void) { for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { - mem_base = xmlMemBlocks(); pubID = gen_const_xmlChar_ptr(n_pubID, 0); sysID = gen_const_xmlChar_ptr(n_sysID, 1); @@ -6183,14 +6208,6 @@ test_xmlCatalogResolve(void) { des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 0); des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 1); xmlResetLastError(); - if (mem_base != xmlMemBlocks()) { - printf("Leak of %d blocks found in xmlCatalogResolve", - xmlMemBlocks() - mem_base); - test_ret++; - printf(" %d", n_pubID); - printf(" %d", n_sysID); - printf("\n"); - } } } function_tests++; @@ -9607,11 +9624,78 @@ test_xmlInitializePredefinedEntities(void) { return(test_ret); } + +static int +test_xmlNewEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + int type; /* the entity type XML_xxx_yyy_ENTITY */ + int n_type; + xmlChar * ExternalID; /* the entity external ID if available */ + int n_ExternalID; + xmlChar * SystemID; /* the entity system ID if available */ + int n_SystemID; + xmlChar * content; /* the entity content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_int(n_type, 2); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 3); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); + content = gen_const_xmlChar_ptr(n_content, 5); + + ret_val = xmlNewEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_type, type, 2); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + static int test_entities(void) { int test_ret = 0; - if (quiet == 0) printf("Testing entities : 12 of 16 functions ...\n"); + if (quiet == 0) printf("Testing entities : 13 of 17 functions ...\n"); test_ret += test_xmlAddDocEntity(); test_ret += test_xmlAddDtdEntity(); test_ret += test_xmlCleanupPredefinedEntities(); @@ -9626,6 +9710,7 @@ test_entities(void) { test_ret += test_xmlGetParameterEntity(); test_ret += test_xmlGetPredefinedEntity(); test_ret += test_xmlInitializePredefinedEntities(); + test_ret += test_xmlNewEntity(); if (test_ret != 0) printf("Module entities: %d errors\n", test_ret); @@ -13136,7 +13221,6 @@ test_xmlIOParseDTD(void) { #if defined(LIBXML_VALID_ENABLED) #ifdef LIBXML_VALID_ENABLED - int mem_base; xmlDtdPtr ret_val; xmlSAXHandlerPtr sax; /* the SAX handler block or NULL */ int n_sax; @@ -13148,7 +13232,6 @@ test_xmlIOParseDTD(void) { for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { - mem_base = xmlMemBlocks(); sax = gen_xmlSAXHandlerPtr(n_sax, 0); input = gen_xmlParserInputBufferPtr(n_input, 1); enc = gen_xmlCharEncoding(n_enc, 2); @@ -13161,15 +13244,6 @@ test_xmlIOParseDTD(void) { des_xmlParserInputBufferPtr(n_input, input, 1); des_xmlCharEncoding(n_enc, enc, 2); xmlResetLastError(); - if (mem_base != xmlMemBlocks()) { - printf("Leak of %d blocks found in xmlIOParseDTD", - xmlMemBlocks() - mem_base); - test_ret++; - printf(" %d", n_sax); - printf(" %d", n_input); - printf(" %d", n_enc); - printf("\n"); - } } } } @@ -14551,14 +14625,14 @@ test_xmlRecoverDoc(void) { xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; - for (n_cur = 0;n_cur < gen_nb_xmlChar_ptr;n_cur++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { mem_base = xmlMemBlocks(); - cur = gen_xmlChar_ptr(n_cur, 0); + cur = gen_const_xmlChar_ptr(n_cur, 0); - ret_val = xmlRecoverDoc(cur); + ret_val = xmlRecoverDoc((const xmlChar *)cur); desret_xmlDocPtr(ret_val); call_tests++; - des_xmlChar_ptr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlRecoverDoc", @@ -16294,6 +16368,7 @@ test_xmlPushInput(void) { int test_ret = 0; int mem_base; + int ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; xmlParserInputPtr input; /* an XML parser input fragment (entity, XML fragment ...). */ @@ -16305,7 +16380,8 @@ test_xmlPushInput(void) { ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); input = gen_xmlParserInputPtr(n_input, 1); - xmlPushInput(ctxt, input); + ret_val = xmlPushInput(ctxt, input); + desret_int(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); des_xmlParserInputPtr(n_input, input, 1); @@ -17302,16 +17378,6 @@ static void des_xmlRelaxNGValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, xmlRe } #endif -#ifdef LIBXML_SCHEMAS_ENABLED - -#define gen_nb_void_ptr_ptr 1 -static void ** gen_void_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { - return(NULL); -} -static void des_void_ptr_ptr(int no ATTRIBUTE_UNUSED, void ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { -} -#endif - static int test_xmlRelaxNGGetParserErrors(void) { @@ -18759,6 +18825,7 @@ test_xmlBufferSetAllocationScheme(void) { scheme = gen_xmlBufferAllocationScheme(n_scheme, 1); xmlBufferSetAllocationScheme(buf, scheme); + if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;} call_tests++; des_xmlBufferPtr(n_buf, buf, 0); des_xmlBufferAllocationScheme(n_scheme, scheme, 1); @@ -18987,6 +19054,40 @@ test_xmlBuildQName(void) { static int +test_xmlChildElementCount(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + unsigned long ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + + ret_val = xmlChildElementCount(parent); + desret_unsigned_long(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlChildElementCount", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlCopyDoc(void) { int test_ret = 0; @@ -20101,6 +20202,40 @@ test_xmlElemDump(void) { static int +test_xmlFirstElementChild(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + + ret_val = xmlFirstElementChild(parent); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlFirstElementChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlGetBufferAllocationScheme(void) { int test_ret = 0; @@ -20603,6 +20738,40 @@ test_xmlIsXHTML(void) { static int +test_xmlLastElementChild(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + + ret_val = xmlLastElementChild(parent); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLastElementChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlNewCDataBlock(void) { int test_ret = 0; @@ -21762,6 +21931,40 @@ test_xmlNewTextLen(void) { static int +test_xmlNextElementSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the current node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlNextElementSibling(node); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNextElementSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlNodeAddContent(void) { int test_ret = 0; @@ -22511,6 +22714,40 @@ test_xmlNodeSetSpacePreserve(void) { static int +test_xmlPreviousElementSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the current node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlPreviousElementSibling(node); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPreviousElementSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlReconciliateNs(void) { int test_ret = 0; @@ -23775,7 +24012,7 @@ static int test_tree(void) { int test_ret = 0; - if (quiet == 0) printf("Testing tree : 133 of 152 functions ...\n"); + if (quiet == 0) printf("Testing tree : 138 of 157 functions ...\n"); test_ret += test_xmlAddChild(); test_ret += test_xmlAddChildList(); test_ret += test_xmlAddNextSibling(); @@ -23800,6 +24037,7 @@ test_tree(void) { test_ret += test_xmlBufferWriteChar(); test_ret += test_xmlBufferWriteQuotedString(); test_ret += test_xmlBuildQName(); + test_ret += test_xmlChildElementCount(); test_ret += test_xmlCopyDoc(); test_ret += test_xmlCopyDtd(); test_ret += test_xmlCopyNamespace(); @@ -23825,6 +24063,7 @@ test_tree(void) { test_ret += test_xmlDocGetRootElement(); test_ret += test_xmlDocSetRootElement(); test_ret += test_xmlElemDump(); + test_ret += test_xmlFirstElementChild(); test_ret += test_xmlGetBufferAllocationScheme(); test_ret += test_xmlGetCompressMode(); test_ret += test_xmlGetDocCompressMode(); @@ -23840,6 +24079,7 @@ test_tree(void) { test_ret += test_xmlHasProp(); test_ret += test_xmlIsBlankNode(); test_ret += test_xmlIsXHTML(); + test_ret += test_xmlLastElementChild(); test_ret += test_xmlNewCDataBlock(); test_ret += test_xmlNewCharRef(); test_ret += test_xmlNewChild(); @@ -23866,6 +24106,7 @@ test_tree(void) { test_ret += test_xmlNewText(); test_ret += test_xmlNewTextChild(); test_ret += test_xmlNewTextLen(); + test_ret += test_xmlNextElementSibling(); test_ret += test_xmlNodeAddContent(); test_ret += test_xmlNodeAddContentLen(); test_ret += test_xmlNodeBufGetContent(); @@ -23884,6 +24125,7 @@ test_tree(void) { test_ret += test_xmlNodeSetLang(); test_ret += test_xmlNodeSetName(); test_ret += test_xmlNodeSetSpacePreserve(); + test_ret += test_xmlPreviousElementSibling(); test_ret += test_xmlReconciliateNs(); test_ret += test_xmlRemoveProp(); test_ret += test_xmlReplaceNode(); @@ -27141,6 +27383,54 @@ test_xmlXIncludeProcessTreeFlags(void) { static int +test_xmlXIncludeProcessTreeFlagsData(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr tree; /* an XML node */ + int n_tree; + int flags; /* a set of xmlParserOption used for parsing XML includes */ + int n_flags; + void * data; /* application data that will be passed to the parser context in the _private field of the parser context(s) */ + int n_data; + + for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + tree = gen_xmlNodePtr(n_tree, 0); + flags = gen_int(n_flags, 1); + data = gen_userdata(n_data, 2); + + ret_val = xmlXIncludeProcessTreeFlagsData(tree, flags, data); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_tree, tree, 0); + des_int(n_flags, flags, 1); + des_userdata(n_data, data, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessTreeFlagsData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_tree); + printf(" %d", n_flags); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlXIncludeSetFlags(void) { int test_ret = 0; @@ -27184,7 +27474,7 @@ static int test_xinclude(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xinclude : 7 of 9 functions ...\n"); + if (quiet == 0) printf("Testing xinclude : 8 of 10 functions ...\n"); test_ret += test_xmlXIncludeNewContext(); test_ret += test_xmlXIncludeProcess(); test_ret += test_xmlXIncludeProcessFlags(); @@ -27192,6 +27482,7 @@ test_xinclude(void) { test_ret += test_xmlXIncludeProcessNode(); test_ret += test_xmlXIncludeProcessTree(); test_ret += test_xmlXIncludeProcessTreeFlags(); + test_ret += test_xmlXIncludeProcessTreeFlagsData(); test_ret += test_xmlXIncludeSetFlags(); if (test_ret != 0) @@ -32068,16 +32359,6 @@ test_xmlTextReaderSchemaValidate(void) { return(test_ret); } -#ifdef LIBXML_READER_ENABLED - -#define gen_nb_xmlSchemaValidCtxtPtr 1 -static xmlSchemaValidCtxtPtr gen_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { - return(NULL); -} -static void des_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { -} -#endif - static int test_xmlTextReaderSchemaValidateCtxt(void) { @@ -32184,16 +32465,6 @@ test_xmlTextReaderSetParserProp(void) { return(test_ret); } -#ifdef LIBXML_READER_ENABLED - -#define gen_nb_xmlSchemaPtr 1 -static xmlSchemaPtr gen_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { - return(NULL); -} -static void des_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, xmlSchemaPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { -} -#endif - static int test_xmlTextReaderSetSchema(void) { @@ -33725,13 +33996,13 @@ test_xmlSchemaGetValidErrors(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a XML-Schema validation context */ int n_ctxt; - xmlSchemaValidityErrorFunc * err; /* */ + xmlSchemaValidityErrorFunc * err; /* the error function result */ int n_err; - xmlSchemaValidityWarningFunc * warn; /* */ + xmlSchemaValidityWarningFunc * warn; /* the warning function result */ int n_warn; - void ** ctx; /* */ + void ** ctx; /* the functions context result */ int n_ctx; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -33780,7 +34051,7 @@ test_xmlSchemaIsValid(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* the schema validation context */ int n_ctxt; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -33973,7 +34244,7 @@ test_xmlSchemaSAXUnplug(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaSAXPlugPtr plug; /* */ + xmlSchemaSAXPlugPtr plug; /* a data structure returned by xmlSchemaSAXPlug */ int n_plug; for (n_plug = 0;n_plug < gen_nb_xmlSchemaSAXPlugPtr;n_plug++) { @@ -34037,9 +34308,9 @@ test_xmlSchemaSetValidOptions(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ int n_ctxt; - int options; /* */ + int options; /* a combination of xmlSchemaValidOption */ int n_options; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -34088,7 +34359,7 @@ test_xmlSchemaValidCtxtGetOptions(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ int n_ctxt; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -34116,35 +34387,69 @@ test_xmlSchemaValidCtxtGetOptions(void) { static int +test_xmlSchemaValidCtxtGetParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlParserCtxtPtr ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + + ret_val = xmlSchemaValidCtxtGetParserCtxt(ctxt); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidCtxtGetParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int test_xmlSchemaValidateDoc(void) { int test_ret = 0; #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ int n_ctxt; - xmlDocPtr instance; /* */ - int n_instance; + xmlDocPtr doc; /* a parsed document tree */ + int n_doc; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { - for (n_instance = 0;n_instance < gen_nb_xmlDocPtr;n_instance++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); - instance = gen_xmlDocPtr(n_instance, 1); + doc = gen_xmlDocPtr(n_doc, 1); - ret_val = xmlSchemaValidateDoc(ctxt, instance); + ret_val = xmlSchemaValidateDoc(ctxt, doc); desret_int(ret_val); call_tests++; des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); - des_xmlDocPtr(n_instance, instance, 1); + des_xmlDocPtr(n_doc, doc, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaValidateDoc", xmlMemBlocks() - mem_base); test_ret++; printf(" %d", n_ctxt); - printf(" %d", n_instance); + printf(" %d", n_doc); printf("\n"); } } @@ -34163,11 +34468,11 @@ test_xmlSchemaValidateFile(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ int n_ctxt; - const char * filename; /* */ + const char * filename; /* the URI of the instance */ int n_filename; - int options; /* */ + int options; /* a future set of options, currently unused */ int n_options; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -34211,9 +34516,9 @@ test_xmlSchemaValidateOneElement(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ int n_ctxt; - xmlNodePtr elem; /* */ + xmlNodePtr elem; /* an element node */ int n_elem; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -34252,15 +34557,15 @@ test_xmlSchemaValidateStream(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; int ret_val; - xmlSchemaValidCtxtPtr ctxt; /* */ + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ int n_ctxt; - xmlParserInputBufferPtr input; /* */ + xmlParserInputBufferPtr input; /* the input to use for reading the data */ int n_input; - xmlCharEncoding enc; /* */ + xmlCharEncoding enc; /* an optional encoding information */ int n_enc; - xmlSAXHandlerPtr sax; /* */ + xmlSAXHandlerPtr sax; /* a SAX handler for the resulting events */ int n_sax; - void * user_data; /* */ + void * user_data; /* the context to provide to the SAX handler. */ int n_user_data; for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { @@ -34310,7 +34615,7 @@ static int test_xmlschemas(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xmlschemas : 14 of 24 functions ...\n"); + if (quiet == 0) printf("Testing xmlschemas : 15 of 25 functions ...\n"); test_ret += test_xmlSchemaDump(); test_ret += test_xmlSchemaGetParserErrors(); test_ret += test_xmlSchemaGetValidErrors(); @@ -34328,6 +34633,7 @@ test_xmlschemas(void) { test_ret += test_xmlSchemaSetValidOptions(); test_ret += test_xmlSchemaSetValidStructuredErrors(); test_ret += test_xmlSchemaValidCtxtGetOptions(); + test_ret += test_xmlSchemaValidCtxtGetParserCtxt(); test_ret += test_xmlSchemaValidateDoc(); test_ret += test_xmlSchemaValidateFile(); test_ret += test_xmlSchemaValidateOneElement(); @@ -35906,16 +36212,16 @@ test_xmlStrcasestr(void) { int n_val; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { - for (n_val = 0;n_val < gen_nb_xmlChar_ptr;n_val++) { + for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { mem_base = xmlMemBlocks(); str = gen_const_xmlChar_ptr(n_str, 0); - val = gen_xmlChar_ptr(n_val, 1); + val = gen_const_xmlChar_ptr(n_val, 1); - ret_val = xmlStrcasestr((const xmlChar *)str, val); + ret_val = xmlStrcasestr((const xmlChar *)str, (const xmlChar *)val); desret_const_xmlChar_ptr(ret_val); call_tests++; des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); - des_xmlChar_ptr(n_val, val, 1); + des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrcasestr", @@ -49388,7 +49694,7 @@ test_xmlXPathRegisterNs(void) { int ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * prefix; /* the namespace prefix */ + xmlChar * prefix; /* the namespace prefix cannot be NULL or empty string */ int n_prefix; xmlChar * ns_uri; /* the namespace name */ int n_ns_uri; |