Commit 3d97e669 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

extending the tests coverage more fixes and cleanups Daniel

* gentest.py testapi.c: extending the tests coverage
* HTMLtree.c tree.c xmlsave.c xpointer.c: more fixes and cleanups
Daniel
parent b1b3a3e9
Thu Nov 4 11:48:47 CET 2004 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: extending the tests coverage
* HTMLtree.c tree.c xmlsave.c xpointer.c: more fixes and cleanups
Thu Nov 4 00:25:36 CET 2004 Daniel Veillard <daniel@veillard.com> Thu Nov 4 00:25:36 CET 2004 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: more fixes and extending the tests coverage * gentest.py testapi.c: more fixes and extending the tests coverage
......
...@@ -944,6 +944,9 @@ htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, ...@@ -944,6 +944,9 @@ htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
xmlInitParser(); xmlInitParser();
if ((buf == NULL) || (cur == NULL))
return;
/* /*
* force to output the stuff as HTML, especially for entities * force to output the stuff as HTML, especially for entities
*/ */
...@@ -997,7 +1000,7 @@ htmlDocDump(FILE *f, xmlDocPtr cur) { ...@@ -997,7 +1000,7 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
xmlInitParser(); xmlInitParser();
if (cur == NULL) { if ((cur == NULL) || (f == NULL)) {
return(-1); return(-1);
} }
......
...@@ -18,7 +18,7 @@ skipped_modules = [ "SAX", "SAX2", "xlink", "threads", "globals", ...@@ -18,7 +18,7 @@ skipped_modules = [ "SAX", "SAX2", "xlink", "threads", "globals",
"xmlversion", "debugXML", "xmlexports", "DOCBparser", "xmlversion", "debugXML", "xmlexports", "DOCBparser",
# temporary # temporary
"xmlautomata", "xmlregexp", "xmlautomata", "xmlregexp", "c14n",
] ]
...@@ -42,7 +42,7 @@ skipped_functions = [ ...@@ -42,7 +42,7 @@ skipped_functions = [
"xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml", "xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml",
"xmlTextReaderReadString", "xmlTextReaderReadString",
# destructor # destructor
"xmlListDelete", "xmlListDelete", "xmlOutputBufferClose",
# deprecated # deprecated
"xmlCatalogGetPublic", "xmlCatalogGetSystem", "xmlEncodeEntities", "xmlCatalogGetPublic", "xmlCatalogGetSystem", "xmlEncodeEntities",
# allocators # allocators
...@@ -88,6 +88,12 @@ extra_post_call = { ...@@ -88,6 +88,12 @@ extra_post_call = {
(ret_val != prefix) && (ret_val != memory)) (ret_val != prefix) && (ret_val != memory))
xmlFree(ret_val); xmlFree(ret_val);
ret_val = NULL;""", ret_val = NULL;""",
# Functions which deallocates one of their parameters
"xmlXPathConvertBoolean": """val = NULL;""",
"xmlXPathConvertNumber": """val = NULL;""",
"xmlXPathConvertString": """val = NULL;""",
"xmlSaveFileTo": """buf = NULL;""",
"xmlSaveFormatFileTo": """buf = NULL;"""
} }
modules = [] modules = []
...@@ -147,11 +153,13 @@ test.write("""/* ...@@ -147,11 +153,13 @@ test.write("""/*
#include <stdio.h> #include <stdio.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/relaxng.h>
static int testlibxml2(void); static int testlibxml2(void);
static int generic_errors = 0; static int generic_errors = 0;
static int call_tests = 0; static int call_tests = 0;
static int function_tests = 0;
static xmlChar chartab[1024] = " chartab\\n"; static xmlChar chartab[1024] = " chartab\\n";
...@@ -166,7 +174,9 @@ int main(void) { ...@@ -166,7 +174,9 @@ int main(void) {
int blocks, mem; int blocks, mem;
xmlInitParser(); xmlInitParser();
#ifdef LIBXML_SCHEMAS_ENABLED
xmlRelaxNGInitTypes(); xmlRelaxNGInitTypes();
#endif
LIBXML_TEST_VERSION LIBXML_TEST_VERSION
...@@ -239,8 +249,6 @@ def type_convert(str, name, info, module, function, pos): ...@@ -239,8 +249,6 @@ def type_convert(str, name, info, module, function, pos):
if string.find(function, "Save") != -1: if string.find(function, "Save") != -1:
return('fileoutput') return('fileoutput')
return('filepath') return('filepath')
if function == 'xmlIOHTTPOpenW':
print function, name, res, pos
if res == 'void_ptr': if res == 'void_ptr':
if module == 'nanoftp' and name == 'ctx': if module == 'nanoftp' and name == 'ctx':
return('xmlNanoFTPCtxtPtr') return('xmlNanoFTPCtxtPtr')
...@@ -254,6 +262,12 @@ def type_convert(str, name, info, module, function, pos): ...@@ -254,6 +262,12 @@ def type_convert(str, name, info, module, function, pos):
return('userdata'); return('userdata');
if string.find(name, "user") != -1: if string.find(name, "user") != -1:
return('userdata'); return('userdata');
if res == 'xmlDoc_ptr':
res = 'xmlDocPtr';
if res == 'xmlNode_ptr':
res = 'xmlNodePtr';
if res == 'xmlDict_ptr':
res = 'xmlDictPtr';
if res == 'xmlNodePtr' and pos != 0: if res == 'xmlNodePtr' and pos != 0:
if (function == 'xmlAddChild' and pos == 2) or \ if (function == 'xmlAddChild' and pos == 2) or \
(function == 'xmlAddChildList' and pos == 2) or \ (function == 'xmlAddChildList' and pos == 2) or \
...@@ -272,7 +286,8 @@ known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr", ...@@ -272,7 +286,8 @@ known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr",
"xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr", "xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr",
"xmlTextWriterPtr", "xmlTextReaderPtr", "xmlBufferPtr", "xmlTextWriterPtr", "xmlTextReaderPtr", "xmlBufferPtr",
"xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr", "xmlValidCtxtPtr", "xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr", "xmlValidCtxtPtr",
"void_ptr", "void_ptr", "xmlOutputBufferPtr", "xmlCharEncoding",
"unsigned_int"
] ]
def is_known_param_type(name): def is_known_param_type(name):
...@@ -284,70 +299,83 @@ def is_known_param_type(name): ...@@ -284,70 +299,83 @@ def is_known_param_type(name):
test.write(""" test.write("""
#define gen_nb_void_ptr 1 #define gen_nb_void_ptr 1
static void *gen_void_ptr(int no ATTRIBUTE_UNUSED) { static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
return(NULL); return(NULL);
} }
static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED) { static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_userdata 3 #define gen_nb_userdata 3
static void *gen_userdata(int no) { static void *gen_userdata(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return((void *) &call_tests); if (no == 0) return((void *) &call_tests);
if (no == 1) return((void *) -1); if (no == 1) return((void *) -1);
return(NULL); return(NULL);
} }
static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED) { static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_int 4 #define gen_nb_int 4
static int gen_int(int no) { static int gen_int(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(0); if (no == 0) return(0);
if (no == 1) return(1); if (no == 1) return(1);
if (no == 1) return(-1);
if (no == 2) return(122); if (no == 2) return(122);
return(-1); return(-1);
} }
static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED) { static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
#define gen_nb_unsigned_int 3
static unsigned int gen_unsigned_int(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(0);
if (no == 1) return(1);
if (no == 2) return(122);
return(-1);
}
static void des_unsigned_int(int no ATTRIBUTE_UNUSED, unsigned int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_const_char_ptr 4 #define gen_nb_const_char_ptr 4
static const char *gen_const_char_ptr(int no) { static const char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return("foo"); if (no == 0) return("foo");
if (no == 1) return("<foo/>"); if (no == 1) return("<foo/>");
if (no == 2) return("test/ent2"); if (no == 2) return("test/ent2");
return(NULL); return(NULL);
} }
static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED) { static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_xmlChar_ptr 2 #define gen_nb_xmlChar_ptr 2
static xmlChar *gen_xmlChar_ptr(int no) { static xmlChar *gen_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(&chartab[0]); if (no == 0) return(&chartab[0]);
return(NULL); return(NULL);
} }
static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED) { static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_const_xmlChar_ptr 5 #define gen_nb_const_xmlChar_ptr 5
static const xmlChar *gen_const_xmlChar_ptr(int no) { static const xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return((const xmlChar *) "foo"); if (no == 0) return((const xmlChar *) "foo");
if (no == 1) return((const xmlChar *) "<foo/>"); if (no == 1) return((const xmlChar *) "<foo/>");
if (no == 2) return((const xmlChar *) "nne"); if (no == 2) return((const xmlChar *) "nne");
if (no == 3) return((const xmlChar *) " 2ab "); if (no == 3) return((const xmlChar *) " 2ab ");
return(NULL); return(NULL);
} }
static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED) { static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_filepath 8 #define gen_nb_filepath 8
static const char *gen_filepath(int no) { static const char *gen_filepath(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return("missing.xml"); if (no == 0) return("missing.xml");
if (no == 1) return("<foo/>"); if (no == 1) return("<foo/>");
if (no == 2) return("test/ent2"); if (no == 2) return("test/ent2");
...@@ -357,12 +385,12 @@ static const char *gen_filepath(int no) { ...@@ -357,12 +385,12 @@ static const char *gen_filepath(int no) {
if (no == 6) return("http://missing. example.org/"); if (no == 6) return("http://missing. example.org/");
return(NULL); return(NULL);
} }
static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED) { static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_fileoutput 6 #define gen_nb_fileoutput 6
static const char *gen_fileoutput(int no) { static const char *gen_fileoutput(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return("/missing.xml"); if (no == 0) return("/missing.xml");
if (no == 1) return("<foo/>"); if (no == 1) return("<foo/>");
if (no == 2) return("ftp://missing.example.org/foo"); if (no == 2) return("ftp://missing.example.org/foo");
...@@ -370,46 +398,46 @@ static const char *gen_fileoutput(int no) { ...@@ -370,46 +398,46 @@ static const char *gen_fileoutput(int no) {
if (no == 4) return("http://missing. example.org/"); if (no == 4) return("http://missing. example.org/");
return(NULL); return(NULL);
} }
static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED) { static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_xmlParserCtxtPtr 2 #define gen_nb_xmlParserCtxtPtr 2
static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no) { static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewParserCtxt()); if (no == 0) return(xmlNewParserCtxt());
return(NULL); return(NULL);
} }
static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val) { static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) if (val != NULL)
xmlFreeParserCtxt(val); xmlFreeParserCtxt(val);
} }
#define gen_nb_xmlValidCtxtPtr 2 #define gen_nb_xmlValidCtxtPtr 2
static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no) { static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewValidCtxt()); if (no == 0) return(xmlNewValidCtxt());
return(NULL); return(NULL);
} }
static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val) { static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) if (val != NULL)
xmlFreeValidCtxt(val); xmlFreeValidCtxt(val);
} }
#define gen_nb_xmlDocPtr 3 #define gen_nb_xmlDocPtr 3
static xmlDocPtr gen_xmlDocPtr(int no) { static xmlDocPtr gen_xmlDocPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewDoc(BAD_CAST "1.0")); if (no == 0) return(xmlNewDoc(BAD_CAST "1.0"));
if (no == 1) return(xmlReadMemory("<foo/>", 6, "test", NULL, 0)); if (no == 1) return(xmlReadMemory("<foo/>", 6, "test", NULL, 0));
return(NULL); return(NULL);
} }
static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val) { static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) if (val != NULL)
xmlFreeDoc(val); xmlFreeDoc(val);
} }
#define gen_nb_xmlNodePtr 2 #define gen_nb_xmlNodePtr 2
static xmlNodePtr gen_xmlNodePtr(int no) { static xmlNodePtr gen_xmlNodePtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL)); if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
return(NULL); return(NULL);
} }
static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val) { static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) { if (val != NULL) {
xmlUnlinkNode(val); xmlUnlinkNode(val);
xmlFreeNode(val); xmlFreeNode(val);
...@@ -417,62 +445,62 @@ static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val) { ...@@ -417,62 +445,62 @@ static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val) {
} }
#define gen_nb_xmlNodePtr_in 3 #define gen_nb_xmlNodePtr_in 3
static xmlNodePtr gen_xmlNodePtr_in(int no) { static xmlNodePtr gen_xmlNodePtr_in(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL)); if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
if (no == 0) return(xmlNewText(BAD_CAST "text")); if (no == 0) return(xmlNewText(BAD_CAST "text"));
return(NULL); return(NULL);
} }
static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED) { static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
} }
#define gen_nb_xmlTextWriterPtr 2 #define gen_nb_xmlTextWriterPtr 2
static xmlTextWriterPtr gen_xmlTextWriterPtr(int no) { static xmlTextWriterPtr gen_xmlTextWriterPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewTextWriterFilename("test.out", 0)); if (no == 0) return(xmlNewTextWriterFilename("test.out", 0));
return(NULL); return(NULL);
} }
static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val) { static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) xmlFreeTextWriter(val); if (val != NULL) xmlFreeTextWriter(val);
} }
#define gen_nb_xmlTextReaderPtr 4 #define gen_nb_xmlTextReaderPtr 4
static xmlTextReaderPtr gen_xmlTextReaderPtr(int no) { static xmlTextReaderPtr gen_xmlTextReaderPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlNewTextReaderFilename("test/ent2")); if (no == 0) return(xmlNewTextReaderFilename("test/ent2"));
if (no == 1) return(xmlNewTextReaderFilename("test/valid/REC-xml-19980210.xml")); if (no == 1) return(xmlNewTextReaderFilename("test/valid/REC-xml-19980210.xml"));
if (no == 2) return(xmlNewTextReaderFilename("test/valid/dtds/xhtml1-strict.dtd")); if (no == 2) return(xmlNewTextReaderFilename("test/valid/dtds/xhtml1-strict.dtd"));
return(NULL); return(NULL);
} }
static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val) { static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) xmlFreeTextReader(val); if (val != NULL) xmlFreeTextReader(val);
} }
#define gen_nb_xmlBufferPtr 2 #define gen_nb_xmlBufferPtr 2
static xmlBufferPtr gen_xmlBufferPtr(int no) { static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlBufferCreate()); if (no == 0) return(xmlBufferCreate());
return(NULL); return(NULL);
} }
static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val) { static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) { if (val != NULL) {
xmlBufferFree(val); xmlBufferFree(val);
} }
} }
#define gen_nb_xmlListPtr 2 #define gen_nb_xmlListPtr 2
static xmlListPtr gen_xmlListPtr(int no) { static xmlListPtr gen_xmlListPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlListCreate(NULL, NULL)); if (no == 0) return(xmlListCreate(NULL, NULL));
return(NULL); return(NULL);
} }
static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val) { static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) { if (val != NULL) {
xmlListDelete(val); xmlListDelete(val);
} }
} }
#define gen_nb_xmlHashTablePtr 2 #define gen_nb_xmlHashTablePtr 2
static xmlHashTablePtr gen_xmlHashTablePtr(int no) { static xmlHashTablePtr gen_xmlHashTablePtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlHashCreate(10)); if (no == 0) return(xmlHashCreate(10));
return(NULL); return(NULL);
} }
static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val) { static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) { if (val != NULL) {
xmlHashFree(val, NULL); xmlHashFree(val, NULL);
} }
...@@ -481,19 +509,40 @@ static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val) { ...@@ -481,19 +509,40 @@ static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val) {
#include <libxml/xpathInternals.h> #include <libxml/xpathInternals.h>
#define gen_nb_xmlXPathObjectPtr 5 #define gen_nb_xmlXPathObjectPtr 5
static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no) { static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlXPathNewString(BAD_CAST "string object")); if (no == 0) return(xmlXPathNewString(BAD_CAST "string object"));
if (no == 1) return(xmlXPathNewFloat(1.1)); if (no == 1) return(xmlXPathNewFloat(1.1));
if (no == 2) return(xmlXPathNewBoolean(1)); if (no == 2) return(xmlXPathNewBoolean(1));
if (no == 3) return(xmlXPathNewNodeSet(NULL)); if (no == 3) return(xmlXPathNewNodeSet(NULL));
return(NULL); return(NULL);
} }
static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val) { static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) { if (val != NULL) {
xmlXPathFreeObject(val); xmlXPathFreeObject(val);
} }
} }
#define gen_nb_xmlOutputBufferPtr 2
static xmlOutputBufferPtr gen_xmlOutputBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlOutputBufferCreateFilename("test.out", NULL, 0));
return(NULL);
}
static void des_xmlOutputBufferPtr(int no ATTRIBUTE_UNUSED, xmlOutputBufferPtr val, int nr ATTRIBUTE_UNUSED) {
if (val != NULL) {
xmlOutputBufferClose(val);
}
}
#define gen_nb_xmlCharEncoding 4
static xmlCharEncoding gen_xmlCharEncoding(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(XML_CHAR_ENCODING_UTF8);
if (no == 1) return(XML_CHAR_ENCODING_NONE);
if (no == 0) return(XML_CHAR_ENCODING_8859_1);
return(XML_CHAR_ENCODING_ERROR);
}
static void des_xmlCharEncoding(int no ATTRIBUTE_UNUSED, xmlCharEncoding val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
"""); """);
# #
...@@ -501,7 +550,8 @@ static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val ...@@ -501,7 +550,8 @@ static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val
# #
known_return_types = [ "int", "const_char_ptr", "xmlDocPtr", "xmlNodePtr", known_return_types = [ "int", "const_char_ptr", "xmlDocPtr", "xmlNodePtr",
"xmlChar_ptr", "const_xmlChar_ptr", "void_ptr" ]; "xmlChar_ptr", "const_xmlChar_ptr", "void_ptr",
"xmlXPathObjectPtr", "xmlCharEncoding" ];
def is_known_return_type(name): def is_known_return_type(name):
for type in known_return_types: for type in known_return_types:
...@@ -512,6 +562,8 @@ def is_known_return_type(name): ...@@ -512,6 +562,8 @@ def is_known_return_type(name):
test.write(""" test.write("""
static void desret_int(int val ATTRIBUTE_UNUSED) { static void desret_int(int val ATTRIBUTE_UNUSED) {
} }
static void desret_xmlCharEncoding(xmlCharEncoding val ATTRIBUTE_UNUSED) {
}
static void desret_void_ptr(void *val ATTRIBUTE_UNUSED) { static void desret_void_ptr(void *val ATTRIBUTE_UNUSED) {
} }
static void desret_const_char_ptr(const char *val ATTRIBUTE_UNUSED) { static void desret_const_char_ptr(const char *val ATTRIBUTE_UNUSED) {
...@@ -529,6 +581,11 @@ static void desret_xmlNodePtr(xmlNodePtr val) { ...@@ -529,6 +581,11 @@ static void desret_xmlNodePtr(xmlNodePtr val) {
xmlUnlinkNode(val); xmlUnlinkNode(val);
xmlFreeNode(val); xmlFreeNode(val);
} }
static void desret_xmlXPathObjectPtr(xmlXPathObjectPtr val) {
if (val != NULL) {
xmlXPathFreeObject(val);
}
}
"""); """);
# #
...@@ -555,7 +612,8 @@ for module in modules: ...@@ -555,7 +612,8 @@ for module in modules:
test.write(" ret += test_%s();\n" % module) test.write(" ret += test_%s();\n" % module)
test.write(""" test.write("""
printf("Total: %d tests, %d errors\\n", call_tests, ret); printf("Total: %d functions, %d tests, %d errors\\n",
function_tests, call_tests, ret);
return(ret); return(ret);
} }
...@@ -669,10 +727,12 @@ test_%s(void) { ...@@ -669,10 +727,12 @@ test_%s(void) {
test.write(" mem_base = xmlMemBlocks();\n"); test.write(" mem_base = xmlMemBlocks();\n");
# prepare the call # prepare the call
i = 0;
for arg in t_args: for arg in t_args:
(nam, type, rtype, info) = arg; (nam, type, rtype, info) = arg;
# #
test.write(" %s = gen_%s(n_%s);\n" % (nam, type, nam)) test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i))
i = i + 1;
# do the call, and clanup the result # do the call, and clanup the result
if t_ret != None: if t_ret != None:
...@@ -706,10 +766,12 @@ test_%s(void) { ...@@ -706,10 +766,12 @@ test_%s(void) {