mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-12-17 16:23:52 +03:00
sanitytest: move C API binding check into a helper method
This is a step towards turning the sanitytest.py file into a normal python unittest. Best viewed with the '-b' flag to diff. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
@@ -349,25 +349,33 @@ for klass in gotfunctions:
|
||||
if verbose:
|
||||
print("PASS %s.%s" % (klass, func))
|
||||
|
||||
# Phase 7: Validate that all the low level C APIs have binding
|
||||
for name, (klass, func, cname) in sorted(finalklassmap.items()):
|
||||
pyname = cname
|
||||
if pyname == "virSetErrorFunc":
|
||||
pyname = "virRegisterErrorHandler"
|
||||
elif pyname == "virConnectListDomains":
|
||||
pyname = "virConnectListDomainsID"
|
||||
|
||||
# These exist in C and exist in python, but we've got
|
||||
# a pure-python impl so don't check them
|
||||
if name in ["virStreamRecvAll", "virStreamSendAll",
|
||||
"virStreamSparseRecvAll", "virStreamSparseSendAll"]:
|
||||
continue
|
||||
# Validate that all the low level C APIs have binding
|
||||
def validate_c_api_bindings_present(finalklassmap):
|
||||
for name, (klass, func, cname) in sorted(finalklassmap.items()):
|
||||
pyname = cname
|
||||
if pyname == "virSetErrorFunc":
|
||||
pyname = "virRegisterErrorHandler"
|
||||
elif pyname == "virConnectListDomains":
|
||||
pyname = "virConnectListDomainsID"
|
||||
|
||||
try:
|
||||
thing = getattr(libvirt.libvirtmod, pyname)
|
||||
except AttributeError:
|
||||
print("FAIL libvirt.libvirtmod.%s (C binding does not exist)" % pyname)
|
||||
fail = True
|
||||
# These exist in C and exist in python, but we've got
|
||||
# a pure-python impl so don't check them
|
||||
if name in ["virStreamRecvAll", "virStreamSendAll",
|
||||
"virStreamSparseRecvAll", "virStreamSparseSendAll"]:
|
||||
continue
|
||||
|
||||
try:
|
||||
thing = getattr(libvirt.libvirtmod, pyname)
|
||||
except AttributeError:
|
||||
raise Exception("libvirt.libvirtmod.%s (C binding does not exist)" % pyname)
|
||||
|
||||
|
||||
try:
|
||||
validate_c_api_bindings_present(finalklassmap)
|
||||
except Exception as e:
|
||||
print("FAIL: %s" % e)
|
||||
fail = True
|
||||
|
||||
if fail:
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user