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:
|
if verbose:
|
||||||
print("PASS %s.%s" % (klass, func))
|
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
|
# Validate that all the low level C APIs have binding
|
||||||
# a pure-python impl so don't check them
|
def validate_c_api_bindings_present(finalklassmap):
|
||||||
if name in ["virStreamRecvAll", "virStreamSendAll",
|
for name, (klass, func, cname) in sorted(finalklassmap.items()):
|
||||||
"virStreamSparseRecvAll", "virStreamSparseSendAll"]:
|
pyname = cname
|
||||||
continue
|
if pyname == "virSetErrorFunc":
|
||||||
|
pyname = "virRegisterErrorHandler"
|
||||||
|
elif pyname == "virConnectListDomains":
|
||||||
|
pyname = "virConnectListDomainsID"
|
||||||
|
|
||||||
try:
|
# These exist in C and exist in python, but we've got
|
||||||
thing = getattr(libvirt.libvirtmod, pyname)
|
# a pure-python impl so don't check them
|
||||||
except AttributeError:
|
if name in ["virStreamRecvAll", "virStreamSendAll",
|
||||||
print("FAIL libvirt.libvirtmod.%s (C binding does not exist)" % pyname)
|
"virStreamSparseRecvAll", "virStreamSparseSendAll"]:
|
||||||
fail = True
|
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:
|
if fail:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user