summaryrefslogtreecommitdiff
path: root/gentest.py
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-11-04 17:34:35 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-11-04 17:34:35 +0000
commit34099b403124601d9cd4bde0846a637bf8952cea (patch)
tree096477eb1aae15c5a69292b2dee3a56f4b625def /gentest.py
parent1ba06bb7f42c636506b319c03ef25b129cb51331 (diff)
downloadlibxml2-34099b403124601d9cd4bde0846a637bf8952cea.tar.gz
changing the way the .c is generated, extending the tests coverage fixing
* gentest.py testapi.c: changing the way the .c is generated, extending the tests coverage * include/libxml/nanoftp.h nanoftp.c elfgcchack.h doc/*: fixing some function signatures, regenerating stuff * SAX2.c parser.c xmlIO.c: another set of bug fixes and API hardening Daniel
Diffstat (limited to 'gentest.py')
-rwxr-xr-xgentest.py591
1 files changed, 113 insertions, 478 deletions
diff --git a/gentest.py b/gentest.py
index 9244a90b..a0f435bc 100755
--- a/gentest.py
+++ b/gentest.py
@@ -3,6 +3,7 @@
# generate a tester program for the API
#
import sys
+import os
import string
try:
import libxml2
@@ -64,6 +65,12 @@ skipped_memcheck = [ "xmlLoadCatalog", "xmlAddEncodingAlias",
#
# Extra code needed for some test cases
#
+extra_pre_call = {
+ "xmlSAXUserParseFile":
+ "if (sax == &xmlDefaultSAXHandler) user_data = NULL;",
+ "xmlSAXUserParseMemory":
+ "if (sax == &xmlDefaultSAXHandler) user_data = NULL;",
+}
extra_post_call = {
"xmlAddChild":
"if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }",
@@ -94,7 +101,8 @@ extra_post_call = {
"xmlXPathConvertNumber": """val = NULL;""",
"xmlXPathConvertString": """val = NULL;""",
"xmlSaveFileTo": """buf = NULL;""",
- "xmlSaveFormatFileTo": """buf = NULL;"""
+ "xmlSaveFormatFileTo": """buf = NULL;""",
+ "xmlIOParseDTD": "input = NULL;",
}
modules = []
@@ -128,109 +136,13 @@ def add_missing_type(name, func):
except:
missing_types[name] = [func]
-#
-# Open the input API description and the C test program result
-#
-doc = libxml2.readFile('doc/libxml2-api.xml', None, 0)
-if doc == None:
- print "Failed to load doc/libxml2-api.xml"
- sys.exit(1)
-test = open('testapi.c', 'w')
-ctxt = doc.xpathNewContext()
-headers = ctxt.xpathEval("/api/files/file")
-
-#
-# Generate the test header
-#
-test.write("""/*
- * testapi.c: libxml2 API tester program.
- *
- * Automatically generated by gentest.py from libxml2-api.xml
- *
- * See Copyright for the status of this software.
- *
- * daniel@veillard.com
- */
-
-#include <stdio.h>
-#include <libxml/xmlerror.h>
-#include <libxml/relaxng.h>
-
-static int testlibxml2(void);
-
-static int generic_errors = 0;
-static int call_tests = 0;
-static int function_tests = 0;
-
-static xmlChar chartab[1024] = " chartab\\n";
-static int inttab[1024];
-static unsigned long longtab[1024];
-
-static void
-structured_errors(void *userData ATTRIBUTE_UNUSED,
- xmlErrorPtr error ATTRIBUTE_UNUSED) {
- generic_errors++;
-}
-
-int main(void) {
- int ret;
- int blocks, mem;
-
- xmlInitParser();
-#ifdef LIBXML_SCHEMAS_ENABLED
- xmlRelaxNGInitTypes();
-#endif
-
- LIBXML_TEST_VERSION
-
- xmlSetStructuredErrorFunc(NULL, structured_errors);
-
- ret = testlibxml2();
-
- xmlCleanupParser();
- blocks = xmlMemBlocks();
- mem = xmlMemUsed();
- if ((blocks != 0) || (mem != 0)) {
- printf("testapi leaked %d bytes in %d blocks\\n", mem, blocks);
- }
- xmlMemoryDump();
-
- return (ret != 0);
-}
-
-""");
-
-#
-# Load the interfaces
-#
-for file in headers:
- name = file.xpathEval('string(@name)')
- if (name == None) or (name == ''):
- continue
-
- #
- # Some module may be skipped because they don't really consists
- # of user callable APIs
- #
- if is_skipped_module(name):
- continue
-
- #
- # do not test deprecated APIs
- #
- desc = file.xpathEval('string(description)')
- if string.find(desc, 'DEPRECATED') != -1:
- print "Skipping deprecated interface %s" % name
- continue;
-
- test.write("#include <libxml/%s.h>\n" % name)
- modules.append(name)
-
-#
-# Generate the callers signatures
-#
-for module in modules:
- test.write("static int test_%s(void);\n" % module);
+missing_functions = {}
+def add_missing_functions(name, module):
+ try:
+ list = missing_functions[module]
+ list.append(name)
+ except:
+ missing_functions[module] = [name]
#
# Provide the type generators and destructors for the parameters
@@ -281,18 +193,12 @@ def type_convert(str, name, info, module, function, pos):
(function == 'xmlTextMerge') or \
(function == 'xmlAddPrevSibling' and pos == 2):
return('xmlNodePtr_in');
+ if res == 'const xmlBufferPtr':
+ res = 'xmlBufferPtr';
return res
-known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr",
- "xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput",
- "xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr",
- "xmlTextWriterPtr", "xmlTextReaderPtr", "xmlBufferPtr",
- "xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr", "xmlValidCtxtPtr",
- "void_ptr", "xmlOutputBufferPtr", "xmlCharEncoding",
- "unsigned_int", "long", "unsigned_long", "const_void_ptr",
- "unsigned_long_ptr", "int_ptr", "FILE_ptr", "xmlDictPtr",
-]
+known_param_types = []
def is_known_param_type(name):
for type in known_param_types:
@@ -300,384 +206,102 @@ def is_known_param_type(name):
return 1
return 0
-test.write("""
-#define gen_nb_void_ptr 2
-
-static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
- return(NULL);
-}
-static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_const_void_ptr 2
-
-static const void *gen_const_void_ptr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return((const void *) "immutable string");
- return(NULL);
-}
-static void des_const_void_ptr(int no ATTRIBUTE_UNUSED, const void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_userdata 3
-
-static void *gen_userdata(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return((void *) &call_tests);
- if (no == 1) return((void *) -1);
- return(NULL);
-}
-static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-
-#define gen_nb_int 4
-
-static int gen_int(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(0);
- if (no == 1) return(1);
- if (no == 1) return(-1);
- if (no == 2) return(122);
- return(-1);
-}
-
-static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_long 4
-
-static long gen_long(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(0);
- if (no == 1) return(1);
- if (no == 1) return(-1);
- if (no == 2) return(122);
- return(-1);
-}
-
-static void des_long(int no ATTRIBUTE_UNUSED, long 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_unsigned_long 3
-
-static unsigned long gen_unsigned_long(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_long(int no ATTRIBUTE_UNUSED, unsigned long val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_unsigned_long_ptr 2
-
-static unsigned long *gen_unsigned_long_ptr(int no, int nr) {
- if (no == 0) return(&longtab[nr]);
- return(NULL);
-}
-
-static void des_unsigned_long_ptr(int no ATTRIBUTE_UNUSED, unsigned long *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_int_ptr 2
-
-static int *gen_int_ptr(int no, int nr) {
- if (no == 0) return(&inttab[nr]);
- return(NULL);
-}
-
-static void des_int_ptr(int no ATTRIBUTE_UNUSED, int *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_const_char_ptr 4
-
-static const char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return("foo");
- if (no == 1) return("<foo/>");
- if (no == 2) return("test/ent2");
- return(NULL);
-}
-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
-
-static xmlChar *gen_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(&chartab[0]);
- return(NULL);
-}
-static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_FILE_ptr 2
-
-static FILE *gen_FILE_ptr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(fopen("test.out", "a+"));
- return(NULL);
-}
-static void des_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) fclose(val);
-}
-
-#define gen_nb_const_xmlChar_ptr 5
-
-static const xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return((const xmlChar *) "foo");
- if (no == 1) return((const xmlChar *) "<foo/>");
- if (no == 2) return((const xmlChar *) "nøne");
- if (no == 3) return((const xmlChar *) " 2ab ");
- return(NULL);
-}
-static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_filepath 8
-
-static const char *gen_filepath(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return("missing.xml");
- if (no == 1) return("<foo/>");
- if (no == 2) return("test/ent2");
- if (no == 3) return("test/valid/REC-xml-19980210.xml");
- if (no == 4) return("test/valid/dtds/xhtml1-strict.dtd");
- if (no == 5) return("http://missing.example.org/");
- if (no == 6) return("http://missing. example.org/");
- return(NULL);
-}
-static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_fileoutput 6
-
-static const char *gen_fileoutput(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return("/missing.xml");
- if (no == 1) return("<foo/>");
- if (no == 2) return("ftp://missing.example.org/foo");
- if (no == 3) return("http://missing.example.org/");
- if (no == 4) return("http://missing. example.org/");
- return(NULL);
-}
-static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_xmlParserCtxtPtr 2
-static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlNewParserCtxt());
- return(NULL);
-}
-static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL)
- xmlFreeParserCtxt(val);
-}
-
-#define gen_nb_xmlValidCtxtPtr 2
-static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlNewValidCtxt());
- return(NULL);
-}
-static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL)
- xmlFreeValidCtxt(val);
-}
-
-#define gen_nb_xmlDocPtr 3
-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));
- return(NULL);
-}
-static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL)
- xmlFreeDoc(val);
-}
-
-#define gen_nb_xmlDictPtr 2
-static xmlDictPtr gen_xmlDictPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlDictCreate());
- return(NULL);
-}
-static void des_xmlDictPtr(int no ATTRIBUTE_UNUSED, xmlDictPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL)
- xmlDictFree(val);
-}
-
-#define gen_nb_xmlNodePtr 2
-static xmlNodePtr gen_xmlNodePtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
- return(NULL);
-}
-static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) {
- xmlUnlinkNode(val);
- xmlFreeNode(val);
- }
-}
-
-#define gen_nb_xmlNodePtr_in 3
-static xmlNodePtr gen_xmlNodePtr_in(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
- if (no == 0) return(xmlNewText(BAD_CAST "text"));
- return(NULL);
-}
-static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
-}
-
-#define gen_nb_xmlTextWriterPtr 2
-static xmlTextWriterPtr gen_xmlTextWriterPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlNewTextWriterFilename("test.out", 0));
- return(NULL);
-}
-static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) xmlFreeTextWriter(val);
-}
+#
+# Provide the type destructors for the return values
+#
-#define gen_nb_xmlTextReaderPtr 4
-static xmlTextReaderPtr gen_xmlTextReaderPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlNewTextReaderFilename("test/ent2"));
- if (no == 1) return(xmlNewTextReaderFilename("test/valid/REC-xml-19980210.xml"));
- if (no == 2) return(xmlNewTextReaderFilename("test/valid/dtds/xhtml1-strict.dtd"));
- return(NULL);
-}
-static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) xmlFreeTextReader(val);
-}
+known_return_types = []
-#define gen_nb_xmlBufferPtr 2
-static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlBufferCreate());
- return(NULL);
-}
-static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) {
- xmlBufferFree(val);
- }
-}
+def is_known_return_type(name):
+ for type in known_return_types:
+ if type == name:
+ return 1
+ return 0
-#define gen_nb_xmlListPtr 2
-static xmlListPtr gen_xmlListPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlListCreate(NULL, NULL));
- return(NULL);
-}
-static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) {
- xmlListDelete(val);
- }
-}
+#
+# Copy the beginning of the C test program result
+#
-#define gen_nb_xmlHashTablePtr 2
-static xmlHashTablePtr gen_xmlHashTablePtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlHashCreate(10));
- return(NULL);
-}
-static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) {
- xmlHashFree(val, NULL);
- }
-}
+input = open("testapi.c", "r")
+test = open('testapi.c.new', 'w')
-#include <libxml/xpathInternals.h>
+def compare_and_save():
+ global test
-#define gen_nb_xmlXPathObjectPtr 5
-static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no, int nr ATTRIBUTE_UNUSED) {
- if (no == 0) return(xmlXPathNewString(BAD_CAST "string object"));
- if (no == 1) return(xmlXPathNewFloat(1.1));
- if (no == 2) return(xmlXPathNewBoolean(1));
- if (no == 3) return(xmlXPathNewNodeSet(NULL));
- return(NULL);
-}
-static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val, int nr ATTRIBUTE_UNUSED) {
- if (val != NULL) {
- xmlXPathFreeObject(val);
- }
-}
+ test.close()
+ input = open("testapi.c", "r").read()
+ test = open('testapi.c.new', "r").read()
+ if input != test:
+ os.system("rm testapi.c ; mv testapi.c.new testapi.c")
+ print("Updated testapi.c")
+ else:
+ print("Generated testapi.c is identical")
+
+line = input.readline()
+while line != "":
+ if line == "/* CUT HERE: everything below that line is generated */\n":
+ break;
+ if line[0:15] == "#define gen_nb_":
+ type = string.split(line[15:])[0]
+ known_param_types.append(type)
+ if line[0:19] == "static void desret_":
+ type = string.split(line[19:], '(')[0]
+ known_return_types.append(type)
+ test.write(line)
+ line = input.readline()
+input.close()
+
+if line == "":
+ print "Could not find the CUT marker in testapi.c skipping generation"
+ test.close()
+ sys.exit(0)
-#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);
- }
-}
+print("Scanned testapi.c: found %d parameters types and %d return types\n" % (
+ len(known_param_types), len(known_return_types)))
+test.write("/* CUT HERE: everything below that line is generated */\n")
-#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) {
-}
-
-""");
#
-# Provide the type destructors for the return values
+# Open the input API description
#
+doc = libxml2.readFile('doc/libxml2-api.xml', None, 0)
+if doc == None:
+ print "Failed to load doc/libxml2-api.xml"
+ sys.exit(1)
+ctxt = doc.xpathNewContext()
+headers = ctxt.xpathEval("/api/files/file")
-known_return_types = [ "int", "const_char_ptr", "xmlDocPtr", "xmlNodePtr",
- "xmlChar_ptr", "const_xmlChar_ptr", "void_ptr",
- "xmlXPathObjectPtr", "xmlCharEncoding", "long",
- "const_void_ptr", "double", "xmlTextReaderPtr",
- "xmlDictPtr",
-]
+#
+# Load the interfaces
+#
+for file in headers:
+ name = file.xpathEval('string(@name)')
+ if (name == None) or (name == ''):
+ continue
-def is_known_return_type(name):
- for type in known_return_types:
- if type == name:
- return 1
- return 0
+ #
+ # Some module may be skipped because they don't really consists
+ # of user callable APIs
+ #
+ if is_skipped_module(name):
+ continue
-test.write("""
-static void desret_int(int val ATTRIBUTE_UNUSED) {
-}
-static void desret_long(long val ATTRIBUTE_UNUSED) {
-}
-static void desret_double(double val ATTRIBUTE_UNUSED) {
-}
-static void desret_xmlCharEncoding(xmlCharEncoding val ATTRIBUTE_UNUSED) {
-}
-static void desret_const_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_xmlChar_ptr(const xmlChar *val ATTRIBUTE_UNUSED) {
-}
-static void desret_xmlChar_ptr(xmlChar *val) {
- if (val != NULL)
- xmlFree(val);
-}
-static void desret_xmlDocPtr(xmlDocPtr val) {
- xmlFreeDoc(val);
-}
-static void desret_xmlDictPtr(xmlDictPtr val) {
- xmlDictFree(val);
-}
-static void desret_xmlTextReaderPtr(xmlTextReaderPtr val) {
- xmlFreeTextReader(val);
-}
-static void desret_xmlNodePtr(xmlNodePtr val) {
- xmlUnlinkNode(val);
- xmlFreeNode(val);
-}
-static void desret_xmlXPathObjectPtr(xmlXPathObjectPtr val) {
- xmlXPathFreeObject(val);
-}
-""");
+ #
+ # do not test deprecated APIs
+ #
+ desc = file.xpathEval('string(description)')
+ if string.find(desc, 'DEPRECATED') != -1:
+ print "Skipping deprecated interface %s" % name
+ continue;
+
+ test.write("#include <libxml/%s.h>\n" % name)
+ modules.append(name)
+
+#
+# Generate the callers signatures
+#
+for module in modules:
+ test.write("static int test_%s(void);\n" % module);
#
# Generate the top caller
@@ -773,6 +397,7 @@ test_%s(void) {
break
if no_gen == 1:
+ add_missing_functions(name, module)
test.write("""
/* missing type support */
return(ret);
@@ -826,6 +451,8 @@ test_%s(void) {
i = i + 1;
# do the call, and clanup the result
+ if extra_pre_call.has_key(name):
+ test.write(" %s\n"% (extra_pre_call[name]))
if t_ret != None:
test.write("\n ret_val = %s(" % (name))
need = 0
@@ -940,6 +567,8 @@ test_%s(void) {
print "Generated test for %d modules and %d functions" %(len(modules), nb_tests)
+compare_and_save()
+
missing_list = []
for missing in missing_types.keys():
if missing == 'va_list' or missing == '...':
@@ -954,6 +583,8 @@ def compare_missing(a, b):
missing_list.sort(compare_missing)
print "Missing support for %d types see missing.lst" % (len(missing_list))
lst = open("missing.lst", "w")
+lst.write("Missing support for %d types" % (len(missing_list)))
+lst.write("\n")
for miss in missing_list:
lst.write("%s: %d :" % (miss[1], miss[0]))
i = 0
@@ -964,8 +595,12 @@ for miss in missing_list:
break
lst.write(" %s" % (n))
lst.write("\n")
+lst.write("\n")
+lst.write("\n")
+lst.write("Missing support per module");
+for module in missing_functions.keys():
+ lst.write("module %s:\n %s\n" % (module, missing_functions[module]))
lst.close()
-test.close()