import sys
import time
import os
import string
import libxml2
#
# the testsuite description
#
#
# Error and warning handlers
#
global error_nr
global error_msg
else:
#warning_nr = 0
#warning = ''
#def warningHandler(ctx, str):
# global warning_nr
# global warning
#
# warning_nr = warning_nr + 1
# warning = warning + str
#
#libxml2.registerWarningHandler(warningHandler, None)
#
# Used to load the XML testsuite description
#
if ctxt == None:
return None
try:
except:
doc = None
return None
return doc
#
# The conformance testing routines
#
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
if doc != None:
print "%s: error: Well Formedness error not detected" % (id)
return 0
return 1
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
if doc != None:
print "%s: error: Well Formedness error not detected" % (id)
return 0
return 1
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
if doc != None:
print "%s: error: Well Formedness error not detected" % (id)
return 0
return 1
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
print "%s: error: wrongly failed to parse the document" % (id)
if doc != None:
return 0
if error_nr != 0:
print "%s: warning: WF document generated an error msg" % (id)
return 2
return 1
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
if doc != None:
print "%s: warning: failed to parse the document but accepted" % (id)
return 2
if error_nr != 0:
print "%s: warning: WF document generated an error msg" % (id)
return 2
return 1
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
if doc == None:
print "%s: error: wrongly failed to parse the document" % (id)
return 0
if valid == 1:
print "%s: error: Validity error not detected" % (id)
return 0
if error_nr == 0:
print "%s: warning: Validity error not reported" % (id)
return 2
return 1
global error_nr
global error_msg
error_nr = 0
error_msg = ''
if ctxt == None:
return -1
try:
except:
doc = None
if doc == None:
print "%s: error: wrongly failed to parse the document" % (id)
return 0
if valid != 1:
print "%s: error: Validity check failed" % (id)
return 0
print "%s: warning: valid document reported an error" % (id)
return 2
return 1
global test_nr
global test_succeed
global test_failed
global error_msg
global log
if uri == None:
print "Test without ID:", uri
return -1
if id == None:
print "Test without URI:", id
return -1
return -1
if type == None:
print "Test %s missing TYPE" % (id)
return -1
extra = None
if type == "invalid":
elif type == "valid":
elif type == "not-wf":
# print URI
#if extra == None:
# res = testNotWfEntDtd(URI, id)
#elif extra == 'none':
# res = testNotWf(URI, id)
#elif extra == 'general':
# res = testNotWfEnt(URI, id)
#elif extra == 'both' or extra == 'parameter':
#else:
# print "Unknow value %s for an ENTITIES test value" % (extra)
# return -1
elif type == "error":
else:
# TODO skipped for now
return -1
if res > 0:
elif res == 0:
elif res < 0:
# Log the ontext
if res != 1:
if extra != None:
else:
if error_msg != '':
error_msg = ''
return 0
if profile != None and \
print "=>", profile
while test != None:
if conf == None:
print "Unable to load %s" % CONF
print "Expecting TESTSUITE root element: aborting"
if profile != None:
print profile
while case != None:
print " Ran %d tests: %d suceeded, %d failed and %d generated an error" % (
print "Ran %d tests: %d suceeded, %d failed and %d generated an error in %.2f s." % (