Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 1 | #!/usr/bin/python -u |
| 2 | # |
| 3 | # generate a tester program for the API |
| 4 | # |
| 5 | import sys |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 6 | import os |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 7 | import string |
| 8 | try: |
| 9 | import libxml2 |
| 10 | except: |
| 11 | print "libxml2 python bindings not available, skipping testapi.c generation" |
| 12 | sys.exit(0) |
| 13 | |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 14 | if len(sys.argv) > 1: |
| 15 | srcPref = sys.argv[1] + '/' |
| 16 | else: |
| 17 | srcPref = '' |
| 18 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 19 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 20 | # Modules we want to skip in API test |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 21 | # |
Daniel Veillard | 2a4fb5a | 2004-11-08 14:02:18 +0000 | [diff] [blame] | 22 | skipped_modules = [ "SAX", "xlink", "threads", "globals", |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 23 | "xmlmemory", "xmlversion", "xmlexports", |
| 24 | #deprecated |
| 25 | "DOCBparser", |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 26 | ] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 27 | |
| 28 | # |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 29 | # defines for each module |
| 30 | # |
| 31 | modules_defines = { |
| 32 | "HTMLparser": "LIBXML_HTML_ENABLED", |
| 33 | "catalog": "LIBXML_CATALOG_ENABLED", |
| 34 | "xmlreader": "LIBXML_READER_ENABLED", |
| 35 | "relaxng": "LIBXML_SCHEMAS_ENABLED", |
| 36 | "schemasInternals": "LIBXML_SCHEMAS_ENABLED", |
| 37 | "xmlschemas": "LIBXML_SCHEMAS_ENABLED", |
| 38 | "xmlschemastypes": "LIBXML_SCHEMAS_ENABLED", |
| 39 | "xpath": "LIBXML_XPATH_ENABLED", |
| 40 | "xpathInternals": "LIBXML_XPATH_ENABLED", |
| 41 | "xinclude": "LIBXML_XINCLUDE_ENABLED", |
| 42 | "xpointer": "LIBXML_XPTR_ENABLED", |
| 43 | "xmlregexp" : "LIBXML_REGEXP_ENABLED", |
| 44 | "xmlautomata" : "LIBXML_AUTOMATA_ENABLED", |
| 45 | "xmlsave" : "LIBXML_OUTPUT_ENABLED", |
| 46 | "DOCBparser" : "LIBXML_DOCB_ENABLED", |
Daniel Veillard | fc0b6f6 | 2005-01-09 17:48:02 +0000 | [diff] [blame] | 47 | "xmlmodule" : "LIBXML_MODULES_ENABLED", |
William M. Brack | ba1d317 | 2005-03-25 03:05:46 +0000 | [diff] [blame] | 48 | "pattern" : "LIBXML_PATTERN_ENABLED", |
William M. Brack | dc904f1 | 2005-10-22 02:04:26 +0000 | [diff] [blame] | 49 | "schematron" : "LIBXML_SCHEMATRON_ENABLED", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | # |
| 53 | # defines for specific functions |
| 54 | # |
| 55 | function_defines = { |
| 56 | "htmlDefaultSAXHandlerInit": "LIBXML_HTML_ENABLED", |
| 57 | "xmlSAX2EndElement" : "LIBXML_SAX1_ENABLED", |
| 58 | "xmlSAX2StartElement" : "LIBXML_SAX1_ENABLED", |
| 59 | "xmlSAXDefaultVersion" : "LIBXML_SAX1_ENABLED", |
| 60 | "UTF8Toisolat1" : "LIBXML_OUTPUT_ENABLED", |
| 61 | "xmlCleanupPredefinedEntities": "LIBXML_LEGACY_ENABLED", |
| 62 | "xmlInitializePredefinedEntities": "LIBXML_LEGACY_ENABLED", |
| 63 | "xmlSetFeature": "LIBXML_LEGACY_ENABLED", |
| 64 | "xmlGetFeature": "LIBXML_LEGACY_ENABLED", |
| 65 | "xmlGetFeaturesList": "LIBXML_LEGACY_ENABLED", |
| 66 | "xmlIOParseDTD": "LIBXML_VALID_ENABLED", |
| 67 | "xmlParseDTD": "LIBXML_VALID_ENABLED", |
| 68 | "xmlParseDoc": "LIBXML_SAX1_ENABLED", |
| 69 | "xmlParseMemory": "LIBXML_SAX1_ENABLED", |
| 70 | "xmlRecoverDoc": "LIBXML_SAX1_ENABLED", |
| 71 | "xmlParseFile": "LIBXML_SAX1_ENABLED", |
| 72 | "xmlRecoverFile": "LIBXML_SAX1_ENABLED", |
| 73 | "xmlRecoverMemory": "LIBXML_SAX1_ENABLED", |
| 74 | "xmlSAXParseFileWithData": "LIBXML_SAX1_ENABLED", |
| 75 | "xmlSAXParseMemory": "LIBXML_SAX1_ENABLED", |
| 76 | "xmlSAXUserParseMemory": "LIBXML_SAX1_ENABLED", |
| 77 | "xmlSAXParseDoc": "LIBXML_SAX1_ENABLED", |
| 78 | "xmlSAXParseDTD": "LIBXML_SAX1_ENABLED", |
| 79 | "xmlSAXUserParseFile": "LIBXML_SAX1_ENABLED", |
| 80 | "xmlParseEntity": "LIBXML_SAX1_ENABLED", |
| 81 | "xmlParseExternalEntity": "LIBXML_SAX1_ENABLED", |
| 82 | "xmlSAXParseMemoryWithData": "LIBXML_SAX1_ENABLED", |
| 83 | "xmlParseBalancedChunkMemory": "LIBXML_SAX1_ENABLED", |
| 84 | "xmlParseBalancedChunkMemoryRecover": "LIBXML_SAX1_ENABLED", |
| 85 | "xmlSetupParserForBuffer": "LIBXML_SAX1_ENABLED", |
| 86 | "xmlStopParser": "LIBXML_PUSH_ENABLED", |
| 87 | "xmlAttrSerializeTxtContent": "LIBXML_OUTPUT_ENABLED", |
| 88 | "xmlSAXParseFile": "LIBXML_SAX1_ENABLED", |
| 89 | "xmlSAXParseEntity": "LIBXML_SAX1_ENABLED", |
| 90 | "xmlNewTextChild": "LIBXML_TREE_ENABLED", |
| 91 | "xmlNewDocRawNode": "LIBXML_TREE_ENABLED", |
| 92 | "xmlNewProp": "LIBXML_TREE_ENABLED", |
| 93 | "xmlReconciliateNs": "LIBXML_TREE_ENABLED", |
| 94 | "xmlValidateNCName": "LIBXML_TREE_ENABLED", |
| 95 | "xmlValidateNMToken": "LIBXML_TREE_ENABLED", |
| 96 | "xmlValidateName": "LIBXML_TREE_ENABLED", |
| 97 | "xmlNewChild": "LIBXML_TREE_ENABLED", |
| 98 | "xmlValidateQName": "LIBXML_TREE_ENABLED", |
| 99 | "xmlSprintfElementContent": "LIBXML_OUTPUT_ENABLED", |
| 100 | "xmlValidGetPotentialChildren" : "LIBXML_VALID_ENABLED", |
| 101 | "xmlValidGetValidElements" : "LIBXML_VALID_ENABLED", |
| 102 | "docbDefaultSAXHandlerInit" : "LIBXML_DOCB_ENABLED", |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 103 | "xmlTextReaderPreservePattern" : "LIBXML_PATTERN_ENABLED", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 107 | # Some functions really need to be skipped for the tests. |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 108 | # |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 109 | skipped_functions = [ |
| 110 | # block on I/O |
| 111 | "xmlFdRead", "xmlReadFd", "xmlCtxtReadFd", |
| 112 | "htmlFdRead", "htmlReadFd", "htmlCtxtReadFd", |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 113 | "xmlReaderNewFd", "xmlReaderForFd", |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 114 | "xmlIORead", "xmlReadIO", "xmlCtxtReadIO", |
| 115 | "htmlIORead", "htmlReadIO", "htmlCtxtReadIO", |
Daniel Veillard | 27f2010 | 2004-11-05 11:50:11 +0000 | [diff] [blame] | 116 | "xmlReaderNewIO", "xmlBufferDump", "xmlNanoFTPConnect", |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 117 | "xmlNanoFTPConnectTo", "xmlNanoHTTPMethod", "xmlNanoHTTPMethodRedir", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 118 | # Complex I/O APIs |
| 119 | "xmlCreateIOParserCtxt", "xmlParserInputBufferCreateIO", |
| 120 | "xmlRegisterInputCallbacks", "xmlReaderForIO", |
| 121 | "xmlOutputBufferCreateIO", "xmlRegisterOutputCallbacks", |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 122 | "xmlSaveToIO", "xmlIOHTTPOpenW", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 123 | # library state cleanup, generate false leak informations and other |
| 124 | # troubles, heavillyb tested otherwise. |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 125 | "xmlCleanupParser", "xmlRelaxNGCleanupTypes", "xmlSetListDoc", |
| 126 | "xmlSetTreeDoc", "xmlUnlinkNode", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 127 | # hard to avoid leaks in the tests |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 128 | "xmlStrcat", "xmlStrncat", "xmlCatalogAddLocal", "xmlNewTextWriterDoc", |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 129 | "xmlXPathNewValueTree", "xmlXPathWrapString", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 130 | # unimplemented |
| 131 | "xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml", |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 132 | "xmlTextReaderReadString", |
| 133 | # destructor |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 134 | "xmlListDelete", "xmlOutputBufferClose", "xmlNanoFTPClose", "xmlNanoHTTPClose", |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 135 | # deprecated |
| 136 | "xmlCatalogGetPublic", "xmlCatalogGetSystem", "xmlEncodeEntities", |
Daniel Veillard | 2a4fb5a | 2004-11-08 14:02:18 +0000 | [diff] [blame] | 137 | "xmlNewGlobalNs", "xmlHandleEntity", "xmlNamespaceParseNCName", |
| 138 | "xmlNamespaceParseNSDef", "xmlNamespaceParseQName", |
| 139 | "xmlParseNamespace", "xmlParseQuotedString", "xmlParserHandleReference", |
| 140 | "xmlScanName", |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 141 | "xmlDecodeEntities", |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 142 | # allocators |
| 143 | "xmlMemFree", |
Daniel Veillard | c2c894f | 2004-11-07 12:17:35 +0000 | [diff] [blame] | 144 | # verbosity |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 145 | "xmlCatalogSetDebug", "xmlShellPrintXPathError", "xmlShellPrintNode", |
Daniel Veillard | 2a4fb5a | 2004-11-08 14:02:18 +0000 | [diff] [blame] | 146 | # Internal functions, no user space should really call them |
| 147 | "xmlParseAttribute", "xmlParseAttributeListDecl", "xmlParseName", |
| 148 | "xmlParseNmtoken", "xmlParseEntityValue", "xmlParseAttValue", |
| 149 | "xmlParseSystemLiteral", "xmlParsePubidLiteral", "xmlParseCharData", |
| 150 | "xmlParseExternalID", "xmlParseComment", "xmlParsePITarget", "xmlParsePI", |
| 151 | "xmlParseNotationDecl", "xmlParseEntityDecl", "xmlParseDefaultDecl", |
| 152 | "xmlParseNotationType", "xmlParseEnumerationType", "xmlParseEnumeratedType", |
| 153 | "xmlParseAttributeType", "xmlParseAttributeListDecl", |
| 154 | "xmlParseElementMixedContentDecl", "xmlParseElementChildrenContentDecl", |
| 155 | "xmlParseElementContentDecl", "xmlParseElementDecl", "xmlParseMarkupDecl", |
| 156 | "xmlParseCharRef", "xmlParseEntityRef", "xmlParseReference", |
| 157 | "xmlParsePEReference", "xmlParseDocTypeDecl", "xmlParseAttribute", |
| 158 | "xmlParseStartTag", "xmlParseEndTag", "xmlParseCDSect", "xmlParseContent", |
| 159 | "xmlParseElement", "xmlParseVersionNum", "xmlParseVersionInfo", |
| 160 | "xmlParseEncName", "xmlParseEncodingDecl", "xmlParseSDDecl", |
| 161 | "xmlParseXMLDecl", "xmlParseTextDecl", "xmlParseMisc", |
| 162 | "xmlParseExternalSubset", "xmlParserHandlePEReference", |
| 163 | "xmlSkipBlankChars", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 164 | ] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 165 | |
| 166 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 167 | # These functions have side effects on the global state |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 168 | # and hence generate errors on memory allocation tests |
| 169 | # |
| 170 | skipped_memcheck = [ "xmlLoadCatalog", "xmlAddEncodingAlias", |
| 171 | "xmlSchemaInitTypes", "xmlNanoFTPProxy", "xmlNanoFTPScanProxy", |
| 172 | "xmlNanoHTTPScanProxy", "xmlResetLastError", "xmlCatalogConvert", |
| 173 | "xmlCatalogRemove", "xmlLoadCatalogs", "xmlCleanupCharEncodingHandlers", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 174 | "xmlInitCharEncodingHandlers", "xmlCatalogCleanup", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 175 | "xmlSchemaGetBuiltInType", |
Daniel Veillard | 1f33c4d | 2005-07-10 21:38:31 +0000 | [diff] [blame] | 176 | "htmlParseFile", "htmlCtxtReadFile", # loads the catalogs |
| 177 | "xmlTextReaderSchemaValidate", "xmlSchemaCleanupTypes" # initialize the schemas type system |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 178 | ] |
| 179 | |
| 180 | # |
| 181 | # Extra code needed for some test cases |
| 182 | # |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 183 | extra_pre_call = { |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 184 | "xmlSAXUserParseFile": """ |
| 185 | #ifdef LIBXML_SAX1_ENABLED |
| 186 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 187 | #endif |
| 188 | """, |
| 189 | "xmlSAXUserParseMemory": """ |
| 190 | #ifdef LIBXML_SAX1_ENABLED |
| 191 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 192 | #endif |
| 193 | """, |
| 194 | "xmlParseBalancedChunkMemory": """ |
| 195 | #ifdef LIBXML_SAX1_ENABLED |
| 196 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 197 | #endif |
| 198 | """, |
| 199 | "xmlParseBalancedChunkMemoryRecover": """ |
| 200 | #ifdef LIBXML_SAX1_ENABLED |
| 201 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 202 | #endif |
| 203 | """, |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 204 | "xmlParserInputBufferCreateFd": |
| 205 | "if (fd >= 0) fd = -1;", |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 206 | } |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 207 | extra_post_call = { |
| 208 | "xmlAddChild": |
| 209 | "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", |
| 210 | "xmlAddChildList": |
| 211 | "if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }", |
| 212 | "xmlAddSibling": |
| 213 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 214 | "xmlAddNextSibling": |
| 215 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 216 | "xmlAddPrevSibling": |
| 217 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 218 | "xmlDocSetRootElement": |
| 219 | "if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }", |
| 220 | "xmlReplaceNode": |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 221 | """if (cur != NULL) { |
| 222 | xmlUnlinkNode(cur); |
| 223 | xmlFreeNode(cur) ; cur = NULL ; } |
| 224 | if (old != NULL) { |
| 225 | xmlUnlinkNode(old); |
| 226 | xmlFreeNode(old) ; old = NULL ; } |
| 227 | ret_val = NULL;""", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 228 | "xmlTextMerge": |
| 229 | """if ((first != NULL) && (first->type != XML_TEXT_NODE)) { |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 230 | xmlUnlinkNode(second); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 231 | xmlFreeNode(second) ; second = NULL ; }""", |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 232 | "xmlBuildQName": |
| 233 | """if ((ret_val != NULL) && (ret_val != ncname) && |
| 234 | (ret_val != prefix) && (ret_val != memory)) |
| 235 | xmlFree(ret_val); |
| 236 | ret_val = NULL;""", |
Daniel Veillard | c394f73 | 2005-01-26 00:04:52 +0000 | [diff] [blame] | 237 | "xmlNewDocElementContent": |
| 238 | """xmlFreeDocElementContent(doc, ret_val); ret_val = NULL;""", |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 239 | "xmlDictReference": "xmlDictFree(dict);", |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 240 | # Functions which deallocates one of their parameters |
| 241 | "xmlXPathConvertBoolean": """val = NULL;""", |
| 242 | "xmlXPathConvertNumber": """val = NULL;""", |
| 243 | "xmlXPathConvertString": """val = NULL;""", |
| 244 | "xmlSaveFileTo": """buf = NULL;""", |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 245 | "xmlSaveFormatFileTo": """buf = NULL;""", |
| 246 | "xmlIOParseDTD": "input = NULL;", |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 247 | "xmlRemoveProp": "cur = NULL;", |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 248 | "xmlNewNs": "if ((node == NULL) && (ret_val != NULL)) xmlFreeNs(ret_val);", |
| 249 | "xmlCopyNamespace": "if (ret_val != NULL) xmlFreeNs(ret_val);", |
| 250 | "xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);", |
| 251 | "xmlNewTextWriter": "if (ret_val != NULL) out = NULL;", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 252 | "xmlNewTextWriterPushParser": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} if (ret_val != NULL) ctxt = NULL;", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 253 | "xmlNewIOInputStream": "if (ret_val != NULL) input = NULL;", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 254 | "htmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 255 | "htmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 256 | "xmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 257 | "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 258 | "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
Daniel Veillard | 7e33dba | 2005-07-03 22:40:26 +0000 | [diff] [blame] | 259 | "xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 260 | } |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 261 | |
| 262 | modules = [] |
| 263 | |
| 264 | def is_skipped_module(name): |
| 265 | for mod in skipped_modules: |
| 266 | if mod == name: |
| 267 | return 1 |
| 268 | return 0 |
| 269 | |
| 270 | def is_skipped_function(name): |
| 271 | for fun in skipped_functions: |
| 272 | if fun == name: |
| 273 | return 1 |
| 274 | # Do not test destructors |
| 275 | if string.find(name, 'Free') != -1: |
| 276 | return 1 |
| 277 | return 0 |
| 278 | |
| 279 | def is_skipped_memcheck(name): |
| 280 | for fun in skipped_memcheck: |
| 281 | if fun == name: |
| 282 | return 1 |
| 283 | return 0 |
| 284 | |
| 285 | missing_types = {} |
| 286 | def add_missing_type(name, func): |
| 287 | try: |
| 288 | list = missing_types[name] |
| 289 | list.append(func) |
| 290 | except: |
| 291 | missing_types[name] = [func] |
| 292 | |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 293 | generated_param_types = [] |
| 294 | def add_generated_param_type(name): |
| 295 | generated_param_types.append(name) |
| 296 | |
| 297 | generated_return_types = [] |
| 298 | def add_generated_return_type(name): |
| 299 | generated_return_types.append(name) |
| 300 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 301 | missing_functions = {} |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 302 | missing_functions_nr = 0 |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 303 | def add_missing_functions(name, module): |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 304 | global missing_functions_nr |
| 305 | |
| 306 | missing_functions_nr = missing_functions_nr + 1 |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 307 | try: |
| 308 | list = missing_functions[module] |
| 309 | list.append(name) |
| 310 | except: |
| 311 | missing_functions[module] = [name] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 312 | |
| 313 | # |
| 314 | # Provide the type generators and destructors for the parameters |
| 315 | # |
| 316 | |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 317 | def type_convert(str, name, info, module, function, pos): |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 318 | # res = string.replace(str, " ", " ") |
| 319 | # res = string.replace(str, " ", " ") |
| 320 | # res = string.replace(str, " ", " ") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 321 | res = string.replace(str, " *", "_ptr") |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 322 | # res = string.replace(str, "*", "_ptr") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 323 | res = string.replace(res, " ", "_") |
| 324 | if res == 'const_char_ptr': |
| 325 | if string.find(name, "file") != -1 or \ |
| 326 | string.find(name, "uri") != -1 or \ |
| 327 | string.find(name, "URI") != -1 or \ |
| 328 | string.find(info, "filename") != -1 or \ |
| 329 | string.find(info, "URI") != -1 or \ |
| 330 | string.find(info, "URL") != -1: |
William M. Brack | 83d9c37 | 2004-11-08 02:26:08 +0000 | [diff] [blame] | 331 | if string.find(function, "Save") != -1 or \ |
| 332 | string.find(function, "Create") != -1 or \ |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 333 | string.find(function, "Write") != -1 or \ |
| 334 | string.find(function, "Fetch") != -1: |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 335 | return('fileoutput') |
| 336 | return('filepath') |
| 337 | if res == 'void_ptr': |
| 338 | if module == 'nanoftp' and name == 'ctx': |
| 339 | return('xmlNanoFTPCtxtPtr') |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 340 | if function == 'xmlNanoFTPNewCtxt' or \ |
| 341 | function == 'xmlNanoFTPConnectTo' or \ |
| 342 | function == 'xmlNanoFTPOpen': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 343 | return('xmlNanoFTPCtxtPtr') |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 344 | if module == 'nanohttp' and name == 'ctx': |
| 345 | return('xmlNanoHTTPCtxtPtr') |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 346 | if function == 'xmlNanoHTTPMethod' or \ |
| 347 | function == 'xmlNanoHTTPMethodRedir' or \ |
| 348 | function == 'xmlNanoHTTPOpen' or \ |
| 349 | function == 'xmlNanoHTTPOpenRedir': |
| 350 | return('xmlNanoHTTPCtxtPtr'); |
| 351 | if function == 'xmlIOHTTPOpen': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 352 | return('xmlNanoHTTPCtxtPtr') |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 353 | if string.find(name, "data") != -1: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 354 | return('userdata') |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 355 | if string.find(name, "user") != -1: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 356 | return('userdata') |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 357 | if res == 'xmlDoc_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 358 | res = 'xmlDocPtr' |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 359 | if res == 'xmlNode_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 360 | res = 'xmlNodePtr' |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 361 | if res == 'xmlDict_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 362 | res = 'xmlDictPtr' |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 363 | if res == 'xmlNodePtr' and pos != 0: |
| 364 | if (function == 'xmlAddChild' and pos == 2) or \ |
| 365 | (function == 'xmlAddChildList' and pos == 2) or \ |
| 366 | (function == 'xmlAddNextSibling' and pos == 2) or \ |
| 367 | (function == 'xmlAddSibling' and pos == 2) or \ |
| 368 | (function == 'xmlDocSetRootElement' and pos == 2) or \ |
| 369 | (function == 'xmlReplaceNode' and pos == 2) or \ |
| 370 | (function == 'xmlTextMerge') or \ |
| 371 | (function == 'xmlAddPrevSibling' and pos == 2): |
| 372 | return('xmlNodePtr_in'); |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 373 | if res == 'const xmlBufferPtr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 374 | res = 'xmlBufferPtr' |
Daniel Veillard | 27f2010 | 2004-11-05 11:50:11 +0000 | [diff] [blame] | 375 | if res == 'xmlChar_ptr' and name == 'name' and \ |
| 376 | string.find(function, "EatName") != -1: |
| 377 | return('eaten_name') |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 378 | if res == 'void_ptr*': |
| 379 | res = 'void_ptr_ptr' |
| 380 | if res == 'char_ptr*': |
| 381 | res = 'char_ptr_ptr' |
| 382 | if res == 'xmlChar_ptr*': |
| 383 | res = 'xmlChar_ptr_ptr' |
| 384 | if res == 'const_xmlChar_ptr*': |
| 385 | res = 'const_xmlChar_ptr_ptr' |
| 386 | if res == 'const_char_ptr*': |
| 387 | res = 'const_char_ptr_ptr' |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 388 | if res == 'FILE_ptr' and module == 'debugXML': |
| 389 | res = 'debug_FILE_ptr'; |
Daniel Veillard | 6128c01 | 2004-11-08 17:16:15 +0000 | [diff] [blame] | 390 | if res == 'int' and name == 'options': |
| 391 | if module == 'parser' or module == 'xmlreader': |
| 392 | res = 'parseroptions' |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 393 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 394 | return res |
| 395 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 396 | known_param_types = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 397 | |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 398 | def is_known_param_type(name, rtype): |
| 399 | global test |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 400 | for type in known_param_types: |
| 401 | if type == name: |
| 402 | return 1 |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 403 | for type in generated_param_types: |
| 404 | if type == name: |
| 405 | return 1 |
| 406 | |
| 407 | if name[-3:] == 'Ptr' or name[-4:] == '_ptr': |
| 408 | if rtype[0:6] == 'const ': |
| 409 | crtype = rtype[6:] |
| 410 | else: |
| 411 | crtype = rtype |
| 412 | |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 413 | define = 0 |
| 414 | if modules_defines.has_key(module): |
| 415 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 416 | define = 1 |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 417 | test.write(""" |
| 418 | #define gen_nb_%s 1 |
| 419 | static %s gen_%s(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 420 | return(NULL); |
| 421 | } |
| 422 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 423 | } |
| 424 | """ % (name, crtype, name, name, rtype)) |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 425 | if define == 1: |
| 426 | test.write("#endif\n\n") |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 427 | add_generated_param_type(name) |
| 428 | return 1 |
| 429 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 430 | return 0 |
| 431 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 432 | # |
| 433 | # Provide the type destructors for the return values |
| 434 | # |
| 435 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 436 | known_return_types = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 437 | |
| 438 | def is_known_return_type(name): |
| 439 | for type in known_return_types: |
| 440 | if type == name: |
| 441 | return 1 |
| 442 | return 0 |
| 443 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 444 | # |
| 445 | # Copy the beginning of the C test program result |
| 446 | # |
| 447 | |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 448 | try: |
| 449 | input = open("testapi.c", "r") |
| 450 | except: |
| 451 | input = open(srcPref + "testapi.c", "r") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 452 | test = open('testapi.c.new', 'w') |
| 453 | |
| 454 | def compare_and_save(): |
| 455 | global test |
| 456 | |
| 457 | test.close() |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 458 | try: |
| 459 | input = open("testapi.c", "r").read() |
| 460 | except: |
| 461 | input = '' |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 462 | test = open('testapi.c.new', "r").read() |
| 463 | if input != test: |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 464 | try: |
| 465 | os.system("rm testapi.c; mv testapi.c.new testapi.c") |
| 466 | except: |
| 467 | os.system("mv testapi.c.new testapi.c") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 468 | print("Updated testapi.c") |
| 469 | else: |
| 470 | print("Generated testapi.c is identical") |
| 471 | |
| 472 | line = input.readline() |
| 473 | while line != "": |
| 474 | if line == "/* CUT HERE: everything below that line is generated */\n": |
| 475 | break; |
| 476 | if line[0:15] == "#define gen_nb_": |
| 477 | type = string.split(line[15:])[0] |
| 478 | known_param_types.append(type) |
| 479 | if line[0:19] == "static void desret_": |
| 480 | type = string.split(line[19:], '(')[0] |
| 481 | known_return_types.append(type) |
| 482 | test.write(line) |
| 483 | line = input.readline() |
| 484 | input.close() |
| 485 | |
| 486 | if line == "": |
| 487 | print "Could not find the CUT marker in testapi.c skipping generation" |
| 488 | test.close() |
| 489 | sys.exit(0) |
| 490 | |
| 491 | print("Scanned testapi.c: found %d parameters types and %d return types\n" % ( |
| 492 | len(known_param_types), len(known_return_types))) |
| 493 | test.write("/* CUT HERE: everything below that line is generated */\n") |
| 494 | |
| 495 | |
| 496 | # |
| 497 | # Open the input API description |
| 498 | # |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 499 | doc = libxml2.readFile(srcPref + 'doc/libxml2-api.xml', None, 0) |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 500 | if doc == None: |
| 501 | print "Failed to load doc/libxml2-api.xml" |
| 502 | sys.exit(1) |
| 503 | ctxt = doc.xpathNewContext() |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 504 | |
| 505 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 506 | # Generate a list of all function parameters and select only |
| 507 | # those used in the api tests |
| 508 | # |
| 509 | argtypes = {} |
| 510 | args = ctxt.xpathEval("/api/symbols/function/arg") |
| 511 | for arg in args: |
| 512 | mod = arg.xpathEval('string(../@file)') |
| 513 | func = arg.xpathEval('string(../@name)') |
| 514 | if (mod not in skipped_modules) and (func not in skipped_functions): |
| 515 | type = arg.xpathEval('string(@type)') |
| 516 | if not argtypes.has_key(type): |
| 517 | argtypes[type] = func |
| 518 | |
| 519 | # similarly for return types |
| 520 | rettypes = {} |
| 521 | rets = ctxt.xpathEval("/api/symbols/function/return") |
| 522 | for ret in rets: |
| 523 | mod = ret.xpathEval('string(../@file)') |
| 524 | func = ret.xpathEval('string(../@name)') |
| 525 | if (mod not in skipped_modules) and (func not in skipped_functions): |
| 526 | type = ret.xpathEval('string(@type)') |
| 527 | if not rettypes.has_key(type): |
| 528 | rettypes[type] = func |
| 529 | |
| 530 | # |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 531 | # Generate constructors and return type handling for all enums |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 532 | # which are used as function parameters |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 533 | # |
| 534 | enums = ctxt.xpathEval("/api/symbols/typedef[@type='enum']") |
| 535 | for enum in enums: |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 536 | module = enum.xpathEval('string(@file)') |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 537 | name = enum.xpathEval('string(@name)') |
| 538 | # |
| 539 | # Skip any enums which are not in our filtered lists |
| 540 | # |
| 541 | if (name == None) or ((name not in argtypes) and (name not in rettypes)): |
| 542 | continue; |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 543 | define = 0 |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 544 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 545 | if argtypes.has_key(name) and is_known_param_type(name, name) == 0: |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 546 | values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name) |
| 547 | i = 0 |
| 548 | vals = [] |
| 549 | for value in values: |
| 550 | vname = value.xpathEval('string(@name)') |
| 551 | if vname == None: |
| 552 | continue; |
| 553 | i = i + 1 |
| 554 | if i >= 5: |
| 555 | break; |
| 556 | vals.append(vname) |
| 557 | if vals == []: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 558 | print "Didn't find any value for enum %s" % (name) |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 559 | continue |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 560 | if modules_defines.has_key(module): |
| 561 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 562 | define = 1 |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 563 | test.write("#define gen_nb_%s %d\n" % (name, len(vals))) |
| 564 | test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" % |
| 565 | (name, name)) |
| 566 | i = 1 |
| 567 | for value in vals: |
| 568 | test.write(" if (no == %d) return(%s);\n" % (i, value)) |
| 569 | i = i + 1 |
| 570 | test.write(""" return(0); |
| 571 | } |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 572 | |
| 573 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 574 | } |
| 575 | |
| 576 | """ % (name, name)); |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 577 | known_param_types.append(name) |
| 578 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 579 | if (is_known_return_type(name) == 0) and (name in rettypes): |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 580 | if define == 0 and modules_defines.has_key(module): |
| 581 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 582 | define = 1 |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 583 | test.write("""static void desret_%s(%s val ATTRIBUTE_UNUSED) { |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 584 | } |
| 585 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 586 | """ % (name, name)) |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 587 | known_return_types.append(name) |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 588 | if define == 1: |
| 589 | test.write("#endif\n\n") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 590 | |
| 591 | # |
| 592 | # Load the interfaces |
| 593 | # |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 594 | headers = ctxt.xpathEval("/api/files/file") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 595 | for file in headers: |
| 596 | name = file.xpathEval('string(@name)') |
| 597 | if (name == None) or (name == ''): |
| 598 | continue |
| 599 | |
| 600 | # |
| 601 | # Some module may be skipped because they don't really consists |
| 602 | # of user callable APIs |
| 603 | # |
| 604 | if is_skipped_module(name): |
| 605 | continue |
| 606 | |
| 607 | # |
| 608 | # do not test deprecated APIs |
| 609 | # |
| 610 | desc = file.xpathEval('string(description)') |
| 611 | if string.find(desc, 'DEPRECATED') != -1: |
| 612 | print "Skipping deprecated interface %s" % name |
| 613 | continue; |
| 614 | |
| 615 | test.write("#include <libxml/%s.h>\n" % name) |
| 616 | modules.append(name) |
| 617 | |
| 618 | # |
| 619 | # Generate the callers signatures |
| 620 | # |
| 621 | for module in modules: |
| 622 | test.write("static int test_%s(void);\n" % module); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 623 | |
| 624 | # |
| 625 | # Generate the top caller |
| 626 | # |
| 627 | |
| 628 | test.write(""" |
| 629 | /** |
| 630 | * testlibxml2: |
| 631 | * |
| 632 | * Main entry point of the tester for the full libxml2 module, |
| 633 | * it calls all the tester entry point for each module. |
| 634 | * |
| 635 | * Returns the number of error found |
| 636 | */ |
| 637 | static int |
| 638 | testlibxml2(void) |
| 639 | { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 640 | int test_ret = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 641 | |
| 642 | """) |
| 643 | |
| 644 | for module in modules: |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 645 | test.write(" test_ret += test_%s();\n" % module) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 646 | |
| 647 | test.write(""" |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 648 | printf("Total: %d functions, %d tests, %d errors\\n", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 649 | function_tests, call_tests, test_ret); |
| 650 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | """) |
| 654 | |
| 655 | # |
| 656 | # How to handle a function |
| 657 | # |
| 658 | nb_tests = 0 |
| 659 | |
| 660 | def generate_test(module, node): |
| 661 | global test |
| 662 | global nb_tests |
| 663 | nb_cond = 0 |
| 664 | no_gen = 0 |
| 665 | |
| 666 | name = node.xpathEval('string(@name)') |
| 667 | if is_skipped_function(name): |
| 668 | return |
| 669 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 670 | # |
| 671 | # check we know how to handle the args and return values |
| 672 | # and store the informations for the generation |
| 673 | # |
| 674 | try: |
| 675 | args = node.xpathEval("arg") |
| 676 | except: |
| 677 | args = [] |
| 678 | t_args = [] |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 679 | n = 0 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 680 | for arg in args: |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 681 | n = n + 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 682 | rtype = arg.xpathEval("string(@type)") |
| 683 | if rtype == 'void': |
| 684 | break; |
| 685 | info = arg.xpathEval("string(@info)") |
| 686 | nam = arg.xpathEval("string(@name)") |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 687 | type = type_convert(rtype, nam, info, module, name, n) |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 688 | if is_known_param_type(type, rtype) == 0: |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 689 | add_missing_type(type, name); |
| 690 | no_gen = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 691 | if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \ |
| 692 | rtype[0:6] == 'const ': |
| 693 | crtype = rtype[6:] |
| 694 | else: |
| 695 | crtype = rtype |
| 696 | t_args.append((nam, type, rtype, crtype, info)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 697 | |
| 698 | try: |
| 699 | rets = node.xpathEval("return") |
| 700 | except: |
| 701 | rets = [] |
| 702 | t_ret = None |
| 703 | for ret in rets: |
| 704 | rtype = ret.xpathEval("string(@type)") |
| 705 | info = ret.xpathEval("string(@info)") |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 706 | type = type_convert(rtype, 'return', info, module, name, 0) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 707 | if rtype == 'void': |
| 708 | break |
| 709 | if is_known_return_type(type) == 0: |
| 710 | add_missing_type(type, name); |
| 711 | no_gen = 1 |
| 712 | t_ret = (type, rtype, info) |
| 713 | break |
| 714 | |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 715 | test.write(""" |
| 716 | static int |
| 717 | test_%s(void) { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 718 | int test_ret = 0; |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 719 | |
| 720 | """ % (name)) |
| 721 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 722 | if no_gen == 1: |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 723 | add_missing_functions(name, module) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 724 | test.write(""" |
| 725 | /* missing type support */ |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 726 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | """) |
| 730 | return |
| 731 | |
| 732 | try: |
| 733 | conds = node.xpathEval("cond") |
| 734 | for cond in conds: |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 735 | test.write("#if %s\n" % (cond.get_content())) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 736 | nb_cond = nb_cond + 1 |
| 737 | except: |
| 738 | pass |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 739 | |
| 740 | define = 0 |
| 741 | if function_defines.has_key(name): |
| 742 | test.write("#ifdef %s\n" % (function_defines[name])) |
| 743 | define = 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 744 | |
| 745 | # Declare the memory usage counter |
| 746 | no_mem = is_skipped_memcheck(name) |
| 747 | if no_mem == 0: |
| 748 | test.write(" int mem_base;\n"); |
| 749 | |
| 750 | # Declare the return value |
| 751 | if t_ret != None: |
| 752 | test.write(" %s ret_val;\n" % (t_ret[1])) |
| 753 | |
| 754 | # Declare the arguments |
| 755 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 756 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 757 | # add declaration |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 758 | test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 759 | test.write(" int n_%s;\n" % (nam)) |
| 760 | test.write("\n") |
| 761 | |
| 762 | # Cascade loop on of each argument list of values |
| 763 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 764 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 765 | # |
| 766 | test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( |
| 767 | nam, nam, type, nam)) |
| 768 | |
| 769 | # log the memory usage |
| 770 | if no_mem == 0: |
| 771 | test.write(" mem_base = xmlMemBlocks();\n"); |
| 772 | |
| 773 | # prepare the call |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 774 | i = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 775 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 776 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 777 | # |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 778 | test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) |
| 779 | i = i + 1; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 780 | |
| 781 | # do the call, and clanup the result |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 782 | if extra_pre_call.has_key(name): |
| 783 | test.write(" %s\n"% (extra_pre_call[name])) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 784 | if t_ret != None: |
| 785 | test.write("\n ret_val = %s(" % (name)) |
| 786 | need = 0 |
| 787 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 788 | (nam, type, rtype, crtype, info) = arg |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 789 | if need: |
| 790 | test.write(", ") |
| 791 | else: |
| 792 | need = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 793 | if rtype != crtype: |
| 794 | test.write("(%s)" % rtype) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 795 | test.write("%s" % nam); |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 796 | test.write(");\n") |
| 797 | if extra_post_call.has_key(name): |
| 798 | test.write(" %s\n"% (extra_post_call[name])) |
| 799 | test.write(" desret_%s(ret_val);\n" % t_ret[0]) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 800 | else: |
| 801 | test.write("\n %s(" % (name)); |
| 802 | need = 0; |
| 803 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 804 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 805 | if need: |
| 806 | test.write(", ") |
| 807 | else: |
| 808 | need = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 809 | if rtype != crtype: |
| 810 | test.write("(%s)" % rtype) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 811 | test.write("%s" % nam) |
| 812 | test.write(");\n") |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 813 | if extra_post_call.has_key(name): |
| 814 | test.write(" %s\n"% (extra_post_call[name])) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 815 | |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 816 | test.write(" call_tests++;\n"); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 817 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 818 | # Free the arguments |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 819 | i = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 820 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 821 | (nam, type, rtype, crtype, info) = arg; |
William M. Brack | d46c1ca | 2007-02-08 23:34:34 +0000 | [diff] [blame] | 822 | # This is a hack to prevent generating a destructor for the |
| 823 | # 'input' argument in xmlTextReaderSetup. There should be |
| 824 | # a better, more generic way to do this! |
| 825 | if string.find(info, 'destroy') == -1: |
| 826 | test.write(" des_%s(n_%s, " % (type, nam)) |
| 827 | if rtype != crtype: |
| 828 | test.write("(%s)" % rtype) |
| 829 | test.write("%s, %d);\n" % (nam, i)) |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 830 | i = i + 1; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 831 | |
| 832 | test.write(" xmlResetLastError();\n"); |
| 833 | # Check the memory usage |
| 834 | if no_mem == 0: |
| 835 | test.write(""" if (mem_base != xmlMemBlocks()) { |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 836 | printf("Leak of %%d blocks found in %s", |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 837 | xmlMemBlocks() - mem_base); |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 838 | test_ret++; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 839 | """ % (name)); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 840 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 841 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 842 | test.write(""" printf(" %%d", n_%s);\n""" % (nam)) |
| 843 | test.write(""" printf("\\n");\n""") |
| 844 | test.write(" }\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 845 | |
| 846 | for arg in t_args: |
| 847 | test.write(" }\n") |
| 848 | |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 849 | test.write(" function_tests++;\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 850 | # |
| 851 | # end of conditional |
| 852 | # |
| 853 | while nb_cond > 0: |
| 854 | test.write("#endif\n") |
| 855 | nb_cond = nb_cond -1 |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 856 | if define == 1: |
| 857 | test.write("#endif\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 858 | |
| 859 | nb_tests = nb_tests + 1; |
| 860 | |
| 861 | test.write(""" |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 862 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | """) |
| 866 | |
| 867 | # |
| 868 | # Generate all module callers |
| 869 | # |
| 870 | for module in modules: |
| 871 | # gather all the functions exported by that module |
| 872 | try: |
| 873 | functions = ctxt.xpathEval("/api/symbols/function[@file='%s']" % (module)) |
| 874 | except: |
| 875 | print "Failed to gather functions from module %s" % (module) |
| 876 | continue; |
| 877 | |
| 878 | # iterate over all functions in the module generating the test |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 879 | i = 0 |
| 880 | nb_tests_old = nb_tests |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 881 | for function in functions: |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 882 | i = i + 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 883 | generate_test(module, function); |
| 884 | |
| 885 | # header |
| 886 | test.write("""static int |
| 887 | test_%s(void) { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 888 | int test_ret = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 889 | |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 890 | if (quiet == 0) printf("Testing %s : %d of %d functions ...\\n"); |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 891 | """ % (module, module, nb_tests - nb_tests_old, i)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 892 | |
| 893 | # iterate over all functions in the module generating the call |
| 894 | for function in functions: |
| 895 | name = function.xpathEval('string(@name)') |
| 896 | if is_skipped_function(name): |
| 897 | continue |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 898 | test.write(" test_ret += test_%s();\n" % (name)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 899 | |
| 900 | # footer |
| 901 | test.write(""" |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 902 | if (test_ret != 0) |
| 903 | printf("Module %s: %%d errors\\n", test_ret); |
| 904 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 905 | } |
| 906 | """ % (module)) |
| 907 | |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 908 | # |
| 909 | # Generate direct module caller |
| 910 | # |
| 911 | test.write("""static int |
| 912 | test_module(const char *module) { |
| 913 | """); |
| 914 | for module in modules: |
| 915 | test.write(""" if (!strcmp(module, "%s")) return(test_%s());\n""" % ( |
| 916 | module, module)) |
| 917 | test.write(""" return(0); |
| 918 | } |
| 919 | """); |
| 920 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 921 | print "Generated test for %d modules and %d functions" %(len(modules), nb_tests) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 922 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 923 | compare_and_save() |
| 924 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 925 | missing_list = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 926 | for missing in missing_types.keys(): |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 927 | if missing == 'va_list' or missing == '...': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 928 | continue; |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 929 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 930 | n = len(missing_types[missing]) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 931 | missing_list.append((n, missing)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 932 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 933 | def compare_missing(a, b): |
| 934 | return b[0] - a[0] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 935 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 936 | missing_list.sort(compare_missing) |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 937 | print "Missing support for %d functions and %d types see missing.lst" % (missing_functions_nr, len(missing_list)) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 938 | lst = open("missing.lst", "w") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 939 | lst.write("Missing support for %d types" % (len(missing_list))) |
| 940 | lst.write("\n") |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 941 | for miss in missing_list: |
| 942 | lst.write("%s: %d :" % (miss[1], miss[0])) |
| 943 | i = 0 |
| 944 | for n in missing_types[miss[1]]: |
| 945 | i = i + 1 |
| 946 | if i > 5: |
| 947 | lst.write(" ...") |
| 948 | break |
| 949 | lst.write(" %s" % (n)) |
| 950 | lst.write("\n") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 951 | lst.write("\n") |
| 952 | lst.write("\n") |
| 953 | lst.write("Missing support per module"); |
| 954 | for module in missing_functions.keys(): |
| 955 | lst.write("module %s:\n %s\n" % (module, missing_functions[module])) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 956 | |
| 957 | lst.close() |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 958 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 959 | |