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
commitb29d0aaa26f5bdc25b88908cfdf5fad9e53dac62 (patch)
treec2d2f21a31a556b3538bf4b000510f4daad7b4a1
parent87e62db6d38a1e250ca7b44fb388f7edf4b9f27a (diff)
downloadlibvirt-python-b29d0aaa26f5bdc25b88908cfdf5fad9e53dac62.tar.gz
sanitytest: move C to python 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.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/sanitytest.py b/sanitytest.py
index 2d30a22..1ab4620 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -318,16 +318,17 @@ for name, (klass, func, cname) in sorted(basicklassmap.items()):
finalklassmap[name] = (klass, func, cname)
-# Phase 5: Validate sure that every C API is mapped to a python API
-usedfunctions = set() # type: Set[str]
-for name, (klass, func, cname) in sorted(finalklassmap.items()):
- if func in gotfunctions[klass]:
- usedfunctions.add("%s.%s" % (klass, func))
- if verbose:
- print("PASS %s -> %s.%s" % (name, klass, func))
- else:
- print("FAIL %s -> %s.%s (C API not mapped to python)" % (name, klass, func))
- fail = True
+# Validate that every C API is mapped to a python API
+def validate_c_to_python_api_mappings(finalklassmap, gotfunctions):
+ usedfunctions = set() # type: Set[str]
+ for name, (klass, func, cname) in sorted(finalklassmap.items()):
+ if func in gotfunctions[klass]:
+ usedfunctions.add("%s.%s" % (klass, func))
+ if verbose:
+ print("PASS %s -> %s.%s" % (name, klass, func))
+ else:
+ raise Exception("%s -> %s.%s (C API not mapped to python)" % (name, klass, func))
+ return usedfunctions
# Validate that every python API has a corresponding C API
@@ -372,6 +373,7 @@ def validate_c_api_bindings_present(finalklassmap):
try:
+ usedfunctions = validate_c_to_python_api_mappings(finalklassmap, gotfunctions)
validate_python_to_c_api_mappings(gotfunctions, usedfunctions)
validate_c_api_bindings_present(finalklassmap)
except Exception as e: