Last change
on this file 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.0 KB
|
Line | |
---|
1 | #!/usr/bin/env python3
|
---|
2 | #
|
---|
3 | # This test exercise the redirection of error messages with a
|
---|
4 | # functions defined in Python.
|
---|
5 | #
|
---|
6 | import sys
|
---|
7 | import setup_test
|
---|
8 | import libxml2
|
---|
9 |
|
---|
10 | # Memory debug specific
|
---|
11 | libxml2.debugMemory(1)
|
---|
12 |
|
---|
13 | expect='--> I/O --> warning : --> failed to load "missing.xml": No such file or directory\n'
|
---|
14 | err=""
|
---|
15 | def callback(ctx, str):
|
---|
16 | global err
|
---|
17 |
|
---|
18 | err = err + "%s %s" % (ctx, str)
|
---|
19 |
|
---|
20 | got_exc = 0
|
---|
21 | libxml2.registerErrorHandler(callback, "-->")
|
---|
22 | try:
|
---|
23 | doc = libxml2.parseFile("missing.xml")
|
---|
24 | except libxml2.parserError:
|
---|
25 | got_exc = 1
|
---|
26 |
|
---|
27 | if got_exc == 0:
|
---|
28 | print("Failed to get a parser exception")
|
---|
29 | sys.exit(1)
|
---|
30 |
|
---|
31 | if err != expect:
|
---|
32 | print("error")
|
---|
33 | print("received %s" %(err))
|
---|
34 | print("expected %s" %(expect))
|
---|
35 | sys.exit(1)
|
---|
36 |
|
---|
37 | i = 10000
|
---|
38 | while i > 0:
|
---|
39 | try:
|
---|
40 | doc = libxml2.parseFile("missing.xml")
|
---|
41 | except libxml2.parserError:
|
---|
42 | got_exc = 1
|
---|
43 | err = ""
|
---|
44 | i = i - 1
|
---|
45 |
|
---|
46 | # Memory debug specific
|
---|
47 | libxml2.cleanupParser()
|
---|
48 | if libxml2.debugMemory(1) == 0:
|
---|
49 | print("OK")
|
---|
50 | else:
|
---|
51 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.