VirtualBox

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

Last change on this file since 105420 was 105420, checked in by vboxsync, 8 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.2 KB
Line 
1#!/usr/bin/env python3
2#
3# this test exercise the XPath basic engine, parser, etc, and
4# allows to detect memory leaks
5#
6import sys
7import setup_test
8import libxml2
9
10# Memory debug specific
11libxml2.debugMemory(1)
12
13doc = libxml2.parseFile("tst.xml")
14if doc.name != "tst.xml":
15 print("doc.name error")
16 sys.exit(1);
17
18ctxt = doc.xpathNewContext()
19res = ctxt.xpathEval("//*")
20if len(res) != 2:
21 print("xpath query: wrong node set size")
22 sys.exit(1)
23if res[0].name != "doc" or res[1].name != "foo":
24 print("xpath query: wrong node set value")
25 sys.exit(1)
26ctxt.setContextNode(res[0])
27res = ctxt.xpathEval("foo")
28if len(res) != 1:
29 print("xpath query: wrong node set size")
30 sys.exit(1)
31if res[0].name != "foo":
32 print("xpath query: wrong node set value")
33 sys.exit(1)
34doc.freeDoc()
35ctxt.xpathFreeContext()
36i = 1000
37while i > 0:
38 doc = libxml2.parseFile("tst.xml")
39 ctxt = doc.xpathNewContext()
40 res = ctxt.xpathEval("//*")
41 doc.freeDoc()
42 ctxt.xpathFreeContext()
43 i = i -1
44del ctxt
45
46# Memory debug specific
47libxml2.cleanupParser()
48if libxml2.debugMemory(1) == 0:
49 print("OK")
50else:
51 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
Note: See TracBrowser for help on using the repository browser.

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