1*7c568831SAndroid Build Coastguard Worker#!/usr/bin/env python3 2*7c568831SAndroid Build Coastguard Worker# -*- coding: utf-8 -*- 3*7c568831SAndroid Build Coastguard Worker# 4*7c568831SAndroid Build Coastguard Worker# this tests the DTD validation with the XmlTextReader interface 5*7c568831SAndroid Build Coastguard Worker# 6*7c568831SAndroid Build Coastguard Workerimport sys 7*7c568831SAndroid Build Coastguard Workerimport glob 8*7c568831SAndroid Build Coastguard Workerimport os 9*7c568831SAndroid Build Coastguard Workerimport setup_test 10*7c568831SAndroid Build Coastguard Workerimport libxml2 11*7c568831SAndroid Build Coastguard Workertry: 12*7c568831SAndroid Build Coastguard Worker import StringIO 13*7c568831SAndroid Build Coastguard Worker str_io = StringIO.StringIO 14*7c568831SAndroid Build Coastguard Workerexcept: 15*7c568831SAndroid Build Coastguard Worker import io 16*7c568831SAndroid Build Coastguard Worker str_io = io.StringIO 17*7c568831SAndroid Build Coastguard Worker 18*7c568831SAndroid Build Coastguard Worker# Memory debug specific 19*7c568831SAndroid Build Coastguard Workerlibxml2.debugMemory(1) 20*7c568831SAndroid Build Coastguard Worker 21*7c568831SAndroid Build Coastguard Workererr = "" 22*7c568831SAndroid Build Coastguard Workerbasedir = os.path.dirname(os.path.realpath(__file__)) 23*7c568831SAndroid Build Coastguard Workerdir_prefix = os.path.realpath(os.path.join(basedir, "..", "..", "test", "valid")) 24*7c568831SAndroid Build Coastguard Worker 25*7c568831SAndroid Build Coastguard Worker# This dictionary reflects the contents of the files 26*7c568831SAndroid Build Coastguard Worker# ../../test/valid/*.xml.err that are not empty, except that 27*7c568831SAndroid Build Coastguard Worker# the file paths in the messages start with ../../test/ 28*7c568831SAndroid Build Coastguard Worker 29*7c568831SAndroid Build Coastguard Workerexpect = { 30*7c568831SAndroid Build Coastguard Worker '766956': 31*7c568831SAndroid Build Coastguard Worker"""{0}/dtds/766956.dtd:2: parser error : PEReference: expecting ';' 32*7c568831SAndroid Build Coastguard Worker%ä%ent; 33*7c568831SAndroid Build Coastguard Worker ^ 34*7c568831SAndroid Build Coastguard Worker{0}/dtds/766956.dtd:2: parser error : Content error in the external subset 35*7c568831SAndroid Build Coastguard Worker%ä%ent; 36*7c568831SAndroid Build Coastguard Worker ^ 37*7c568831SAndroid Build Coastguard WorkerEntity: line 1: 38*7c568831SAndroid Build Coastguard Workervalue 39*7c568831SAndroid Build Coastguard Worker^ 40*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 41*7c568831SAndroid Build Coastguard Worker '781333': 42*7c568831SAndroid Build Coastguard Worker"""{0}/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got 43*7c568831SAndroid Build Coastguard Worker<a/> 44*7c568831SAndroid Build Coastguard Worker ^ 45*7c568831SAndroid Build Coastguard Worker{0}/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children 46*7c568831SAndroid Build Coastguard Worker 47*7c568831SAndroid Build Coastguard Worker^ 48*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 49*7c568831SAndroid Build Coastguard Worker 'cond_sect2': 50*7c568831SAndroid Build Coastguard Worker"""{0}/dtds/cond_sect2.dtd:15: parser error : All markup of the conditional section is not in the same entity 51*7c568831SAndroid Build Coastguard Worker %ent; 52*7c568831SAndroid Build Coastguard Worker ^ 53*7c568831SAndroid Build Coastguard WorkerEntity: line 1: 54*7c568831SAndroid Build Coastguard Worker]]> 55*7c568831SAndroid Build Coastguard Worker^ 56*7c568831SAndroid Build Coastguard Worker{0}/dtds/cond_sect2.dtd:17: parser error : Content error in the external subset 57*7c568831SAndroid Build Coastguard Worker 58*7c568831SAndroid Build Coastguard Worker^ 59*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 60*7c568831SAndroid Build Coastguard Worker 'rss': 61*7c568831SAndroid Build Coastguard Worker"""{0}/rss.xml:177: element rss: validity error : Element rss does not carry attribute version 62*7c568831SAndroid Build Coastguard Worker</rss> 63*7c568831SAndroid Build Coastguard Worker ^ 64*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 65*7c568831SAndroid Build Coastguard Worker 't8': 66*7c568831SAndroid Build Coastguard Worker"""{0}/t8.xml:6: parser error : Content error in the internal subset 67*7c568831SAndroid Build Coastguard Worker%defroot; %defmiddle; %deftest; 68*7c568831SAndroid Build Coastguard Worker ^ 69*7c568831SAndroid Build Coastguard WorkerEntity: line 1: 70*7c568831SAndroid Build Coastguard Worker<!ELEMENT root (middle) > 71*7c568831SAndroid Build Coastguard Worker^ 72*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 73*7c568831SAndroid Build Coastguard Worker 't8a': 74*7c568831SAndroid Build Coastguard Worker"""{0}/t8a.xml:6: parser error : Content error in the internal subset 75*7c568831SAndroid Build Coastguard Worker%defroot;%defmiddle;%deftest; 76*7c568831SAndroid Build Coastguard Worker ^ 77*7c568831SAndroid Build Coastguard WorkerEntity: line 1: 78*7c568831SAndroid Build Coastguard Worker<!ELEMENT root (middle) > 79*7c568831SAndroid Build Coastguard Worker^ 80*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 81*7c568831SAndroid Build Coastguard Worker 'xlink': 82*7c568831SAndroid Build Coastguard Worker"""{0}/xlink.xml:450: element termdef: validity error : ID dt-arc already defined 83*7c568831SAndroid Build Coastguard Worker <p><termdef id="dt-arc" term="Arc">An <ter 84*7c568831SAndroid Build Coastguard Worker ^ 85*7c568831SAndroid Build Coastguard Workervalidity error : attribute def line 199 references an unknown ID "dt-xlg" 86*7c568831SAndroid Build Coastguard Worker""".format(dir_prefix), 87*7c568831SAndroid Build Coastguard Worker} 88*7c568831SAndroid Build Coastguard Worker 89*7c568831SAndroid Build Coastguard Worker# Add prefix_dir and extension to the keys 90*7c568831SAndroid Build Coastguard Workerexpect = {os.path.join(dir_prefix, key + ".xml"): val for key, val in expect.items()} 91*7c568831SAndroid Build Coastguard Worker 92*7c568831SAndroid Build Coastguard Workerdef callback(ctx, str): 93*7c568831SAndroid Build Coastguard Worker global err 94*7c568831SAndroid Build Coastguard Worker err = err + "%s" % (str) 95*7c568831SAndroid Build Coastguard Workerlibxml2.registerErrorHandler(callback, "") 96*7c568831SAndroid Build Coastguard Worker 97*7c568831SAndroid Build Coastguard Workerparsing_error_files = ["766956", "cond_sect2", "t8", "t8a", "pe-in-text-decl"] 98*7c568831SAndroid Build Coastguard Workerexpect_parsing_error = [os.path.join(dir_prefix, f + ".xml") for f in parsing_error_files] 99*7c568831SAndroid Build Coastguard Worker 100*7c568831SAndroid Build Coastguard Workervalid_files = glob.glob(os.path.join(dir_prefix, "*.x*")) 101*7c568831SAndroid Build Coastguard Workerassert valid_files, "found no valid files in '{}'".format(dir_prefix) 102*7c568831SAndroid Build Coastguard Workervalid_files.sort() 103*7c568831SAndroid Build Coastguard Workerfailures = 0 104*7c568831SAndroid Build Coastguard Workerfor file in valid_files: 105*7c568831SAndroid Build Coastguard Worker err = "" 106*7c568831SAndroid Build Coastguard Worker reader = libxml2.newTextReaderFilename(file) 107*7c568831SAndroid Build Coastguard Worker #print "%s:" % (file) 108*7c568831SAndroid Build Coastguard Worker reader.SetParserProp(libxml2.PARSER_VALIDATE, 1) 109*7c568831SAndroid Build Coastguard Worker ret = reader.Read() 110*7c568831SAndroid Build Coastguard Worker while ret == 1: 111*7c568831SAndroid Build Coastguard Worker ret = reader.Read() 112*7c568831SAndroid Build Coastguard Worker if ret != 0 and file not in expect_parsing_error: 113*7c568831SAndroid Build Coastguard Worker print("Error parsing and validating %s" % (file)) 114*7c568831SAndroid Build Coastguard Worker #sys.exit(1) 115*7c568831SAndroid Build Coastguard Worker if file in expect and err != expect[file]: 116*7c568831SAndroid Build Coastguard Worker failures += 1 117*7c568831SAndroid Build Coastguard Worker print("Error: ", err) 118*7c568831SAndroid Build Coastguard Worker if file in expect: 119*7c568831SAndroid Build Coastguard Worker print("Expected: ", expect[file]) 120*7c568831SAndroid Build Coastguard Worker 121*7c568831SAndroid Build Coastguard Workerif failures: 122*7c568831SAndroid Build Coastguard Worker print("Failed %d tests" % failures) 123*7c568831SAndroid Build Coastguard Worker sys.exit(1) 124*7c568831SAndroid Build Coastguard Worker 125*7c568831SAndroid Build Coastguard Worker# 126*7c568831SAndroid Build Coastguard Worker# another separate test based on Stephane Bidoul one 127*7c568831SAndroid Build Coastguard Worker# 128*7c568831SAndroid Build Coastguard Workers = """ 129*7c568831SAndroid Build Coastguard Worker<!DOCTYPE test [ 130*7c568831SAndroid Build Coastguard Worker<!ELEMENT test (x,b)> 131*7c568831SAndroid Build Coastguard Worker<!ELEMENT x (c)> 132*7c568831SAndroid Build Coastguard Worker<!ELEMENT b (#PCDATA)> 133*7c568831SAndroid Build Coastguard Worker<!ELEMENT c (#PCDATA)> 134*7c568831SAndroid Build Coastguard Worker<!ENTITY x "<x><c>xxx</c></x>"> 135*7c568831SAndroid Build Coastguard Worker]> 136*7c568831SAndroid Build Coastguard Worker<test> 137*7c568831SAndroid Build Coastguard Worker &x; 138*7c568831SAndroid Build Coastguard Worker <b>bbb</b> 139*7c568831SAndroid Build Coastguard Worker</test> 140*7c568831SAndroid Build Coastguard Worker""" 141*7c568831SAndroid Build Coastguard Workerexpect="""10,test 142*7c568831SAndroid Build Coastguard Worker1,test 143*7c568831SAndroid Build Coastguard Worker14,#text 144*7c568831SAndroid Build Coastguard Worker1,x 145*7c568831SAndroid Build Coastguard Worker1,c 146*7c568831SAndroid Build Coastguard Worker3,#text 147*7c568831SAndroid Build Coastguard Worker15,c 148*7c568831SAndroid Build Coastguard Worker15,x 149*7c568831SAndroid Build Coastguard Worker14,#text 150*7c568831SAndroid Build Coastguard Worker1,b 151*7c568831SAndroid Build Coastguard Worker3,#text 152*7c568831SAndroid Build Coastguard Worker15,b 153*7c568831SAndroid Build Coastguard Worker14,#text 154*7c568831SAndroid Build Coastguard Worker15,test 155*7c568831SAndroid Build Coastguard Worker""" 156*7c568831SAndroid Build Coastguard Workerres="" 157*7c568831SAndroid Build Coastguard Workererr="" 158*7c568831SAndroid Build Coastguard Worker 159*7c568831SAndroid Build Coastguard Workerinput = libxml2.inputBuffer(str_io(s)) 160*7c568831SAndroid Build Coastguard Workerreader = input.newTextReader("test2") 161*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_LOADDTD,1) 162*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) 163*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) 164*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_VALIDATE,1) 165*7c568831SAndroid Build Coastguard Workerwhile reader.Read() == 1: 166*7c568831SAndroid Build Coastguard Worker res = res + "%s,%s\n" % (reader.NodeType(),reader.Name()) 167*7c568831SAndroid Build Coastguard Worker 168*7c568831SAndroid Build Coastguard Workerif res != expect: 169*7c568831SAndroid Build Coastguard Worker print("test2 failed: unexpected output") 170*7c568831SAndroid Build Coastguard Worker print(res) 171*7c568831SAndroid Build Coastguard Worker sys.exit(1) 172*7c568831SAndroid Build Coastguard Workerif err != "": 173*7c568831SAndroid Build Coastguard Worker print("test2 failed: validation error found") 174*7c568831SAndroid Build Coastguard Worker print(err) 175*7c568831SAndroid Build Coastguard Worker sys.exit(1) 176*7c568831SAndroid Build Coastguard Worker 177*7c568831SAndroid Build Coastguard Worker# 178*7c568831SAndroid Build Coastguard Worker# Another test for external entity parsing and validation 179*7c568831SAndroid Build Coastguard Worker# 180*7c568831SAndroid Build Coastguard Worker 181*7c568831SAndroid Build Coastguard Workers = """<!DOCTYPE test [ 182*7c568831SAndroid Build Coastguard Worker<!ELEMENT test (x)> 183*7c568831SAndroid Build Coastguard Worker<!ELEMENT x (#PCDATA)> 184*7c568831SAndroid Build Coastguard Worker<!ENTITY e SYSTEM "tst.ent"> 185*7c568831SAndroid Build Coastguard Worker]> 186*7c568831SAndroid Build Coastguard Worker<test> 187*7c568831SAndroid Build Coastguard Worker &e; 188*7c568831SAndroid Build Coastguard Worker</test> 189*7c568831SAndroid Build Coastguard Worker""" 190*7c568831SAndroid Build Coastguard Workertst_ent = """<x>hello</x>""" 191*7c568831SAndroid Build Coastguard Workerexpect="""10 test 192*7c568831SAndroid Build Coastguard Worker1 test 193*7c568831SAndroid Build Coastguard Worker14 #text 194*7c568831SAndroid Build Coastguard Worker1 x 195*7c568831SAndroid Build Coastguard Worker3 #text 196*7c568831SAndroid Build Coastguard Worker15 x 197*7c568831SAndroid Build Coastguard Worker14 #text 198*7c568831SAndroid Build Coastguard Worker15 test 199*7c568831SAndroid Build Coastguard Worker""" 200*7c568831SAndroid Build Coastguard Workerres="" 201*7c568831SAndroid Build Coastguard Worker 202*7c568831SAndroid Build Coastguard Workerdef myResolver(URL, ID, ctxt): 203*7c568831SAndroid Build Coastguard Worker if URL == "tst.ent": 204*7c568831SAndroid Build Coastguard Worker return(str_io(tst_ent)) 205*7c568831SAndroid Build Coastguard Worker return None 206*7c568831SAndroid Build Coastguard Worker 207*7c568831SAndroid Build Coastguard Workerlibxml2.setEntityLoader(myResolver) 208*7c568831SAndroid Build Coastguard Worker 209*7c568831SAndroid Build Coastguard Workerinput = libxml2.inputBuffer(str_io(s)) 210*7c568831SAndroid Build Coastguard Workerreader = input.newTextReader("test3") 211*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_LOADDTD,1) 212*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) 213*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) 214*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_VALIDATE,1) 215*7c568831SAndroid Build Coastguard Workerwhile reader.Read() == 1: 216*7c568831SAndroid Build Coastguard Worker res = res + "%s %s\n" % (reader.NodeType(),reader.Name()) 217*7c568831SAndroid Build Coastguard Worker 218*7c568831SAndroid Build Coastguard Workerif res != expect: 219*7c568831SAndroid Build Coastguard Worker print("test3 failed: unexpected output") 220*7c568831SAndroid Build Coastguard Worker print(res) 221*7c568831SAndroid Build Coastguard Worker sys.exit(1) 222*7c568831SAndroid Build Coastguard Workerif err != "": 223*7c568831SAndroid Build Coastguard Worker print("test3 failed: validation error found") 224*7c568831SAndroid Build Coastguard Worker print(err) 225*7c568831SAndroid Build Coastguard Worker sys.exit(1) 226*7c568831SAndroid Build Coastguard Worker 227*7c568831SAndroid Build Coastguard Worker# 228*7c568831SAndroid Build Coastguard Worker# Another test for recursive entity parsing, validation, and replacement of 229*7c568831SAndroid Build Coastguard Worker# entities, making sure the entity ref node doesn't show up in that case 230*7c568831SAndroid Build Coastguard Worker# 231*7c568831SAndroid Build Coastguard Worker 232*7c568831SAndroid Build Coastguard Workers = """<!DOCTYPE test [ 233*7c568831SAndroid Build Coastguard Worker<!ELEMENT test (x, x)> 234*7c568831SAndroid Build Coastguard Worker<!ELEMENT x (y)> 235*7c568831SAndroid Build Coastguard Worker<!ELEMENT y (#PCDATA)> 236*7c568831SAndroid Build Coastguard Worker<!ENTITY x "<x>&y;</x>"> 237*7c568831SAndroid Build Coastguard Worker<!ENTITY y "<y>yyy</y>"> 238*7c568831SAndroid Build Coastguard Worker]> 239*7c568831SAndroid Build Coastguard Worker<test> 240*7c568831SAndroid Build Coastguard Worker &x; 241*7c568831SAndroid Build Coastguard Worker &x; 242*7c568831SAndroid Build Coastguard Worker</test>""" 243*7c568831SAndroid Build Coastguard Workerexpect="""10 test 0 244*7c568831SAndroid Build Coastguard Worker1 test 0 245*7c568831SAndroid Build Coastguard Worker14 #text 1 246*7c568831SAndroid Build Coastguard Worker1 x 1 247*7c568831SAndroid Build Coastguard Worker1 y 2 248*7c568831SAndroid Build Coastguard Worker3 #text 3 249*7c568831SAndroid Build Coastguard Worker15 y 2 250*7c568831SAndroid Build Coastguard Worker15 x 1 251*7c568831SAndroid Build Coastguard Worker14 #text 1 252*7c568831SAndroid Build Coastguard Worker1 x 1 253*7c568831SAndroid Build Coastguard Worker1 y 2 254*7c568831SAndroid Build Coastguard Worker3 #text 3 255*7c568831SAndroid Build Coastguard Worker15 y 2 256*7c568831SAndroid Build Coastguard Worker15 x 1 257*7c568831SAndroid Build Coastguard Worker14 #text 1 258*7c568831SAndroid Build Coastguard Worker15 test 0 259*7c568831SAndroid Build Coastguard Worker""" 260*7c568831SAndroid Build Coastguard Workerres="" 261*7c568831SAndroid Build Coastguard Workererr="" 262*7c568831SAndroid Build Coastguard Worker 263*7c568831SAndroid Build Coastguard Workerinput = libxml2.inputBuffer(str_io(s)) 264*7c568831SAndroid Build Coastguard Workerreader = input.newTextReader("test4") 265*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_LOADDTD,1) 266*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) 267*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) 268*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_VALIDATE,1) 269*7c568831SAndroid Build Coastguard Workerwhile reader.Read() == 1: 270*7c568831SAndroid Build Coastguard Worker res = res + "%s %s %d\n" % (reader.NodeType(),reader.Name(),reader.Depth()) 271*7c568831SAndroid Build Coastguard Worker 272*7c568831SAndroid Build Coastguard Workerif res != expect: 273*7c568831SAndroid Build Coastguard Worker print("test4 failed: unexpected output") 274*7c568831SAndroid Build Coastguard Worker print(res) 275*7c568831SAndroid Build Coastguard Worker sys.exit(1) 276*7c568831SAndroid Build Coastguard Workerif err != "": 277*7c568831SAndroid Build Coastguard Worker print("test4 failed: validation error found") 278*7c568831SAndroid Build Coastguard Worker print(err) 279*7c568831SAndroid Build Coastguard Worker sys.exit(1) 280*7c568831SAndroid Build Coastguard Worker 281*7c568831SAndroid Build Coastguard Worker# 282*7c568831SAndroid Build Coastguard Worker# The same test but without entity substitution this time 283*7c568831SAndroid Build Coastguard Worker# 284*7c568831SAndroid Build Coastguard Worker 285*7c568831SAndroid Build Coastguard Workers = """<!DOCTYPE test [ 286*7c568831SAndroid Build Coastguard Worker<!ELEMENT test (x, x)> 287*7c568831SAndroid Build Coastguard Worker<!ELEMENT x (y)> 288*7c568831SAndroid Build Coastguard Worker<!ELEMENT y (#PCDATA)> 289*7c568831SAndroid Build Coastguard Worker<!ENTITY x "<x>&y;</x>"> 290*7c568831SAndroid Build Coastguard Worker<!ENTITY y "<y>yyy</y>"> 291*7c568831SAndroid Build Coastguard Worker]> 292*7c568831SAndroid Build Coastguard Worker<test> 293*7c568831SAndroid Build Coastguard Worker &x; 294*7c568831SAndroid Build Coastguard Worker &x; 295*7c568831SAndroid Build Coastguard Worker</test>""" 296*7c568831SAndroid Build Coastguard Workerexpect="""10 test 0 297*7c568831SAndroid Build Coastguard Worker1 test 0 298*7c568831SAndroid Build Coastguard Worker14 #text 1 299*7c568831SAndroid Build Coastguard Worker5 x 1 300*7c568831SAndroid Build Coastguard Worker14 #text 1 301*7c568831SAndroid Build Coastguard Worker5 x 1 302*7c568831SAndroid Build Coastguard Worker14 #text 1 303*7c568831SAndroid Build Coastguard Worker15 test 0 304*7c568831SAndroid Build Coastguard Worker""" 305*7c568831SAndroid Build Coastguard Workerres="" 306*7c568831SAndroid Build Coastguard Workererr="" 307*7c568831SAndroid Build Coastguard Worker 308*7c568831SAndroid Build Coastguard Workerinput = libxml2.inputBuffer(str_io(s)) 309*7c568831SAndroid Build Coastguard Workerreader = input.newTextReader("test5") 310*7c568831SAndroid Build Coastguard Workerreader.SetParserProp(libxml2.PARSER_VALIDATE,1) 311*7c568831SAndroid Build Coastguard Workerwhile reader.Read() == 1: 312*7c568831SAndroid Build Coastguard Worker res = res + "%s %s %d\n" % (reader.NodeType(),reader.Name(),reader.Depth()) 313*7c568831SAndroid Build Coastguard Worker 314*7c568831SAndroid Build Coastguard Workerif res != expect: 315*7c568831SAndroid Build Coastguard Worker print("test5 failed: unexpected output") 316*7c568831SAndroid Build Coastguard Worker print(res) 317*7c568831SAndroid Build Coastguard Worker sys.exit(1) 318*7c568831SAndroid Build Coastguard Workerif err != "": 319*7c568831SAndroid Build Coastguard Worker print("test5 failed: validation error found") 320*7c568831SAndroid Build Coastguard Worker print(err) 321*7c568831SAndroid Build Coastguard Worker sys.exit(1) 322*7c568831SAndroid Build Coastguard Worker 323*7c568831SAndroid Build Coastguard Worker# 324*7c568831SAndroid Build Coastguard Worker# cleanup 325*7c568831SAndroid Build Coastguard Worker# 326*7c568831SAndroid Build Coastguard Workerdel input 327*7c568831SAndroid Build Coastguard Workerdel reader 328*7c568831SAndroid Build Coastguard Worker 329*7c568831SAndroid Build Coastguard Worker# Memory debug specific 330*7c568831SAndroid Build Coastguard Workerlibxml2.cleanupParser() 331*7c568831SAndroid Build Coastguard Workerif libxml2.debugMemory(1) == 0: 332*7c568831SAndroid Build Coastguard Worker print("OK") 333*7c568831SAndroid Build Coastguard Workerelse: 334*7c568831SAndroid Build Coastguard Worker print("Memory leak %d bytes" % (libxml2.debugMemory(1))) 335