|
version 1.1.1.1, 2012/02/21 23:38:00
|
version 1.1.1.2, 2014/06/15 19:53:34
|
|
Line 1
|
Line 1
|
| #!/usr/bin/python -u |
#!/usr/bin/python -u |
| import string, sys, time |
import string, sys, time |
| import thread | try: |
| | from _thread import get_ident |
| | except: |
| | from thread import get_ident |
| from threading import Thread, Lock |
from threading import Thread, Lock |
| |
|
| import libxml2 |
import libxml2 |
|
Line 31 def test(expectedLineNumbersDefault):
|
Line 34 def test(expectedLineNumbersDefault):
|
| # check a per thread-global |
# check a per thread-global |
| if expectedLineNumbersDefault != getLineNumbersDefault(): |
if expectedLineNumbersDefault != getLineNumbersDefault(): |
| failed = 1 |
failed = 1 |
| print "FAILED to obtain correct value for " \ | print("FAILED to obtain correct value for " \ |
| "lineNumbersDefault in thread %d" % thread.get_ident() | "lineNumbersDefault in thread %d" % get_ident()) |
| # check ther global error handler |
# check ther global error handler |
| # (which is NOT per-thread in the python bindings) |
# (which is NOT per-thread in the python bindings) |
| try: |
try: |
|
Line 51 libxml2.lineNumbersDefault(1)
|
Line 54 libxml2.lineNumbersDefault(1)
|
| test(1) |
test(1) |
| ec = len(eh.errors) |
ec = len(eh.errors) |
| if ec == 0: |
if ec == 0: |
| print "FAILED: should have obtained errors" | print("FAILED: should have obtained errors") |
| sys.exit(1) |
sys.exit(1) |
| |
|
| ts = [] |
ts = [] |
|
Line 65 for t in ts:
|
Line 68 for t in ts:
|
| t.join() |
t.join() |
| |
|
| if len(eh.errors) != ec+THREADS_COUNT*ec: |
if len(eh.errors) != ec+THREADS_COUNT*ec: |
| print "FAILED: did not obtain the correct number of errors" | print("FAILED: did not obtain the correct number of errors") |
| sys.exit(1) |
sys.exit(1) |
| |
|
| # set lineNumbersDefault for future new threads |
# set lineNumbersDefault for future new threads |
|
Line 80 for t in ts:
|
Line 83 for t in ts:
|
| t.join() |
t.join() |
| |
|
| if len(eh.errors) != ec+THREADS_COUNT*ec*2: |
if len(eh.errors) != ec+THREADS_COUNT*ec*2: |
| print "FAILED: did not obtain the correct number of errors" | print("FAILED: did not obtain the correct number of errors") |
| sys.exit(1) |
sys.exit(1) |
| |
|
| if failed: |
if failed: |
| print "FAILED" | print("FAILED") |
| sys.exit(1) |
sys.exit(1) |
| |
|
| # Memory debug specific |
# Memory debug specific |
| libxml2.cleanupParser() |
libxml2.cleanupParser() |
| if libxml2.debugMemory(1) == 0: |
if libxml2.debugMemory(1) == 0: |
| print "OK" | print("OK") |
| else: |
else: |
| print "Memory leak %d bytes" % (libxml2.debugMemory(1)) | print("Memory leak %d bytes" % (libxml2.debugMemory(1))) |
| libxml2.dumpMemory() |
libxml2.dumpMemory() |