Annotation of embedaddon/libxml2/python/tests/validate.py, revision 1.1
1.1 ! misho 1: #!/usr/bin/python -u
! 2: import sys
! 3: import libxml2
! 4:
! 5: # Memory debug specific
! 6: libxml2.debugMemory(1)
! 7:
! 8: ctxt = libxml2.createFileParserCtxt("valid.xml")
! 9: ctxt.validate(1)
! 10: ctxt.parseDocument()
! 11: doc = ctxt.doc()
! 12: valid = ctxt.isValid()
! 13:
! 14: if doc.name != "valid.xml":
! 15: print "doc.name failed"
! 16: sys.exit(1)
! 17: root = doc.children
! 18: if root.name != "doc":
! 19: print "root.name failed"
! 20: sys.exit(1)
! 21: if valid != 1:
! 22: print "validity chec failed"
! 23: sys.exit(1)
! 24: doc.freeDoc()
! 25:
! 26: i = 1000
! 27: while i > 0:
! 28: ctxt = libxml2.createFileParserCtxt("valid.xml")
! 29: ctxt.validate(1)
! 30: ctxt.parseDocument()
! 31: doc = ctxt.doc()
! 32: valid = ctxt.isValid()
! 33: doc.freeDoc()
! 34: if valid != 1:
! 35: print "validity check failed"
! 36: sys.exit(1)
! 37: i = i - 1
! 38:
! 39: #desactivate error messages from the validation
! 40: def noerr(ctx, str):
! 41: pass
! 42:
! 43: libxml2.registerErrorHandler(noerr, None)
! 44:
! 45: ctxt = libxml2.createFileParserCtxt("invalid.xml")
! 46: ctxt.validate(1)
! 47: ctxt.parseDocument()
! 48: doc = ctxt.doc()
! 49: valid = ctxt.isValid()
! 50: if doc.name != "invalid.xml":
! 51: print "doc.name failed"
! 52: sys.exit(1)
! 53: root = doc.children
! 54: if root.name != "doc":
! 55: print "root.name failed"
! 56: sys.exit(1)
! 57: if valid != 0:
! 58: print "validity chec failed"
! 59: sys.exit(1)
! 60: doc.freeDoc()
! 61:
! 62: i = 1000
! 63: while i > 0:
! 64: ctxt = libxml2.createFileParserCtxt("invalid.xml")
! 65: ctxt.validate(1)
! 66: ctxt.parseDocument()
! 67: doc = ctxt.doc()
! 68: valid = ctxt.isValid()
! 69: doc.freeDoc()
! 70: if valid != 0:
! 71: print "validity check failed"
! 72: sys.exit(1)
! 73: i = i - 1
! 74: del ctxt
! 75:
! 76: # Memory debug specific
! 77: libxml2.cleanupParser()
! 78: if libxml2.debugMemory(1) == 0:
! 79: print "OK"
! 80: else:
! 81: print "Memory leak %d bytes" % (libxml2.debugMemory(1))
! 82: libxml2.dumpMemory()
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>