mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Fix missing error constants in libvirt python module
The previous change to the generator, changed too much - only the functions are in 'virerror.c', the constants remained in 'virerror.h' which could not be renamed for API compat reasons. Add a test case to sanity check the generated python bindings Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
@@ -119,6 +119,11 @@ $(libvirtmod_la_OBJECTS): $(GENERATED)
|
|||||||
$(libvirtmod_qemu_la_OBJECTS): $(QEMU_GENERATED)
|
$(libvirtmod_qemu_la_OBJECTS): $(QEMU_GENERATED)
|
||||||
$(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
|
$(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
|
||||||
|
|
||||||
|
EXTRA_DIST += sanitytest.py
|
||||||
|
|
||||||
|
check-local:
|
||||||
|
$(AM_V_GEN)PYTHONPATH=$(abs_topbuilddir):$(abs_topbuilddir)/.libs $(PYTHON) $(srcdir)/sanitytest.py
|
||||||
|
|
||||||
install-data-local:
|
install-data-local:
|
||||||
$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
|
$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
|
||||||
$(INSTALL) -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
|
$(INSTALL) -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
|
||||||
|
|||||||
@@ -122,8 +122,9 @@ class docParser(xml.sax.handler.ContentHandler):
|
|||||||
if attrs.has_key('field'):
|
if attrs.has_key('field'):
|
||||||
self.function_return_field = attrs['field']
|
self.function_return_field = attrs['field']
|
||||||
elif tag == 'enum':
|
elif tag == 'enum':
|
||||||
|
# enums come from header files, hence virterror.h
|
||||||
if (attrs['file'] == "libvirt" or
|
if (attrs['file'] == "libvirt" or
|
||||||
attrs['file'] == "virerror"):
|
attrs['file'] == "virterror"):
|
||||||
enum(attrs['type'],attrs['name'],attrs['value'])
|
enum(attrs['type'],attrs['name'],attrs['value'])
|
||||||
elif attrs['file'] == "libvirt-lxc":
|
elif attrs['file'] == "libvirt-lxc":
|
||||||
lxc_enum(attrs['type'],attrs['name'],attrs['value'])
|
lxc_enum(attrs['type'],attrs['name'],attrs['value'])
|
||||||
@@ -134,6 +135,7 @@ class docParser(xml.sax.handler.ContentHandler):
|
|||||||
if debug:
|
if debug:
|
||||||
print "end %s" % tag
|
print "end %s" % tag
|
||||||
if tag == 'function':
|
if tag == 'function':
|
||||||
|
# fuctions come from source files, hence 'virerror.c'
|
||||||
if self.function != None:
|
if self.function != None:
|
||||||
if (self.function_module == "libvirt" or
|
if (self.function_module == "libvirt" or
|
||||||
self.function_module == "virevent" or
|
self.function_module == "virevent" or
|
||||||
|
|||||||
31
python/sanitytest.py
Normal file
31
python/sanitytest.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import libvirt
|
||||||
|
|
||||||
|
globals = dir(libvirt)
|
||||||
|
|
||||||
|
# Sanity test that the generator hasn't gone wrong
|
||||||
|
|
||||||
|
# Look for core classes
|
||||||
|
assert("virConnect" in globals)
|
||||||
|
assert("virDomain" in globals)
|
||||||
|
assert("virDomainSnapshot" in globals)
|
||||||
|
assert("virInterface" in globals)
|
||||||
|
assert("virNWFilter" in globals)
|
||||||
|
assert("virNodeDevice" in globals)
|
||||||
|
assert("virNetwork" in globals)
|
||||||
|
assert("virSecret" in globals)
|
||||||
|
assert("virStoragePool" in globals)
|
||||||
|
assert("virStorageVol" in globals)
|
||||||
|
assert("virStream" in globals)
|
||||||
|
assert("VIR_CONNECT_RO" in globals)
|
||||||
|
|
||||||
|
# Error related bits
|
||||||
|
assert("libvirtError" in globals)
|
||||||
|
assert("VIR_ERR_AUTH_FAILED" in globals)
|
||||||
|
assert("virGetLastError" in globals)
|
||||||
|
|
||||||
|
# Some misc methods
|
||||||
|
assert("virInitialize" in globals)
|
||||||
|
assert("virEventAddHandle" in globals)
|
||||||
|
assert("virEventRegisterDefaultImpl" in globals)
|
||||||
Reference in New Issue
Block a user