diff options
| author | Martin Jansa <martin.jansa@gmail.com> | 2022-08-08 23:27:30 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-18 17:52:23 +0100 |
| commit | 54846f581e6a80caadb5db6fc392efc46114a15d (patch) | |
| tree | 64187646be7a6fb4bb23ee506bb8f280a8aad312 /meta | |
| parent | b361f2a931bc83c35ae2c4088dca2e3477a964f4 (diff) | |
| download | poky-54846f581e6a80caadb5db6fc392efc46114a15d.tar.gz | |
libxml2: Port gentest.py to Python-3
* but it still won't work well on hosts without libxml2, make
sure to use pre-generated testapi.c in do_compile_ptest
* this is reproducible with SOURCE_DATE_EPOCH set to 0 which
e.g. meta-updater still sets by default for DISTROs which
use it :(, see https://github.com/uptane/meta-updater/pull/35
(From OE-Core rev: 2f78dbcb300e7deae6cf39263e874ee8776d7a7b)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/recipes-core/libxml/libxml2/0001-Port-gentest.py-to-Python-3.patch | 813 | ||||
| -rw-r--r-- | meta/recipes-core/libxml/libxml2_2.9.10.bb | 11 |
2 files changed, 824 insertions, 0 deletions
diff --git a/meta/recipes-core/libxml/libxml2/0001-Port-gentest.py-to-Python-3.patch b/meta/recipes-core/libxml/libxml2/0001-Port-gentest.py-to-Python-3.patch new file mode 100644 index 0000000000..b0d26d1c08 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/0001-Port-gentest.py-to-Python-3.patch | |||
| @@ -0,0 +1,813 @@ | |||
| 1 | From b5125000917810731bc28055c0445d571121f80e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Nick Wellnhofer <wellnhofer@aevum.de> | ||
| 3 | Date: Thu, 21 Apr 2022 00:45:58 +0200 | ||
| 4 | Subject: [PATCH] Port gentest.py to Python 3 | ||
| 5 | |||
| 6 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/-/commit/343fc1421cdae097fa6c4cffeb1a065a40be6bbb] | ||
| 7 | |||
| 8 | * fixes: | ||
| 9 | |||
| 10 | make[1]: 'testReader' is up to date. | ||
| 11 | File "../libxml2-2.9.10/gentest.py", line 11 | ||
| 12 | print "libxml2 python bindings not available, skipping testapi.c generation" | ||
| 13 | ^ | ||
| 14 | SyntaxError: Missing parentheses in call to 'print'. Did you mean print("libxml2 python bindings not available, skipping testapi.c generation")? | ||
| 15 | make[1]: [Makefile:2078: testapi.c] Error 1 (ignored) | ||
| 16 | |||
| 17 | ... | ||
| 18 | |||
| 19 | make[1]: 'testReader' is up to date. | ||
| 20 | File "../libxml2-2.9.10/gentest.py", line 271 | ||
| 21 | return 1 | ||
| 22 | ^ | ||
| 23 | TabError: inconsistent use of tabs and spaces in indentation | ||
| 24 | make[1]: [Makefile:2078: testapi.c] Error 1 (ignored) | ||
| 25 | |||
| 26 | ... | ||
| 27 | |||
| 28 | aarch64-oe-linux-gcc: error: testapi.c: No such file or directory | ||
| 29 | aarch64-oe-linux-gcc: fatal error: no input files | ||
| 30 | compilation terminated. | ||
| 31 | make[1]: *** [Makefile:1275: testapi.o] Error 1 | ||
| 32 | |||
| 33 | But there is still a bit mystery why it worked before, because check-am | ||
| 34 | calls gentest.py with $(PYTHON), so it ignores the shebang in the script | ||
| 35 | and libxml2 is using python3native (through python3targetconfig.bbclass) | ||
| 36 | so something like: | ||
| 37 | |||
| 38 | libxml2/2.9.10-r0/recipe-sysroot-native/usr/bin/python3-native/python3 gentest.py | ||
| 39 | |||
| 40 | But that still fails (now without SyntaxError) with: | ||
| 41 | libxml2 python bindings not available, skipping testapi.c generation | ||
| 42 | |||
| 43 | because we don't have dependency on libxml2-native (to provide libxml2 | ||
| 44 | python bindings form python3native) and exported PYTHON_SITE_PACKAGES | ||
| 45 | might be useless (e.g. /usr/lib/python3.8/site-packages on Ubuntu-22.10 | ||
| 46 | which uses python 3.10 and there is no site-packages with libxml2) | ||
| 47 | |||
| 48 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 49 | --- | ||
| 50 | gentest.py | 421 ++++++++++++++++++++++++++--------------------------- | ||
| 51 | 1 file changed, 209 insertions(+), 212 deletions(-) | ||
| 52 | |||
| 53 | diff --git a/gentest.py b/gentest.py | ||
| 54 | index b763300..0756706 100755 | ||
| 55 | --- a/gentest.py | ||
| 56 | +++ b/gentest.py | ||
| 57 | @@ -8,7 +8,7 @@ import string | ||
| 58 | try: | ||
| 59 | import libxml2 | ||
| 60 | except: | ||
| 61 | - print "libxml2 python bindings not available, skipping testapi.c generation" | ||
| 62 | + print("libxml2 python bindings not available, skipping testapi.c generation") | ||
| 63 | sys.exit(0) | ||
| 64 | |||
| 65 | if len(sys.argv) > 1: | ||
| 66 | @@ -227,7 +227,7 @@ extra_post_call = { | ||
| 67 | if (old != NULL) { | ||
| 68 | xmlUnlinkNode(old); | ||
| 69 | xmlFreeNode(old) ; old = NULL ; } | ||
| 70 | - ret_val = NULL;""", | ||
| 71 | +\t ret_val = NULL;""", | ||
| 72 | "xmlTextMerge": | ||
| 73 | """if ((first != NULL) && (first->type != XML_TEXT_NODE)) { | ||
| 74 | xmlUnlinkNode(second); | ||
| 75 | @@ -236,7 +236,7 @@ extra_post_call = { | ||
| 76 | """if ((ret_val != NULL) && (ret_val != ncname) && | ||
| 77 | (ret_val != prefix) && (ret_val != memory)) | ||
| 78 | xmlFree(ret_val); | ||
| 79 | - ret_val = NULL;""", | ||
| 80 | +\t ret_val = NULL;""", | ||
| 81 | "xmlNewDocElementContent": | ||
| 82 | """xmlFreeDocElementContent(doc, ret_val); ret_val = NULL;""", | ||
| 83 | "xmlDictReference": "xmlDictFree(dict);", | ||
| 84 | @@ -268,29 +268,29 @@ modules = [] | ||
| 85 | def is_skipped_module(name): | ||
| 86 | for mod in skipped_modules: | ||
| 87 | if mod == name: | ||
| 88 | - return 1 | ||
| 89 | + return 1 | ||
| 90 | return 0 | ||
| 91 | |||
| 92 | def is_skipped_function(name): | ||
| 93 | for fun in skipped_functions: | ||
| 94 | if fun == name: | ||
| 95 | - return 1 | ||
| 96 | + return 1 | ||
| 97 | # Do not test destructors | ||
| 98 | - if string.find(name, 'Free') != -1: | ||
| 99 | + if name.find('Free') != -1: | ||
| 100 | return 1 | ||
| 101 | return 0 | ||
| 102 | |||
| 103 | def is_skipped_memcheck(name): | ||
| 104 | for fun in skipped_memcheck: | ||
| 105 | if fun == name: | ||
| 106 | - return 1 | ||
| 107 | + return 1 | ||
| 108 | return 0 | ||
| 109 | |||
| 110 | missing_types = {} | ||
| 111 | def add_missing_type(name, func): | ||
| 112 | try: | ||
| 113 | list = missing_types[name] | ||
| 114 | - list.append(func) | ||
| 115 | + list.append(func) | ||
| 116 | except: | ||
| 117 | missing_types[name] = [func] | ||
| 118 | |||
| 119 | @@ -310,7 +310,7 @@ def add_missing_functions(name, module): | ||
| 120 | missing_functions_nr = missing_functions_nr + 1 | ||
| 121 | try: | ||
| 122 | list = missing_functions[module] | ||
| 123 | - list.append(name) | ||
| 124 | + list.append(name) | ||
| 125 | except: | ||
| 126 | missing_functions[module] = [name] | ||
| 127 | |||
| 128 | @@ -319,45 +319,45 @@ def add_missing_functions(name, module): | ||
| 129 | # | ||
| 130 | |||
| 131 | def type_convert(str, name, info, module, function, pos): | ||
| 132 | -# res = string.replace(str, " ", " ") | ||
| 133 | -# res = string.replace(str, " ", " ") | ||
| 134 | -# res = string.replace(str, " ", " ") | ||
| 135 | - res = string.replace(str, " *", "_ptr") | ||
| 136 | -# res = string.replace(str, "*", "_ptr") | ||
| 137 | - res = string.replace(res, " ", "_") | ||
| 138 | +# res = str.replace(" ", " ") | ||
| 139 | +# res = str.replace(" ", " ") | ||
| 140 | +# res = str.replace(" ", " ") | ||
| 141 | + res = str.replace(" *", "_ptr") | ||
| 142 | +# res = str.replace("*", "_ptr") | ||
| 143 | + res = res.replace(" ", "_") | ||
| 144 | if res == 'const_char_ptr': | ||
| 145 | - if string.find(name, "file") != -1 or \ | ||
| 146 | - string.find(name, "uri") != -1 or \ | ||
| 147 | - string.find(name, "URI") != -1 or \ | ||
| 148 | - string.find(info, "filename") != -1 or \ | ||
| 149 | - string.find(info, "URI") != -1 or \ | ||
| 150 | - string.find(info, "URL") != -1: | ||
| 151 | - if string.find(function, "Save") != -1 or \ | ||
| 152 | - string.find(function, "Create") != -1 or \ | ||
| 153 | - string.find(function, "Write") != -1 or \ | ||
| 154 | - string.find(function, "Fetch") != -1: | ||
| 155 | - return('fileoutput') | ||
| 156 | - return('filepath') | ||
| 157 | + if name.find("file") != -1 or \ | ||
| 158 | + name.find("uri") != -1 or \ | ||
| 159 | + name.find("URI") != -1 or \ | ||
| 160 | + info.find("filename") != -1 or \ | ||
| 161 | + info.find("URI") != -1 or \ | ||
| 162 | + info.find("URL") != -1: | ||
| 163 | + if function.find("Save") != -1 or \ | ||
| 164 | + function.find("Create") != -1 or \ | ||
| 165 | + function.find("Write") != -1 or \ | ||
| 166 | + function.find("Fetch") != -1: | ||
| 167 | + return('fileoutput') | ||
| 168 | + return('filepath') | ||
| 169 | if res == 'void_ptr': | ||
| 170 | if module == 'nanoftp' and name == 'ctx': | ||
| 171 | - return('xmlNanoFTPCtxtPtr') | ||
| 172 | + return('xmlNanoFTPCtxtPtr') | ||
| 173 | if function == 'xmlNanoFTPNewCtxt' or \ | ||
| 174 | - function == 'xmlNanoFTPConnectTo' or \ | ||
| 175 | - function == 'xmlNanoFTPOpen': | ||
| 176 | - return('xmlNanoFTPCtxtPtr') | ||
| 177 | + function == 'xmlNanoFTPConnectTo' or \ | ||
| 178 | + function == 'xmlNanoFTPOpen': | ||
| 179 | + return('xmlNanoFTPCtxtPtr') | ||
| 180 | if module == 'nanohttp' and name == 'ctx': | ||
| 181 | - return('xmlNanoHTTPCtxtPtr') | ||
| 182 | - if function == 'xmlNanoHTTPMethod' or \ | ||
| 183 | - function == 'xmlNanoHTTPMethodRedir' or \ | ||
| 184 | - function == 'xmlNanoHTTPOpen' or \ | ||
| 185 | - function == 'xmlNanoHTTPOpenRedir': | ||
| 186 | - return('xmlNanoHTTPCtxtPtr'); | ||
| 187 | + return('xmlNanoHTTPCtxtPtr') | ||
| 188 | + if function == 'xmlNanoHTTPMethod' or \ | ||
| 189 | + function == 'xmlNanoHTTPMethodRedir' or \ | ||
| 190 | + function == 'xmlNanoHTTPOpen' or \ | ||
| 191 | + function == 'xmlNanoHTTPOpenRedir': | ||
| 192 | + return('xmlNanoHTTPCtxtPtr'); | ||
| 193 | if function == 'xmlIOHTTPOpen': | ||
| 194 | - return('xmlNanoHTTPCtxtPtr') | ||
| 195 | - if string.find(name, "data") != -1: | ||
| 196 | - return('userdata') | ||
| 197 | - if string.find(name, "user") != -1: | ||
| 198 | - return('userdata') | ||
| 199 | + return('xmlNanoHTTPCtxtPtr') | ||
| 200 | + if name.find("data") != -1: | ||
| 201 | + return('userdata') | ||
| 202 | + if name.find("user") != -1: | ||
| 203 | + return('userdata') | ||
| 204 | if res == 'xmlDoc_ptr': | ||
| 205 | res = 'xmlDocPtr' | ||
| 206 | if res == 'xmlNode_ptr': | ||
| 207 | @@ -366,18 +366,18 @@ def type_convert(str, name, info, module, function, pos): | ||
| 208 | res = 'xmlDictPtr' | ||
| 209 | if res == 'xmlNodePtr' and pos != 0: | ||
| 210 | if (function == 'xmlAddChild' and pos == 2) or \ | ||
| 211 | - (function == 'xmlAddChildList' and pos == 2) or \ | ||
| 212 | + (function == 'xmlAddChildList' and pos == 2) or \ | ||
| 213 | (function == 'xmlAddNextSibling' and pos == 2) or \ | ||
| 214 | (function == 'xmlAddSibling' and pos == 2) or \ | ||
| 215 | (function == 'xmlDocSetRootElement' and pos == 2) or \ | ||
| 216 | (function == 'xmlReplaceNode' and pos == 2) or \ | ||
| 217 | (function == 'xmlTextMerge') or \ | ||
| 218 | - (function == 'xmlAddPrevSibling' and pos == 2): | ||
| 219 | - return('xmlNodePtr_in'); | ||
| 220 | + (function == 'xmlAddPrevSibling' and pos == 2): | ||
| 221 | + return('xmlNodePtr_in'); | ||
| 222 | if res == 'const xmlBufferPtr': | ||
| 223 | res = 'xmlBufferPtr' | ||
| 224 | if res == 'xmlChar_ptr' and name == 'name' and \ | ||
| 225 | - string.find(function, "EatName") != -1: | ||
| 226 | + function.find("EatName") != -1: | ||
| 227 | return('eaten_name') | ||
| 228 | if res == 'void_ptr*': | ||
| 229 | res = 'void_ptr_ptr' | ||
| 230 | @@ -393,7 +393,7 @@ def type_convert(str, name, info, module, function, pos): | ||
| 231 | res = 'debug_FILE_ptr'; | ||
| 232 | if res == 'int' and name == 'options': | ||
| 233 | if module == 'parser' or module == 'xmlreader': | ||
| 234 | - res = 'parseroptions' | ||
| 235 | + res = 'parseroptions' | ||
| 236 | |||
| 237 | return res | ||
| 238 | |||
| 239 | @@ -402,28 +402,28 @@ known_param_types = [] | ||
| 240 | def is_known_param_type(name): | ||
| 241 | for type in known_param_types: | ||
| 242 | if type == name: | ||
| 243 | - return 1 | ||
| 244 | + return 1 | ||
| 245 | return name[-3:] == 'Ptr' or name[-4:] == '_ptr' | ||
| 246 | |||
| 247 | def generate_param_type(name, rtype): | ||
| 248 | global test | ||
| 249 | for type in known_param_types: | ||
| 250 | if type == name: | ||
| 251 | - return | ||
| 252 | + return | ||
| 253 | for type in generated_param_types: | ||
| 254 | if type == name: | ||
| 255 | - return | ||
| 256 | + return | ||
| 257 | |||
| 258 | if name[-3:] == 'Ptr' or name[-4:] == '_ptr': | ||
| 259 | if rtype[0:6] == 'const ': | ||
| 260 | - crtype = rtype[6:] | ||
| 261 | - else: | ||
| 262 | - crtype = rtype | ||
| 263 | + crtype = rtype[6:] | ||
| 264 | + else: | ||
| 265 | + crtype = rtype | ||
| 266 | |||
| 267 | define = 0 | ||
| 268 | - if modules_defines.has_key(module): | ||
| 269 | - test.write("#ifdef %s\n" % (modules_defines[module])) | ||
| 270 | - define = 1 | ||
| 271 | + if module in modules_defines: | ||
| 272 | + test.write("#ifdef %s\n" % (modules_defines[module])) | ||
| 273 | + define = 1 | ||
| 274 | test.write(""" | ||
| 275 | #define gen_nb_%s 1 | ||
| 276 | static %s gen_%s(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { | ||
| 277 | @@ -433,7 +433,7 @@ static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTR | ||
| 278 | } | ||
| 279 | """ % (name, crtype, name, name, rtype)) | ||
| 280 | if define == 1: | ||
| 281 | - test.write("#endif\n\n") | ||
| 282 | + test.write("#endif\n\n") | ||
| 283 | add_generated_param_type(name) | ||
| 284 | |||
| 285 | # | ||
| 286 | @@ -445,7 +445,7 @@ known_return_types = [] | ||
| 287 | def is_known_return_type(name): | ||
| 288 | for type in known_return_types: | ||
| 289 | if type == name: | ||
| 290 | - return 1 | ||
| 291 | + return 1 | ||
| 292 | return 0 | ||
| 293 | |||
| 294 | # | ||
| 295 | @@ -471,7 +471,7 @@ def compare_and_save(): | ||
| 296 | try: | ||
| 297 | os.system("rm testapi.c; mv testapi.c.new testapi.c") | ||
| 298 | except: | ||
| 299 | - os.system("mv testapi.c.new testapi.c") | ||
| 300 | + os.system("mv testapi.c.new testapi.c") | ||
| 301 | print("Updated testapi.c") | ||
| 302 | else: | ||
| 303 | print("Generated testapi.c is identical") | ||
| 304 | @@ -481,17 +481,17 @@ while line != "": | ||
| 305 | if line == "/* CUT HERE: everything below that line is generated */\n": | ||
| 306 | break; | ||
| 307 | if line[0:15] == "#define gen_nb_": | ||
| 308 | - type = string.split(line[15:])[0] | ||
| 309 | - known_param_types.append(type) | ||
| 310 | + type = line[15:].split()[0] | ||
| 311 | + known_param_types.append(type) | ||
| 312 | if line[0:19] == "static void desret_": | ||
| 313 | - type = string.split(line[19:], '(')[0] | ||
| 314 | - known_return_types.append(type) | ||
| 315 | + type = line[19:].split('(')[0] | ||
| 316 | + known_return_types.append(type) | ||
| 317 | test.write(line) | ||
| 318 | line = input.readline() | ||
| 319 | input.close() | ||
| 320 | |||
| 321 | if line == "": | ||
| 322 | - print "Could not find the CUT marker in testapi.c skipping generation" | ||
| 323 | + print("Could not find the CUT marker in testapi.c skipping generation") | ||
| 324 | test.close() | ||
| 325 | sys.exit(0) | ||
| 326 | |||
| 327 | @@ -505,7 +505,7 @@ test.write("/* CUT HERE: everything below that line is generated */\n") | ||
| 328 | # | ||
| 329 | doc = libxml2.readFile(srcPref + 'doc/libxml2-api.xml', None, 0) | ||
| 330 | if doc == None: | ||
| 331 | - print "Failed to load doc/libxml2-api.xml" | ||
| 332 | + print("Failed to load doc/libxml2-api.xml") | ||
| 333 | sys.exit(1) | ||
| 334 | ctxt = doc.xpathNewContext() | ||
| 335 | |||
| 336 | @@ -519,9 +519,9 @@ for arg in args: | ||
| 337 | mod = arg.xpathEval('string(../@file)') | ||
| 338 | func = arg.xpathEval('string(../@name)') | ||
| 339 | if (mod not in skipped_modules) and (func not in skipped_functions): | ||
| 340 | - type = arg.xpathEval('string(@type)') | ||
| 341 | - if not argtypes.has_key(type): | ||
| 342 | - argtypes[type] = func | ||
| 343 | + type = arg.xpathEval('string(@type)') | ||
| 344 | + if type not in argtypes: | ||
| 345 | + argtypes[type] = func | ||
| 346 | |||
| 347 | # similarly for return types | ||
| 348 | rettypes = {} | ||
| 349 | @@ -531,8 +531,8 @@ for ret in rets: | ||
| 350 | func = ret.xpathEval('string(../@name)') | ||
| 351 | if (mod not in skipped_modules) and (func not in skipped_functions): | ||
| 352 | type = ret.xpathEval('string(@type)') | ||
| 353 | - if not rettypes.has_key(type): | ||
| 354 | - rettypes[type] = func | ||
| 355 | + if type not in rettypes: | ||
| 356 | + rettypes[type] = func | ||
| 357 | |||
| 358 | # | ||
| 359 | # Generate constructors and return type handling for all enums | ||
| 360 | @@ -549,49 +549,49 @@ for enum in enums: | ||
| 361 | continue; | ||
| 362 | define = 0 | ||
| 363 | |||
| 364 | - if argtypes.has_key(name) and is_known_param_type(name) == 0: | ||
| 365 | - values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name) | ||
| 366 | - i = 0 | ||
| 367 | - vals = [] | ||
| 368 | - for value in values: | ||
| 369 | - vname = value.xpathEval('string(@name)') | ||
| 370 | - if vname == None: | ||
| 371 | - continue; | ||
| 372 | - i = i + 1 | ||
| 373 | - if i >= 5: | ||
| 374 | - break; | ||
| 375 | - vals.append(vname) | ||
| 376 | - if vals == []: | ||
| 377 | - print "Didn't find any value for enum %s" % (name) | ||
| 378 | - continue | ||
| 379 | - if modules_defines.has_key(module): | ||
| 380 | - test.write("#ifdef %s\n" % (modules_defines[module])) | ||
| 381 | - define = 1 | ||
| 382 | - test.write("#define gen_nb_%s %d\n" % (name, len(vals))) | ||
| 383 | - test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" % | ||
| 384 | - (name, name)) | ||
| 385 | - i = 1 | ||
| 386 | - for value in vals: | ||
| 387 | - test.write(" if (no == %d) return(%s);\n" % (i, value)) | ||
| 388 | - i = i + 1 | ||
| 389 | - test.write(""" return(0); | ||
| 390 | + if (name in argtypes) and is_known_param_type(name) == 0: | ||
| 391 | + values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name) | ||
| 392 | + i = 0 | ||
| 393 | + vals = [] | ||
| 394 | + for value in values: | ||
| 395 | + vname = value.xpathEval('string(@name)') | ||
| 396 | + if vname == None: | ||
| 397 | + continue; | ||
| 398 | + i = i + 1 | ||
| 399 | + if i >= 5: | ||
| 400 | + break; | ||
| 401 | + vals.append(vname) | ||
| 402 | + if vals == []: | ||
| 403 | + print("Didn't find any value for enum %s" % (name)) | ||
| 404 | + continue | ||
| 405 | + if module in modules_defines: | ||
| 406 | + test.write("#ifdef %s\n" % (modules_defines[module])) | ||
| 407 | + define = 1 | ||
| 408 | + test.write("#define gen_nb_%s %d\n" % (name, len(vals))) | ||
| 409 | + test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" % | ||
| 410 | + (name, name)) | ||
| 411 | + i = 1 | ||
| 412 | + for value in vals: | ||
| 413 | + test.write(" if (no == %d) return(%s);\n" % (i, value)) | ||
| 414 | + i = i + 1 | ||
| 415 | + test.write(""" return(0); | ||
| 416 | } | ||
| 417 | |||
| 418 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { | ||
| 419 | } | ||
| 420 | |||
| 421 | """ % (name, name)); | ||
| 422 | - known_param_types.append(name) | ||
| 423 | + known_param_types.append(name) | ||
| 424 | |||
| 425 | if (is_known_return_type(name) == 0) and (name in rettypes): | ||
| 426 | - if define == 0 and modules_defines.has_key(module): | ||
| 427 | - test.write("#ifdef %s\n" % (modules_defines[module])) | ||
| 428 | - define = 1 | ||
| 429 | + if define == 0 and (module in modules_defines): | ||
| 430 | + test.write("#ifdef %s\n" % (modules_defines[module])) | ||
| 431 | + define = 1 | ||
| 432 | test.write("""static void desret_%s(%s val ATTRIBUTE_UNUSED) { | ||
| 433 | } | ||
| 434 | |||
| 435 | """ % (name, name)) | ||
| 436 | - known_return_types.append(name) | ||
| 437 | + known_return_types.append(name) | ||
| 438 | if define == 1: | ||
| 439 | test.write("#endif\n\n") | ||
| 440 | |||
| 441 | @@ -615,9 +615,9 @@ for file in headers: | ||
| 442 | # do not test deprecated APIs | ||
| 443 | # | ||
| 444 | desc = file.xpathEval('string(description)') | ||
| 445 | - if string.find(desc, 'DEPRECATED') != -1: | ||
| 446 | - print "Skipping deprecated interface %s" % name | ||
| 447 | - continue; | ||
| 448 | + if desc.find('DEPRECATED') != -1: | ||
| 449 | + print("Skipping deprecated interface %s" % name) | ||
| 450 | + continue; | ||
| 451 | |||
| 452 | test.write("#include <libxml/%s.h>\n" % name) | ||
| 453 | modules.append(name) | ||
| 454 | @@ -679,7 +679,7 @@ def generate_test(module, node): | ||
| 455 | # and store the informations for the generation | ||
| 456 | # | ||
| 457 | try: | ||
| 458 | - args = node.xpathEval("arg") | ||
| 459 | + args = node.xpathEval("arg") | ||
| 460 | except: | ||
| 461 | args = [] | ||
| 462 | t_args = [] | ||
| 463 | @@ -687,37 +687,37 @@ def generate_test(module, node): | ||
| 464 | for arg in args: | ||
| 465 | n = n + 1 | ||
| 466 | rtype = arg.xpathEval("string(@type)") | ||
| 467 | - if rtype == 'void': | ||
| 468 | - break; | ||
| 469 | - info = arg.xpathEval("string(@info)") | ||
| 470 | - nam = arg.xpathEval("string(@name)") | ||
| 471 | + if rtype == 'void': | ||
| 472 | + break; | ||
| 473 | + info = arg.xpathEval("string(@info)") | ||
| 474 | + nam = arg.xpathEval("string(@name)") | ||
| 475 | type = type_convert(rtype, nam, info, module, name, n) | ||
| 476 | - if is_known_param_type(type) == 0: | ||
| 477 | - add_missing_type(type, name); | ||
| 478 | - no_gen = 1 | ||
| 479 | + if is_known_param_type(type) == 0: | ||
| 480 | + add_missing_type(type, name); | ||
| 481 | + no_gen = 1 | ||
| 482 | if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \ | ||
| 483 | - rtype[0:6] == 'const ': | ||
| 484 | - crtype = rtype[6:] | ||
| 485 | - else: | ||
| 486 | - crtype = rtype | ||
| 487 | - t_args.append((nam, type, rtype, crtype, info)) | ||
| 488 | + rtype[0:6] == 'const ': | ||
| 489 | + crtype = rtype[6:] | ||
| 490 | + else: | ||
| 491 | + crtype = rtype | ||
| 492 | + t_args.append((nam, type, rtype, crtype, info)) | ||
| 493 | |||
| 494 | try: | ||
| 495 | - rets = node.xpathEval("return") | ||
| 496 | + rets = node.xpathEval("return") | ||
| 497 | except: | ||
| 498 | rets = [] | ||
| 499 | t_ret = None | ||
| 500 | for ret in rets: | ||
| 501 | rtype = ret.xpathEval("string(@type)") | ||
| 502 | - info = ret.xpathEval("string(@info)") | ||
| 503 | + info = ret.xpathEval("string(@info)") | ||
| 504 | type = type_convert(rtype, 'return', info, module, name, 0) | ||
| 505 | - if rtype == 'void': | ||
| 506 | - break | ||
| 507 | - if is_known_return_type(type) == 0: | ||
| 508 | - add_missing_type(type, name); | ||
| 509 | - no_gen = 1 | ||
| 510 | - t_ret = (type, rtype, info) | ||
| 511 | - break | ||
| 512 | + if rtype == 'void': | ||
| 513 | + break | ||
| 514 | + if is_known_return_type(type) == 0: | ||
| 515 | + add_missing_type(type, name); | ||
| 516 | + no_gen = 1 | ||
| 517 | + t_ret = (type, rtype, info) | ||
| 518 | + break | ||
| 519 | |||
| 520 | if no_gen == 0: | ||
| 521 | for t_arg in t_args: | ||
| 522 | @@ -733,7 +733,7 @@ test_%s(void) { | ||
| 523 | |||
| 524 | if no_gen == 1: | ||
| 525 | add_missing_functions(name, module) | ||
| 526 | - test.write(""" | ||
| 527 | + test.write(""" | ||
| 528 | /* missing type support */ | ||
| 529 | return(test_ret); | ||
| 530 | } | ||
| 531 | @@ -742,22 +742,22 @@ test_%s(void) { | ||
| 532 | return | ||
| 533 | |||
| 534 | try: | ||
| 535 | - conds = node.xpathEval("cond") | ||
| 536 | - for cond in conds: | ||
| 537 | - test.write("#if %s\n" % (cond.get_content())) | ||
| 538 | - nb_cond = nb_cond + 1 | ||
| 539 | + conds = node.xpathEval("cond") | ||
| 540 | + for cond in conds: | ||
| 541 | + test.write("#if %s\n" % (cond.get_content())) | ||
| 542 | + nb_cond = nb_cond + 1 | ||
| 543 | except: | ||
| 544 | pass | ||
| 545 | |||
| 546 | define = 0 | ||
| 547 | - if function_defines.has_key(name): | ||
| 548 | + if name in function_defines: | ||
| 549 | test.write("#ifdef %s\n" % (function_defines[name])) | ||
| 550 | - define = 1 | ||
| 551 | + define = 1 | ||
| 552 | |||
| 553 | # Declare the memory usage counter | ||
| 554 | no_mem = is_skipped_memcheck(name) | ||
| 555 | if no_mem == 0: | ||
| 556 | - test.write(" int mem_base;\n"); | ||
| 557 | + test.write(" int mem_base;\n"); | ||
| 558 | |||
| 559 | # Declare the return value | ||
| 560 | if t_ret != None: | ||
| 561 | @@ -766,29 +766,29 @@ test_%s(void) { | ||
| 562 | # Declare the arguments | ||
| 563 | for arg in t_args: | ||
| 564 | (nam, type, rtype, crtype, info) = arg; | ||
| 565 | - # add declaration | ||
| 566 | - test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) | ||
| 567 | - test.write(" int n_%s;\n" % (nam)) | ||
| 568 | + # add declaration | ||
| 569 | + test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) | ||
| 570 | + test.write(" int n_%s;\n" % (nam)) | ||
| 571 | test.write("\n") | ||
| 572 | |||
| 573 | # Cascade loop on of each argument list of values | ||
| 574 | for arg in t_args: | ||
| 575 | (nam, type, rtype, crtype, info) = arg; | ||
| 576 | - # | ||
| 577 | - test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( | ||
| 578 | - nam, nam, type, nam)) | ||
| 579 | + # | ||
| 580 | + test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( | ||
| 581 | + nam, nam, type, nam)) | ||
| 582 | |||
| 583 | # log the memory usage | ||
| 584 | if no_mem == 0: | ||
| 585 | - test.write(" mem_base = xmlMemBlocks();\n"); | ||
| 586 | + test.write(" mem_base = xmlMemBlocks();\n"); | ||
| 587 | |||
| 588 | # prepare the call | ||
| 589 | i = 0; | ||
| 590 | for arg in t_args: | ||
| 591 | (nam, type, rtype, crtype, info) = arg; | ||
| 592 | - # | ||
| 593 | - test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) | ||
| 594 | - i = i + 1; | ||
| 595 | + # | ||
| 596 | + test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) | ||
| 597 | + i = i + 1; | ||
| 598 | |||
| 599 | # add checks to avoid out-of-bounds array access | ||
| 600 | i = 0; | ||
| 601 | @@ -797,7 +797,7 @@ test_%s(void) { | ||
| 602 | # assume that "size", "len", and "start" parameters apply to either | ||
| 603 | # the nearest preceding or following char pointer | ||
| 604 | if type == "int" and (nam == "size" or nam == "len" or nam == "start"): | ||
| 605 | - for j in range(i - 1, -1, -1) + range(i + 1, len(t_args)): | ||
| 606 | + for j in (*range(i - 1, -1, -1), *range(i + 1, len(t_args))): | ||
| 607 | (bnam, btype) = t_args[j][:2] | ||
| 608 | if btype == "const_char_ptr" or btype == "const_xmlChar_ptr": | ||
| 609 | test.write( | ||
| 610 | @@ -806,42 +806,42 @@ test_%s(void) { | ||
| 611 | " continue;\n" | ||
| 612 | % (bnam, nam, bnam)) | ||
| 613 | break | ||
| 614 | - i = i + 1; | ||
| 615 | + i = i + 1; | ||
| 616 | |||
| 617 | # do the call, and clanup the result | ||
| 618 | - if extra_pre_call.has_key(name): | ||
| 619 | - test.write(" %s\n"% (extra_pre_call[name])) | ||
| 620 | + if name in extra_pre_call: | ||
| 621 | + test.write(" %s\n"% (extra_pre_call[name])) | ||
| 622 | if t_ret != None: | ||
| 623 | - test.write("\n ret_val = %s(" % (name)) | ||
| 624 | - need = 0 | ||
| 625 | - for arg in t_args: | ||
| 626 | - (nam, type, rtype, crtype, info) = arg | ||
| 627 | - if need: | ||
| 628 | - test.write(", ") | ||
| 629 | - else: | ||
| 630 | - need = 1 | ||
| 631 | - if rtype != crtype: | ||
| 632 | - test.write("(%s)" % rtype) | ||
| 633 | - test.write("%s" % nam); | ||
| 634 | - test.write(");\n") | ||
| 635 | - if extra_post_call.has_key(name): | ||
| 636 | - test.write(" %s\n"% (extra_post_call[name])) | ||
| 637 | - test.write(" desret_%s(ret_val);\n" % t_ret[0]) | ||
| 638 | + test.write("\n ret_val = %s(" % (name)) | ||
| 639 | + need = 0 | ||
| 640 | + for arg in t_args: | ||
| 641 | + (nam, type, rtype, crtype, info) = arg | ||
| 642 | + if need: | ||
| 643 | + test.write(", ") | ||
| 644 | + else: | ||
| 645 | + need = 1 | ||
| 646 | + if rtype != crtype: | ||
| 647 | + test.write("(%s)" % rtype) | ||
| 648 | + test.write("%s" % nam); | ||
| 649 | + test.write(");\n") | ||
| 650 | + if name in extra_post_call: | ||
| 651 | + test.write(" %s\n"% (extra_post_call[name])) | ||
| 652 | + test.write(" desret_%s(ret_val);\n" % t_ret[0]) | ||
| 653 | else: | ||
| 654 | - test.write("\n %s(" % (name)); | ||
| 655 | - need = 0; | ||
| 656 | - for arg in t_args: | ||
| 657 | - (nam, type, rtype, crtype, info) = arg; | ||
| 658 | - if need: | ||
| 659 | - test.write(", ") | ||
| 660 | - else: | ||
| 661 | - need = 1 | ||
| 662 | - if rtype != crtype: | ||
| 663 | - test.write("(%s)" % rtype) | ||
| 664 | - test.write("%s" % nam) | ||
| 665 | - test.write(");\n") | ||
| 666 | - if extra_post_call.has_key(name): | ||
| 667 | - test.write(" %s\n"% (extra_post_call[name])) | ||
| 668 | + test.write("\n %s(" % (name)); | ||
| 669 | + need = 0; | ||
| 670 | + for arg in t_args: | ||
| 671 | + (nam, type, rtype, crtype, info) = arg; | ||
| 672 | + if need: | ||
| 673 | + test.write(", ") | ||
| 674 | + else: | ||
| 675 | + need = 1 | ||
| 676 | + if rtype != crtype: | ||
| 677 | + test.write("(%s)" % rtype) | ||
| 678 | + test.write("%s" % nam) | ||
| 679 | + test.write(");\n") | ||
| 680 | + if name in extra_post_call: | ||
| 681 | + test.write(" %s\n"% (extra_post_call[name])) | ||
| 682 | |||
| 683 | test.write(" call_tests++;\n"); | ||
| 684 | |||
| 685 | @@ -849,32 +849,32 @@ test_%s(void) { | ||
| 686 | i = 0; | ||
| 687 | for arg in t_args: | ||
| 688 | (nam, type, rtype, crtype, info) = arg; | ||
| 689 | - # This is a hack to prevent generating a destructor for the | ||
| 690 | - # 'input' argument in xmlTextReaderSetup. There should be | ||
| 691 | - # a better, more generic way to do this! | ||
| 692 | - if string.find(info, 'destroy') == -1: | ||
| 693 | - test.write(" des_%s(n_%s, " % (type, nam)) | ||
| 694 | - if rtype != crtype: | ||
| 695 | - test.write("(%s)" % rtype) | ||
| 696 | - test.write("%s, %d);\n" % (nam, i)) | ||
| 697 | - i = i + 1; | ||
| 698 | + # This is a hack to prevent generating a destructor for the | ||
| 699 | + # 'input' argument in xmlTextReaderSetup. There should be | ||
| 700 | + # a better, more generic way to do this! | ||
| 701 | + if info.find('destroy') == -1: | ||
| 702 | + test.write(" des_%s(n_%s, " % (type, nam)) | ||
| 703 | + if rtype != crtype: | ||
| 704 | + test.write("(%s)" % rtype) | ||
| 705 | + test.write("%s, %d);\n" % (nam, i)) | ||
| 706 | + i = i + 1; | ||
| 707 | |||
| 708 | test.write(" xmlResetLastError();\n"); | ||
| 709 | # Check the memory usage | ||
| 710 | if no_mem == 0: | ||
| 711 | - test.write(""" if (mem_base != xmlMemBlocks()) { | ||
| 712 | + test.write(""" if (mem_base != xmlMemBlocks()) { | ||
| 713 | printf("Leak of %%d blocks found in %s", | ||
| 714 | - xmlMemBlocks() - mem_base); | ||
| 715 | - test_ret++; | ||
| 716 | +\t xmlMemBlocks() - mem_base); | ||
| 717 | +\t test_ret++; | ||
| 718 | """ % (name)); | ||
| 719 | - for arg in t_args: | ||
| 720 | - (nam, type, rtype, crtype, info) = arg; | ||
| 721 | - test.write(""" printf(" %%d", n_%s);\n""" % (nam)) | ||
| 722 | - test.write(""" printf("\\n");\n""") | ||
| 723 | - test.write(" }\n") | ||
| 724 | + for arg in t_args: | ||
| 725 | + (nam, type, rtype, crtype, info) = arg; | ||
| 726 | + test.write(""" printf(" %%d", n_%s);\n""" % (nam)) | ||
| 727 | + test.write(""" printf("\\n");\n""") | ||
| 728 | + test.write(" }\n") | ||
| 729 | |||
| 730 | for arg in t_args: | ||
| 731 | - test.write(" }\n") | ||
| 732 | + test.write(" }\n") | ||
| 733 | |||
| 734 | test.write(" function_tests++;\n") | ||
| 735 | # | ||
| 736 | @@ -882,7 +882,7 @@ test_%s(void) { | ||
| 737 | # | ||
| 738 | while nb_cond > 0: | ||
| 739 | test.write("#endif\n") | ||
| 740 | - nb_cond = nb_cond -1 | ||
| 741 | + nb_cond = nb_cond -1 | ||
| 742 | if define == 1: | ||
| 743 | test.write("#endif\n") | ||
| 744 | |||
| 745 | @@ -900,10 +900,10 @@ test_%s(void) { | ||
| 746 | for module in modules: | ||
| 747 | # gather all the functions exported by that module | ||
| 748 | try: | ||
| 749 | - functions = ctxt.xpathEval("/api/symbols/function[@file='%s']" % (module)) | ||
| 750 | + functions = ctxt.xpathEval("/api/symbols/function[@file='%s']" % (module)) | ||
| 751 | except: | ||
| 752 | - print "Failed to gather functions from module %s" % (module) | ||
| 753 | - continue; | ||
| 754 | + print("Failed to gather functions from module %s" % (module)) | ||
| 755 | + continue; | ||
| 756 | |||
| 757 | # iterate over all functions in the module generating the test | ||
| 758 | i = 0 | ||
| 759 | @@ -923,14 +923,14 @@ test_%s(void) { | ||
| 760 | # iterate over all functions in the module generating the call | ||
| 761 | for function in functions: | ||
| 762 | name = function.xpathEval('string(@name)') | ||
| 763 | - if is_skipped_function(name): | ||
| 764 | - continue | ||
| 765 | - test.write(" test_ret += test_%s();\n" % (name)) | ||
| 766 | + if is_skipped_function(name): | ||
| 767 | + continue | ||
| 768 | + test.write(" test_ret += test_%s();\n" % (name)) | ||
| 769 | |||
| 770 | # footer | ||
| 771 | test.write(""" | ||
| 772 | if (test_ret != 0) | ||
| 773 | - printf("Module %s: %%d errors\\n", test_ret); | ||
| 774 | +\tprintf("Module %s: %%d errors\\n", test_ret); | ||
| 775 | return(test_ret); | ||
| 776 | } | ||
| 777 | """ % (module)) | ||
| 778 | @@ -948,7 +948,7 @@ test.write(""" return(0); | ||
| 779 | } | ||
| 780 | """); | ||
| 781 | |||
| 782 | -print "Generated test for %d modules and %d functions" %(len(modules), nb_tests) | ||
| 783 | +print("Generated test for %d modules and %d functions" %(len(modules), nb_tests)) | ||
| 784 | |||
| 785 | compare_and_save() | ||
| 786 | |||
| 787 | @@ -960,11 +960,8 @@ for missing in missing_types.keys(): | ||
| 788 | n = len(missing_types[missing]) | ||
| 789 | missing_list.append((n, missing)) | ||
| 790 | |||
| 791 | -def compare_missing(a, b): | ||
| 792 | - return b[0] - a[0] | ||
| 793 | - | ||
| 794 | -missing_list.sort(compare_missing) | ||
| 795 | -print "Missing support for %d functions and %d types see missing.lst" % (missing_functions_nr, len(missing_list)) | ||
| 796 | +missing_list.sort(key=lambda a: a[0]) | ||
| 797 | +print("Missing support for %d functions and %d types see missing.lst" % (missing_functions_nr, len(missing_list))) | ||
| 798 | lst = open("missing.lst", "w") | ||
| 799 | lst.write("Missing support for %d types" % (len(missing_list))) | ||
| 800 | lst.write("\n") | ||
| 801 | @@ -974,9 +971,9 @@ for miss in missing_list: | ||
| 802 | for n in missing_types[miss[1]]: | ||
| 803 | i = i + 1 | ||
| 804 | if i > 5: | ||
| 805 | - lst.write(" ...") | ||
| 806 | - break | ||
| 807 | - lst.write(" %s" % (n)) | ||
| 808 | + lst.write(" ...") | ||
| 809 | + break | ||
| 810 | + lst.write(" %s" % (n)) | ||
| 811 | lst.write("\n") | ||
| 812 | lst.write("\n") | ||
| 813 | lst.write("\n") | ||
diff --git a/meta/recipes-core/libxml/libxml2_2.9.10.bb b/meta/recipes-core/libxml/libxml2_2.9.10.bb index b3ebf15751..d1c1f0884f 100644 --- a/meta/recipes-core/libxml/libxml2_2.9.10.bb +++ b/meta/recipes-core/libxml/libxml2_2.9.10.bb | |||
| @@ -32,6 +32,7 @@ SRC_URI += "http://www.w3.org/XML/Test/xmlts20080827.tar.gz;subdir=${BP};name=te | |||
| 32 | file://CVE-2022-23308-fix-regression.patch \ | 32 | file://CVE-2022-23308-fix-regression.patch \ |
| 33 | file://CVE-2022-29824-dependent.patch \ | 33 | file://CVE-2022-29824-dependent.patch \ |
| 34 | file://CVE-2022-29824.patch \ | 34 | file://CVE-2022-29824.patch \ |
| 35 | file://0001-Port-gentest.py-to-Python-3.patch \ | ||
| 35 | " | 36 | " |
| 36 | 37 | ||
| 37 | SRC_URI[archive.sha256sum] = "593b7b751dd18c2d6abcd0c4bcb29efc203d0b4373a6df98e3a455ea74ae2813" | 38 | SRC_URI[archive.sha256sum] = "593b7b751dd18c2d6abcd0c4bcb29efc203d0b4373a6df98e3a455ea74ae2813" |
| @@ -89,6 +90,16 @@ do_configure_prepend () { | |||
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | do_compile_ptest() { | 92 | do_compile_ptest() { |
| 93 | # Make sure that testapi.c is newer than gentests.py, because | ||
| 94 | # with reproducible builds, they will both get e.g. Jan 1 1970 | ||
| 95 | # modification time from SOURCE_DATE_EPOCH and then check-am | ||
| 96 | # might try to rebuild_testapi, which will fail even with | ||
| 97 | # 0001-Port-gentest.py-to-Python-3.patch, because it needs | ||
| 98 | # libxml2 module (libxml2-native dependency and correctly | ||
| 99 | # set PYTHON_SITE_PACKAGES), it's easier to | ||
| 100 | # just rely on pre-generated testapi.c from the release | ||
| 101 | touch ${S}/testapi.c | ||
| 102 | |||
| 92 | oe_runmake check-am | 103 | oe_runmake check-am |
| 93 | } | 104 | } |
| 94 | 105 | ||
