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
commit87e62db6d38a1e250ca7b44fb388f7edf4b9f27a (patch)
tree5d52040d400b1cb8488bd8826bdf0ca8dfcd8184
parent45fa54ab67396217b2524c21b00adec0ce9b7824 (diff)
downloadlibvirt-python-87e62db6d38a1e250ca7b44fb388f7edf4b9f27a.tar.gz
sanitytest: move python to C API mapping 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.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/sanitytest.py b/sanitytest.py
index a87cbdc..2d30a22 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -330,24 +330,24 @@ for name, (klass, func, cname) in sorted(finalklassmap.items()):
fail = True
-# Phase 6: Validate that every python API has a corresponding C API
-for klass in gotfunctions:
- if klass == "libvirtError":
- continue
- for func in sorted(gotfunctions[klass]):
- # These are pure python methods with no C APi
- if func in ["connect", "getConnect", "domain", "getDomain",
- "virEventInvokeFreeCallback", "network",
- "sparseRecvAll", "sparseSendAll"]:
+# Validate that every python API has a corresponding C API
+def validate_python_to_c_api_mappings(gotfunctions, usedfunctions):
+ for klass in gotfunctions:
+ if klass == "libvirtError":
continue
+ for func in sorted(gotfunctions[klass]):
+ # These are pure python methods with no C APi
+ if func in ["connect", "getConnect", "domain", "getDomain",
+ "virEventInvokeFreeCallback", "network",
+ "sparseRecvAll", "sparseSendAll"]:
+ continue
- key = "%s.%s" % (klass, func)
- if key not in usedfunctions:
- print("FAIL %s.%s (Python API not mapped to C)" % (klass, func))
- fail = True
- else:
- if verbose:
- print("PASS %s.%s" % (klass, func))
+ key = "%s.%s" % (klass, func)
+ if key not in usedfunctions:
+ raise Exception("%s.%s (Python API not mapped to C)" % (klass, func))
+ else:
+ if verbose:
+ print("PASS %s.%s" % (klass, func))
# Validate that all the low level C APIs have binding
@@ -372,6 +372,7 @@ def validate_c_api_bindings_present(finalklassmap):
try:
+ validate_python_to_c_api_mappings(gotfunctions, usedfunctions)
validate_c_api_bindings_present(finalklassmap)
except Exception as e:
print("FAIL: %s" % e)