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 | 29614c7 | 2004-11-26 10:47:26 +0000 | [diff] [blame] | 175 | "htmlParseFile", "htmlCtxtReadFile" # loads the catalogs |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 176 | ] |
| 177 | |
| 178 | # |
| 179 | # Extra code needed for some test cases |
| 180 | # |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 181 | extra_pre_call = { |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 182 | "xmlSAXUserParseFile": """ |
| 183 | #ifdef LIBXML_SAX1_ENABLED |
| 184 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 185 | #endif |
| 186 | """, |
| 187 | "xmlSAXUserParseMemory": """ |
| 188 | #ifdef LIBXML_SAX1_ENABLED |
| 189 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 190 | #endif |
| 191 | """, |
| 192 | "xmlParseBalancedChunkMemory": """ |
| 193 | #ifdef LIBXML_SAX1_ENABLED |
| 194 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 195 | #endif |
| 196 | """, |
| 197 | "xmlParseBalancedChunkMemoryRecover": """ |
| 198 | #ifdef LIBXML_SAX1_ENABLED |
| 199 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 200 | #endif |
| 201 | """, |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 202 | "xmlParserInputBufferCreateFd": |
| 203 | "if (fd >= 0) fd = -1;", |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 204 | } |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 205 | extra_post_call = { |
| 206 | "xmlAddChild": |
| 207 | "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", |
| 208 | "xmlAddChildList": |
| 209 | "if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }", |
| 210 | "xmlAddSibling": |
| 211 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 212 | "xmlAddNextSibling": |
| 213 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 214 | "xmlAddPrevSibling": |
| 215 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 216 | "xmlDocSetRootElement": |
| 217 | "if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }", |
| 218 | "xmlReplaceNode": |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 219 | """if (cur != NULL) { |
| 220 | xmlUnlinkNode(cur); |
| 221 | xmlFreeNode(cur) ; cur = NULL ; } |
| 222 | if (old != NULL) { |
| 223 | xmlUnlinkNode(old); |
| 224 | xmlFreeNode(old) ; old = NULL ; } |
| 225 | ret_val = NULL;""", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 226 | "xmlTextMerge": |
| 227 | """if ((first != NULL) && (first->type != XML_TEXT_NODE)) { |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 228 | xmlUnlinkNode(second); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 229 | xmlFreeNode(second) ; second = NULL ; }""", |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 230 | "xmlBuildQName": |
| 231 | """if ((ret_val != NULL) && (ret_val != ncname) && |
| 232 | (ret_val != prefix) && (ret_val != memory)) |
| 233 | xmlFree(ret_val); |
| 234 | ret_val = NULL;""", |
Daniel Veillard | c394f73 | 2005-01-26 00:04:52 +0000 | [diff] [blame] | 235 | "xmlNewDocElementContent": |
| 236 | """xmlFreeDocElementContent(doc, ret_val); ret_val = NULL;""", |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 237 | "xmlDictReference": "xmlDictFree(dict);", |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 238 | # Functions which deallocates one of their parameters |
| 239 | "xmlXPathConvertBoolean": """val = NULL;""", |
| 240 | "xmlXPathConvertNumber": """val = NULL;""", |
| 241 | "xmlXPathConvertString": """val = NULL;""", |
| 242 | "xmlSaveFileTo": """buf = NULL;""", |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 243 | "xmlSaveFormatFileTo": """buf = NULL;""", |
| 244 | "xmlIOParseDTD": "input = NULL;", |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 245 | "xmlRemoveProp": "cur = NULL;", |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 246 | "xmlNewNs": "if ((node == NULL) && (ret_val != NULL)) xmlFreeNs(ret_val);", |
| 247 | "xmlCopyNamespace": "if (ret_val != NULL) xmlFreeNs(ret_val);", |
| 248 | "xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);", |
| 249 | "xmlNewTextWriter": "if (ret_val != NULL) out = NULL;", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 250 | "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] | 251 | "xmlNewIOInputStream": "if (ret_val != NULL) input = NULL;", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 252 | "htmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 253 | "htmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 254 | "xmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 255 | "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 256 | "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 257 | } |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 258 | |
| 259 | modules = [] |
| 260 | |
| 261 | def is_skipped_module(name): |
| 262 | for mod in skipped_modules: |
| 263 | if mod == name: |
| 264 | return 1 |
| 265 | return 0 |
| 266 | |
| 267 | def is_skipped_function(name): |
| 268 | for fun in skipped_functions: |
| 269 | if fun == name: |
| 270 | return 1 |
| 271 | # Do not test destructors |
| 272 | if string.find(name, 'Free') != -1: |
| 273 | return 1 |
| 274 | return 0 |
| 275 | |
| 276 | def is_skipped_memcheck(name): |
| 277 | for fun in skipped_memcheck: |
| 278 | if fun == name: |
| 279 | return 1 |
| 280 | return 0 |
| 281 | |
| 282 | missing_types = {} |
| 283 | def add_missing_type(name, func): |
| 284 | try: |
| 285 | list = missing_types[name] |
| 286 | list.append(func) |
| 287 | except: |
| 288 | missing_types[name] = [func] |
| 289 | |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 290 | generated_param_types = [] |
| 291 | def add_generated_param_type(name): |
| 292 | generated_param_types.append(name) |
| 293 | |
| 294 | generated_return_types = [] |
| 295 | def add_generated_return_type(name): |
| 296 | generated_return_types.append(name) |
| 297 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 298 | missing_functions = {} |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 299 | missing_functions_nr = 0 |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 300 | def add_missing_functions(name, module): |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 301 | global missing_functions_nr |
| 302 | |
| 303 | missing_functions_nr = missing_functions_nr + 1 |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 304 | try: |
| 305 | list = missing_functions[module] |
| 306 | list.append(name) |
| 307 | except: |
| 308 | missing_functions[module] = [name] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 309 | |
| 310 | # |
| 311 | # Provide the type generators and destructors for the parameters |
| 312 | # |
| 313 | |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 314 | def type_convert(str, name, info, module, function, pos): |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 315 | # res = string.replace(str, " ", " ") |
| 316 | # res = string.replace(str, " ", " ") |
| 317 | # res = string.replace(str, " ", " ") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 318 | res = string.replace(str, " *", "_ptr") |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 319 | # res = string.replace(str, "*", "_ptr") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 320 | res = string.replace(res, " ", "_") |
| 321 | if res == 'const_char_ptr': |
| 322 | if string.find(name, "file") != -1 or \ |
| 323 | string.find(name, "uri") != -1 or \ |
| 324 | string.find(name, "URI") != -1 or \ |
| 325 | string.find(info, "filename") != -1 or \ |
| 326 | string.find(info, "URI") != -1 or \ |
| 327 | string.find(info, "URL") != -1: |
William M. Brack | 83d9c37 | 2004-11-08 02:26:08 +0000 | [diff] [blame] | 328 | if string.find(function, "Save") != -1 or \ |
| 329 | string.find(function, "Create") != -1 or \ |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 330 | string.find(function, "Write") != -1 or \ |
| 331 | string.find(function, "Fetch") != -1: |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 332 | return('fileoutput') |
| 333 | return('filepath') |
| 334 | if res == 'void_ptr': |
| 335 | if module == 'nanoftp' and name == 'ctx': |
| 336 | return('xmlNanoFTPCtxtPtr') |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 337 | if function == 'xmlNanoFTPNewCtxt' or \ |
| 338 | function == 'xmlNanoFTPConnectTo' or \ |
| 339 | function == 'xmlNanoFTPOpen': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 340 | return('xmlNanoFTPCtxtPtr') |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 341 | if module == 'nanohttp' and name == 'ctx': |
| 342 | return('xmlNanoHTTPCtxtPtr') |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 343 | if function == 'xmlNanoHTTPMethod' or \ |
| 344 | function == 'xmlNanoHTTPMethodRedir' or \ |
| 345 | function == 'xmlNanoHTTPOpen' or \ |
| 346 | function == 'xmlNanoHTTPOpenRedir': |
| 347 | return('xmlNanoHTTPCtxtPtr'); |
| 348 | if function == 'xmlIOHTTPOpen': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 349 | return('xmlNanoHTTPCtxtPtr') |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 350 | if string.find(name, "data") != -1: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 351 | return('userdata') |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 352 | if string.find(name, "user") != -1: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 353 | return('userdata') |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 354 | if res == 'xmlDoc_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 355 | res = 'xmlDocPtr' |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 356 | if res == 'xmlNode_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 357 | res = 'xmlNodePtr' |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 358 | if res == 'xmlDict_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 359 | res = 'xmlDictPtr' |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 360 | if res == 'xmlNodePtr' and pos != 0: |
| 361 | if (function == 'xmlAddChild' and pos == 2) or \ |
| 362 | (function == 'xmlAddChildList' and pos == 2) or \ |
| 363 | (function == 'xmlAddNextSibling' and pos == 2) or \ |
| 364 | (function == 'xmlAddSibling' and pos == 2) or \ |
| 365 | (function == 'xmlDocSetRootElement' and pos == 2) or \ |
| 366 | (function == 'xmlReplaceNode' and pos == 2) or \ |
| 367 | (function == 'xmlTextMerge') or \ |
| 368 | (function == 'xmlAddPrevSibling' and pos == 2): |
| 369 | return('xmlNodePtr_in'); |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 370 | if res == 'const xmlBufferPtr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 371 | res = 'xmlBufferPtr' |
Daniel Veillard | 27f2010 | 2004-11-05 11:50:11 +0000 | [diff] [blame] | 372 | if res == 'xmlChar_ptr' and name == 'name' and \ |
| 373 | string.find(function, "EatName") != -1: |
| 374 | return('eaten_name') |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 375 | if res == 'void_ptr*': |
| 376 | res = 'void_ptr_ptr' |
| 377 | if res == 'char_ptr*': |
| 378 | res = 'char_ptr_ptr' |
| 379 | if res == 'xmlChar_ptr*': |
| 380 | res = 'xmlChar_ptr_ptr' |
| 381 | if res == 'const_xmlChar_ptr*': |
| 382 | res = 'const_xmlChar_ptr_ptr' |
| 383 | if res == 'const_char_ptr*': |
| 384 | res = 'const_char_ptr_ptr' |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 385 | if res == 'FILE_ptr' and module == 'debugXML': |
| 386 | res = 'debug_FILE_ptr'; |
Daniel Veillard | 6128c01 | 2004-11-08 17:16:15 +0000 | [diff] [blame] | 387 | if res == 'int' and name == 'options': |
| 388 | if module == 'parser' or module == 'xmlreader': |
| 389 | res = 'parseroptions' |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 390 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 391 | return res |
| 392 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 393 | known_param_types = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 394 | |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 395 | def is_known_param_type(name, rtype): |
| 396 | global test |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 397 | for type in known_param_types: |
| 398 | if type == name: |
| 399 | return 1 |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 400 | for type in generated_param_types: |
| 401 | if type == name: |
| 402 | return 1 |
| 403 | |
| 404 | if name[-3:] == 'Ptr' or name[-4:] == '_ptr': |
| 405 | if rtype[0:6] == 'const ': |
| 406 | crtype = rtype[6:] |
| 407 | else: |
| 408 | crtype = rtype |
| 409 | |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 410 | define = 0 |
| 411 | if modules_defines.has_key(module): |
| 412 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 413 | define = 1 |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 414 | test.write(""" |
| 415 | #define gen_nb_%s 1 |
| 416 | static %s gen_%s(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 417 | return(NULL); |
| 418 | } |
| 419 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 420 | } |
| 421 | """ % (name, crtype, name, name, rtype)) |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 422 | if define == 1: |
| 423 | test.write("#endif\n\n") |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 424 | add_generated_param_type(name) |
| 425 | return 1 |
| 426 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 427 | return 0 |
| 428 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 429 | # |
| 430 | # Provide the type destructors for the return values |
| 431 | # |
| 432 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 433 | known_return_types = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 434 | |
| 435 | def is_known_return_type(name): |
| 436 | for type in known_return_types: |
| 437 | if type == name: |
| 438 | return 1 |
| 439 | return 0 |
| 440 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 441 | # |
| 442 | # Copy the beginning of the C test program result |
| 443 | # |
| 444 | |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 445 | try: |
| 446 | input = open("testapi.c", "r") |
| 447 | except: |
| 448 | input = open(srcPref + "testapi.c", "r") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 449 | test = open('testapi.c.new', 'w') |
| 450 | |
| 451 | def compare_and_save(): |
| 452 | global test |
| 453 | |
| 454 | test.close() |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 455 | try: |
| 456 | input = open("testapi.c", "r").read() |
| 457 | except: |
| 458 | input = '' |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 459 | test = open('testapi.c.new', "r").read() |
| 460 | if input != test: |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 461 | try: |
| 462 | os.system("rm testapi.c; mv testapi.c.new testapi.c") |
| 463 | except: |
| 464 | os.system("mv testapi.c.new testapi.c") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 465 | print("Updated testapi.c") |
| 466 | else: |
| 467 | print("Generated testapi.c is identical") |
| 468 | |
| 469 | line = input.readline() |
| 470 | while line != "": |
| 471 | if line == "/* CUT HERE: everything below that line is generated */\n": |
| 472 | break; |
| 473 | if line[0:15] == "#define gen_nb_": |
| 474 | type = string.split(line[15:])[0] |
| 475 | known_param_types.append(type) |
| 476 | if line[0:19] == "static void desret_": |
| 477 | type = string.split(line[19:], '(')[0] |
| 478 | known_return_types.append(type) |
| 479 | test.write(line) |
| 480 | line = input.readline() |
| 481 | input.close() |
| 482 | |
| 483 | if line == "": |
| 484 | print "Could not find the CUT marker in testapi.c skipping generation" |
| 485 | test.close() |
| 486 | sys.exit(0) |
| 487 | |
| 488 | print("Scanned testapi.c: found %d parameters types and %d return types\n" % ( |
| 489 | len(known_param_types), len(known_return_types))) |
| 490 | test.write("/* CUT HERE: everything below that line is generated */\n") |
| 491 | |
| 492 | |
| 493 | # |
| 494 | # Open the input API description |
| 495 | # |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 496 | doc = libxml2.readFile(srcPref + 'doc/libxml2-api.xml', None, 0) |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 497 | if doc == None: |
| 498 | print "Failed to load doc/libxml2-api.xml" |
| 499 | sys.exit(1) |
| 500 | ctxt = doc.xpathNewContext() |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 501 | |
| 502 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 503 | # Generate a list of all function parameters and select only |
| 504 | # those used in the api tests |
| 505 | # |
| 506 | argtypes = {} |
| 507 | args = ctxt.xpathEval("/api/symbols/function/arg") |
| 508 | for arg in args: |
| 509 | mod = arg.xpathEval('string(../@file)') |
| 510 | func = arg.xpathEval('string(../@name)') |
| 511 | if (mod not in skipped_modules) and (func not in skipped_functions): |
| 512 | type = arg.xpathEval('string(@type)') |
| 513 | if not argtypes.has_key(type): |
| 514 | argtypes[type] = func |
| 515 | |
| 516 | # similarly for return types |
| 517 | rettypes = {} |
| 518 | rets = ctxt.xpathEval("/api/symbols/function/return") |
| 519 | for ret in rets: |
| 520 | mod = ret.xpathEval('string(../@file)') |
| 521 | func = ret.xpathEval('string(../@name)') |
| 522 | if (mod not in skipped_modules) and (func not in skipped_functions): |
| 523 | type = ret.xpathEval('string(@type)') |
| 524 | if not rettypes.has_key(type): |
| 525 | rettypes[type] = func |
| 526 | |
| 527 | # |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 528 | # Generate constructors and return type handling for all enums |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 529 | # which are used as function parameters |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 530 | # |
| 531 | enums = ctxt.xpathEval("/api/symbols/typedef[@type='enum']") |
| 532 | for enum in enums: |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 533 | module = enum.xpathEval('string(@file)') |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 534 | name = enum.xpathEval('string(@name)') |
| 535 | # |
| 536 | # Skip any enums which are not in our filtered lists |
| 537 | # |
| 538 | if (name == None) or ((name not in argtypes) and (name not in rettypes)): |
| 539 | continue; |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 540 | define = 0 |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 541 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 542 | 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] | 543 | values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name) |
| 544 | i = 0 |
| 545 | vals = [] |
| 546 | for value in values: |
| 547 | vname = value.xpathEval('string(@name)') |
| 548 | if vname == None: |
| 549 | continue; |
| 550 | i = i + 1 |
| 551 | if i >= 5: |
| 552 | break; |
| 553 | vals.append(vname) |
| 554 | if vals == []: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 555 | print "Didn't find any value for enum %s" % (name) |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 556 | continue |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 557 | if modules_defines.has_key(module): |
| 558 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 559 | define = 1 |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 560 | test.write("#define gen_nb_%s %d\n" % (name, len(vals))) |
| 561 | test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" % |
| 562 | (name, name)) |
| 563 | i = 1 |
| 564 | for value in vals: |
| 565 | test.write(" if (no == %d) return(%s);\n" % (i, value)) |
| 566 | i = i + 1 |
| 567 | test.write(""" return(0); |
| 568 | } |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 569 | |
| 570 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 571 | } |
| 572 | |
| 573 | """ % (name, name)); |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 574 | known_param_types.append(name) |
| 575 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 576 | if (is_known_return_type(name) == 0) and (name in rettypes): |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 577 | if define == 0 and modules_defines.has_key(module): |
| 578 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 579 | define = 1 |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 580 | test.write("""static void desret_%s(%s val ATTRIBUTE_UNUSED) { |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 581 | } |
| 582 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 583 | """ % (name, name)) |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 584 | known_return_types.append(name) |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 585 | if define == 1: |
| 586 | test.write("#endif\n\n") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 587 | |
| 588 | # |
| 589 | # Load the interfaces |
| 590 | # |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 591 | headers = ctxt.xpathEval("/api/files/file") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 592 | for file in headers: |
| 593 | name = file.xpathEval('string(@name)') |
| 594 | if (name == None) or (name == ''): |
| 595 | continue |
| 596 | |
| 597 | # |
| 598 | # Some module may be skipped because they don't really consists |
| 599 | # of user callable APIs |
| 600 | # |
| 601 | if is_skipped_module(name): |
| 602 | continue |
| 603 | |
| 604 | # |
| 605 | # do not test deprecated APIs |
| 606 | # |
| 607 | desc = file.xpathEval('string(description)') |
| 608 | if string.find(desc, 'DEPRECATED') != -1: |
| 609 | print "Skipping deprecated interface %s" % name |
| 610 | continue; |
| 611 | |
| 612 | test.write("#include <libxml/%s.h>\n" % name) |
| 613 | modules.append(name) |
| 614 | |
| 615 | # |
| 616 | # Generate the callers signatures |
| 617 | # |
| 618 | for module in modules: |
| 619 | test.write("static int test_%s(void);\n" % module); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 620 | |
| 621 | # |
| 622 | # Generate the top caller |
| 623 | # |
| 624 | |
| 625 | test.write(""" |
| 626 | /** |
| 627 | * testlibxml2: |
| 628 | * |
| 629 | * Main entry point of the tester for the full libxml2 module, |
| 630 | * it calls all the tester entry point for each module. |
| 631 | * |
| 632 | * Returns the number of error found |
| 633 | */ |
| 634 | static int |
| 635 | testlibxml2(void) |
| 636 | { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 637 | int test_ret = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 638 | |
| 639 | """) |
| 640 | |
| 641 | for module in modules: |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 642 | test.write(" test_ret += test_%s();\n" % module) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 643 | |
| 644 | test.write(""" |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 645 | printf("Total: %d functions, %d tests, %d errors\\n", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 646 | function_tests, call_tests, test_ret); |
| 647 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | """) |
| 651 | |
| 652 | # |
| 653 | # How to handle a function |
| 654 | # |
| 655 | nb_tests = 0 |
| 656 | |
| 657 | def generate_test(module, node): |
| 658 | global test |
| 659 | global nb_tests |
| 660 | nb_cond = 0 |
| 661 | no_gen = 0 |
| 662 | |
| 663 | name = node.xpathEval('string(@name)') |
| 664 | if is_skipped_function(name): |
| 665 | return |
| 666 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 667 | # |
| 668 | # check we know how to handle the args and return values |
| 669 | # and store the informations for the generation |
| 670 | # |
| 671 | try: |
| 672 | args = node.xpathEval("arg") |
| 673 | except: |
| 674 | args = [] |
| 675 | t_args = [] |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 676 | n = 0 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 677 | for arg in args: |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 678 | n = n + 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 679 | rtype = arg.xpathEval("string(@type)") |
| 680 | if rtype == 'void': |
| 681 | break; |
| 682 | info = arg.xpathEval("string(@info)") |
| 683 | nam = arg.xpathEval("string(@name)") |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 684 | type = type_convert(rtype, nam, info, module, name, n) |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 685 | if is_known_param_type(type, rtype) == 0: |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 686 | add_missing_type(type, name); |
| 687 | no_gen = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 688 | if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \ |
| 689 | rtype[0:6] == 'const ': |
| 690 | crtype = rtype[6:] |
| 691 | else: |
| 692 | crtype = rtype |
| 693 | t_args.append((nam, type, rtype, crtype, info)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 694 | |
| 695 | try: |
| 696 | rets = node.xpathEval("return") |
| 697 | except: |
| 698 | rets = [] |
| 699 | t_ret = None |
| 700 | for ret in rets: |
| 701 | rtype = ret.xpathEval("string(@type)") |
| 702 | info = ret.xpathEval("string(@info)") |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 703 | type = type_convert(rtype, 'return', info, module, name, 0) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 704 | if rtype == 'void': |
| 705 | break |
| 706 | if is_known_return_type(type) == 0: |
| 707 | add_missing_type(type, name); |
| 708 | no_gen = 1 |
| 709 | t_ret = (type, rtype, info) |
| 710 | break |
| 711 | |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 712 | test.write(""" |
| 713 | static int |
| 714 | test_%s(void) { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 715 | int test_ret = 0; |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 716 | |
| 717 | """ % (name)) |
| 718 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 719 | if no_gen == 1: |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 720 | add_missing_functions(name, module) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 721 | test.write(""" |
| 722 | /* missing type support */ |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 723 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | """) |
| 727 | return |
| 728 | |
| 729 | try: |
| 730 | conds = node.xpathEval("cond") |
| 731 | for cond in conds: |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 732 | test.write("#if %s\n" % (cond.get_content())) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 733 | nb_cond = nb_cond + 1 |
| 734 | except: |
| 735 | pass |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 736 | |
| 737 | define = 0 |
| 738 | if function_defines.has_key(name): |
| 739 | test.write("#ifdef %s\n" % (function_defines[name])) |
| 740 | define = 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 741 | |
| 742 | # Declare the memory usage counter |
| 743 | no_mem = is_skipped_memcheck(name) |
| 744 | if no_mem == 0: |
| 745 | test.write(" int mem_base;\n"); |
| 746 | |
| 747 | # Declare the return value |
| 748 | if t_ret != None: |
| 749 | test.write(" %s ret_val;\n" % (t_ret[1])) |
| 750 | |
| 751 | # Declare the arguments |
| 752 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 753 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 754 | # add declaration |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 755 | test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 756 | test.write(" int n_%s;\n" % (nam)) |
| 757 | test.write("\n") |
| 758 | |
| 759 | # Cascade loop on of each argument list of values |
| 760 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 761 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 762 | # |
| 763 | test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( |
| 764 | nam, nam, type, nam)) |
| 765 | |
| 766 | # log the memory usage |
| 767 | if no_mem == 0: |
| 768 | test.write(" mem_base = xmlMemBlocks();\n"); |
| 769 | |
| 770 | # prepare the call |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 771 | i = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 772 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 773 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 774 | # |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 775 | test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) |
| 776 | i = i + 1; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 777 | |
| 778 | # do the call, and clanup the result |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 779 | if extra_pre_call.has_key(name): |
| 780 | test.write(" %s\n"% (extra_pre_call[name])) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 781 | if t_ret != None: |
| 782 | test.write("\n ret_val = %s(" % (name)) |
| 783 | need = 0 |
| 784 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 785 | (nam, type, rtype, crtype, info) = arg |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 786 | if need: |
| 787 | test.write(", ") |
| 788 | else: |
| 789 | need = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 790 | if rtype != crtype: |
| 791 | test.write("(%s)" % rtype) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 792 | test.write("%s" % nam); |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 793 | test.write(");\n") |
| 794 | if extra_post_call.has_key(name): |
| 795 | test.write(" %s\n"% (extra_post_call[name])) |
| 796 | test.write(" desret_%s(ret_val);\n" % t_ret[0]) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 797 | else: |
| 798 | test.write("\n %s(" % (name)); |
| 799 | need = 0; |
| 800 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 801 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 802 | if need: |
| 803 | test.write(", ") |
| 804 | else: |
| 805 | need = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 806 | if rtype != crtype: |
| 807 | test.write("(%s)" % rtype) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 808 | test.write("%s" % nam) |
| 809 | test.write(");\n") |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 810 | if extra_post_call.has_key(name): |
| 811 | test.write(" %s\n"% (extra_post_call[name])) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 812 | |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 813 | test.write(" call_tests++;\n"); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 814 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 815 | # Free the arguments |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 816 | i = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 817 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 818 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 819 | # |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 820 | test.write(" des_%s(n_%s, " % (type, nam)) |
| 821 | if rtype != crtype: |
| 822 | test.write("(%s)" % rtype) |
| 823 | test.write("%s, %d);\n" % (nam, i)) |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 824 | i = i + 1; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 825 | |
| 826 | test.write(" xmlResetLastError();\n"); |
| 827 | # Check the memory usage |
| 828 | if no_mem == 0: |
| 829 | test.write(""" if (mem_base != xmlMemBlocks()) { |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 830 | printf("Leak of %%d blocks found in %s", |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 831 | xmlMemBlocks() - mem_base); |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 832 | test_ret++; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 833 | """ % (name)); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 834 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 835 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 836 | test.write(""" printf(" %%d", n_%s);\n""" % (nam)) |
| 837 | test.write(""" printf("\\n");\n""") |
| 838 | test.write(" }\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 839 | |
| 840 | for arg in t_args: |
| 841 | test.write(" }\n") |
| 842 | |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 843 | test.write(" function_tests++;\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 844 | # |
| 845 | # end of conditional |
| 846 | # |
| 847 | while nb_cond > 0: |
| 848 | test.write("#endif\n") |
| 849 | nb_cond = nb_cond -1 |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 850 | if define == 1: |
| 851 | test.write("#endif\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 852 | |
| 853 | nb_tests = nb_tests + 1; |
| 854 | |
| 855 | test.write(""" |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 856 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | """) |
| 860 | |
| 861 | # |
| 862 | # Generate all module callers |
| 863 | # |
| 864 | for module in modules: |
| 865 | # gather all the functions exported by that module |
| 866 | try: |
| 867 | functions = ctxt.xpathEval("/api/symbols/function[@file='%s']" % (module)) |
| 868 | except: |
| 869 | print "Failed to gather functions from module %s" % (module) |
| 870 | continue; |
| 871 | |
| 872 | # iterate over all functions in the module generating the test |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 873 | i = 0 |
| 874 | nb_tests_old = nb_tests |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 875 | for function in functions: |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 876 | i = i + 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 877 | generate_test(module, function); |
| 878 | |
| 879 | # header |
| 880 | test.write("""static int |
| 881 | test_%s(void) { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 882 | int test_ret = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 883 | |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 884 | if (quiet == 0) printf("Testing %s : %d of %d functions ...\\n"); |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 885 | """ % (module, module, nb_tests - nb_tests_old, i)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 886 | |
| 887 | # iterate over all functions in the module generating the call |
| 888 | for function in functions: |
| 889 | name = function.xpathEval('string(@name)') |
| 890 | if is_skipped_function(name): |
| 891 | continue |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 892 | test.write(" test_ret += test_%s();\n" % (name)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 893 | |
| 894 | # footer |
| 895 | test.write(""" |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 896 | if (test_ret != 0) |
| 897 | printf("Module %s: %%d errors\\n", test_ret); |
| 898 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 899 | } |
| 900 | """ % (module)) |
| 901 | |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 902 | # |
| 903 | # Generate direct module caller |
| 904 | # |
| 905 | test.write("""static int |
| 906 | test_module(const char *module) { |
| 907 | """); |
| 908 | for module in modules: |
| 909 | test.write(""" if (!strcmp(module, "%s")) return(test_%s());\n""" % ( |
| 910 | module, module)) |
| 911 | test.write(""" return(0); |
| 912 | } |
| 913 | """); |
| 914 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 915 | 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] | 916 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 917 | compare_and_save() |
| 918 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 919 | missing_list = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 920 | for missing in missing_types.keys(): |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 921 | if missing == 'va_list' or missing == '...': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 922 | continue; |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 923 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 924 | n = len(missing_types[missing]) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 925 | missing_list.append((n, missing)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 926 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 927 | def compare_missing(a, b): |
| 928 | return b[0] - a[0] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 929 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 930 | missing_list.sort(compare_missing) |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 931 | 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] | 932 | lst = open("missing.lst", "w") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 933 | lst.write("Missing support for %d types" % (len(missing_list))) |
| 934 | lst.write("\n") |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 935 | for miss in missing_list: |
| 936 | lst.write("%s: %d :" % (miss[1], miss[0])) |
| 937 | i = 0 |
| 938 | for n in missing_types[miss[1]]: |
| 939 | i = i + 1 |
| 940 | if i > 5: |
| 941 | lst.write(" ...") |
| 942 | break |
| 943 | lst.write(" %s" % (n)) |
| 944 | lst.write("\n") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 945 | lst.write("\n") |
| 946 | lst.write("\n") |
| 947 | lst.write("Missing support per module"); |
| 948 | for module in missing_functions.keys(): |
| 949 | lst.write("module %s:\n %s\n" % (module, missing_functions[module])) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 950 | |
| 951 | lst.close() |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 952 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 953 | |