Example #1
0
static int
testCompareFiles(const char *xml, const char *sexpr)
{
    char *gotsexpr = NULL;
    int ret = -1;
    virDomainDefPtr def = NULL;

    if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL,
                                      VIR_DOMAIN_DEF_PARSE_INACTIVE)))
        goto fail;

    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
        fprintf(stderr, "ABI stability check failed on %s", xml);
        goto fail;
    }

    if (!(gotsexpr = xenFormatSxpr(NULL, def)))
        goto fail;

    if (virTestCompareToFile(gotsexpr, sexpr) < 0)
        goto fail;

    ret = 0;

 fail:
    VIR_FREE(gotsexpr);
    virDomainDefFree(def);

    return ret;
}
Example #2
0
static int
testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
{
  char *xmlData = NULL;
  char *sexprData = NULL;
  char *gotsexpr = NULL;
  int ret = -1;
  virDomainDefPtr def = NULL;

  if (virtTestLoadFile(xml, &xmlData) < 0)
      goto fail;

  if (virtTestLoadFile(sexpr, &sexprData) < 0)
      goto fail;

  if (!(def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_XEN,
                                      VIR_DOMAIN_XML_INACTIVE)))
      goto fail;

  if (!(gotsexpr = xenFormatSxpr(NULL, def, xendConfigVersion)))
      goto fail;

  if (STRNEQ(sexprData, gotsexpr)) {
      virtTestDifference(stderr, sexprData, gotsexpr);
      goto fail;
  }

  ret = 0;

 fail:
  VIR_FREE(xmlData);
  VIR_FREE(sexprData);
  VIR_FREE(gotsexpr);
  virDomainDefFree(def);

  return ret;
}