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