summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-03-22 17:52:55 +0000
committerDaniel P. Berrangé <berrange@redhat.com>2022-04-21 15:00:29 +0000
commit45fa54ab67396217b2524c21b00adec0ce9b7824 (patch)
tree3b52bd9d854a8f1ca4f1cb29ee492d86ca72e925
parentd4dfac2a4328eb56b10c14195fdd4dc8faadbec4 (diff)
downloadlibvirt-python-45fa54ab67396217b2524c21b00adec0ce9b7824.tar.gz
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>
-rw-r--r--sanitytest.py44
1 files changed, 26 insertions, 18 deletions
diff --git a/sanitytest.py b/sanitytest.py
index 04cf0e4..a87cbdc 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -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
- try:
- thing = getattr(libvirt.libvirtmod, pyname)
- except AttributeError:
- print("FAIL libvirt.libvirtmod.%s (C binding does not exist)" % pyname)
- fail = True
+# 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"
+
+ # 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)