VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/validate.py@ 105420

Last change on this file since 105420 was 105420, checked in by vboxsync, 7 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/env python3
2import sys
3import setup_test
4import libxml2
5
6# Memory debug specific
7libxml2.debugMemory(1)
8
9ctxt = libxml2.createFileParserCtxt("valid.xml")
10ctxt.validate(1)
11ctxt.parseDocument()
12doc = ctxt.doc()
13valid = ctxt.isValid()
14
15if doc.name != "valid.xml":
16 print("doc.name failed")
17 sys.exit(1)
18root = doc.children
19if root.name != "doc":
20 print("root.name failed")
21 sys.exit(1)
22if valid != 1:
23 print("validity chec failed")
24 sys.exit(1)
25doc.freeDoc()
26
27i = 1000
28while i > 0:
29 ctxt = libxml2.createFileParserCtxt("valid.xml")
30 ctxt.validate(1)
31 ctxt.parseDocument()
32 doc = ctxt.doc()
33 valid = ctxt.isValid()
34 doc.freeDoc()
35 if valid != 1:
36 print("validity check failed")
37 sys.exit(1)
38 i = i - 1
39
40#deactivate error messages from the validation
41def noerr(ctx, str):
42 pass
43
44libxml2.registerErrorHandler(noerr, None)
45
46ctxt = libxml2.createFileParserCtxt("invalid.xml")
47ctxt.validate(1)
48ctxt.parseDocument()
49doc = ctxt.doc()
50valid = ctxt.isValid()
51if doc.name != "invalid.xml":
52 print("doc.name failed")
53 sys.exit(1)
54root = doc.children
55if root.name != "doc":
56 print("root.name failed")
57 sys.exit(1)
58if valid != 0:
59 print("validity chec failed")
60 sys.exit(1)
61doc.freeDoc()
62
63i = 1000
64while i > 0:
65 ctxt = libxml2.createFileParserCtxt("invalid.xml")
66 ctxt.validate(1)
67 ctxt.parseDocument()
68 doc = ctxt.doc()
69 valid = ctxt.isValid()
70 doc.freeDoc()
71 if valid != 0:
72 print("validity check failed")
73 sys.exit(1)
74 i = i - 1
75del ctxt
76
77# Memory debug specific
78libxml2.cleanupParser()
79if libxml2.debugMemory(1) == 0:
80 print("OK")
81else:
82 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette