Marek Marczykowski-Górecki wrote: > Handle features supported only on xen: driver domains, qemu in > stubdomain. > > Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx> > [...] > diff --git a/tests/xlxml2xmltest.c b/tests/xlxml2xmltest.c > new file mode 100644 > index 0000000..131e43b > --- /dev/null > +++ b/tests/xlxml2xmltest.c > @@ -0,0 +1,189 @@ > +#include <config.h> > + > +#include <stdio.h> > +#include <stdlib.h> > +#include <unistd.h> > +#include <string.h> > + > +#include <sys/types.h> > +#include <fcntl.h> > + > +#include "testutils.h" > + > +#ifdef WITH_LIBXL > + > +# include "internal.h" > +# include "libxl/libxl_conf.h" > +# include "libxl/libxl_domain.h" > +# include "testutilsxen.h" > +# include "virstring.h" > + > +# define VIR_FROM_THIS VIR_FROM_NONE > + > +static virCapsPtr caps; > +static virDomainXMLOptionPtr xmlopt; > + > +static int > +testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) > +{ > + char *inXmlData = NULL; > + char *outXmlData = NULL; > + char *actual = NULL; > + int ret = -1; > + virDomainDefPtr def = NULL; > + unsigned int parse_flags = live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE; > + unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE; > + if (!live) > + format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE; > + > Perhaps I'm being dense, but it is not clear to me what this is testing wrt libxl or xenconfig code. xml config is read from a file > + if (virtTestLoadFile(inxml, &inXmlData) < 0) > + goto fail; > + if (virtTestLoadFile(outxml, &outXmlData) < 0) > + goto fail; > + > + if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt, > + 1 << VIR_DOMAIN_VIRT_XEN, parse_flags))) > + goto fail; > + > parsed with virDomainDefParseString (which does invoke the libxl driver post-parse callbacks) > + if (!virDomainDefCheckABIStability(def, def)) { > + fprintf(stderr, "ABI stability check failed on %s", inxml); > + goto fail; > + } > virDomainDefCheckABIStability called with identical def > + > + if (!(actual = virDomainDefFormat(def, format_flags))) > + goto fail; > converted back to XML > + > + if (STRNEQ(outXmlData, actual)) { > + virtTestDifferenceFull(stderr, outXmlData, outxml, actual, inxml); > + goto fail; > and then compared with xml config read from a file. I suppose the post-parse callbacks are being tested. IMO, a more useful test would be domain XML -> libxl_domain_config -> JSON doc, comparing the output JSON doc to a template doc. Daniel Berrange started work on such a test, which I toiled on later, but we've yet to find a nice solution that works across Xen >= 4.2. This work was last discussed in January https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html Suggestions welcomed! Regards, Jim -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list