2006-08-24 15:05:19 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2007-03-15 07:43:16 +00:00
|
|
|
#ifdef WITH_XEN
|
2006-08-24 15:05:19 +00:00
|
|
|
#include "xml.h"
|
|
|
|
#include "xend_internal.h"
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
static char *progname;
|
|
|
|
|
|
|
|
#define MAX_FILE 4096
|
|
|
|
|
2006-09-12 01:16:22 +00:00
|
|
|
static int testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) {
|
2006-08-24 15:05:19 +00:00
|
|
|
char xmlData[MAX_FILE];
|
|
|
|
char sexprData[MAX_FILE];
|
|
|
|
char *gotxml = NULL;
|
|
|
|
char *xmlPtr = &(xmlData[0]);
|
|
|
|
char *sexprPtr = &(sexprData[0]);
|
2006-10-06 15:32:48 +00:00
|
|
|
int ret = -1;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
|
|
|
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
|
2006-10-06 15:32:48 +00:00
|
|
|
goto fail;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
|
|
|
if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
|
2006-10-06 15:32:48 +00:00
|
|
|
goto fail;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
2006-09-12 01:16:22 +00:00
|
|
|
if (!(gotxml = xend_parse_domain_sexp(NULL, sexprData, xendConfigVersion)))
|
2006-10-06 15:32:48 +00:00
|
|
|
goto fail;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
|
|
|
if (getenv("DEBUG_TESTS")) {
|
2006-09-14 15:34:50 +00:00
|
|
|
printf("Expect %d '%s'\n", (int)strlen(xmlData), xmlData);
|
|
|
|
printf("Actual %d '%s'\n", (int)strlen(gotxml), gotxml);
|
2006-08-24 15:05:19 +00:00
|
|
|
}
|
|
|
|
if (strcmp(xmlData, gotxml))
|
2006-10-06 15:32:48 +00:00
|
|
|
goto fail;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
2006-10-06 15:32:48 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
free(gotxml);
|
|
|
|
|
|
|
|
return ret;
|
2006-08-24 15:05:19 +00:00
|
|
|
}
|
|
|
|
|
2006-09-12 01:16:22 +00:00
|
|
|
static int testComparePVversion1(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-pv.sexpr",
|
|
|
|
1);
|
2006-08-24 15:05:19 +00:00
|
|
|
}
|
|
|
|
|
2006-09-12 01:16:22 +00:00
|
|
|
static int testCompareFVversion1(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-fv.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testComparePVversion2(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-pv.sexpr",
|
|
|
|
2);
|
|
|
|
}
|
|
|
|
|
2006-12-06 23:44:17 +00:00
|
|
|
static int testComparePVOrigVFB(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr",
|
|
|
|
2);
|
2006-12-13 14:08:51 +00:00
|
|
|
}
|
2006-12-06 23:44:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int testComparePVNewVFB(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-new.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr",
|
|
|
|
3);
|
2006-12-13 14:08:51 +00:00
|
|
|
}
|
2006-12-06 23:44:17 +00:00
|
|
|
|
|
|
|
|
2006-09-12 01:16:22 +00:00
|
|
|
static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-v2.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
|
|
|
|
2);
|
2006-08-24 15:05:19 +00:00
|
|
|
}
|
|
|
|
|
2006-10-09 14:32:07 +00:00
|
|
|
static int testCompareDiskFile(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-file.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-disk-file.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testCompareDiskBlock(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-block.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-disk-block.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testCompareDiskDrvBlktapQcow(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testCompareDiskDrvBlktapRaw(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
2006-11-10 11:13:01 +00:00
|
|
|
static int testCompareResizedMemory(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-curmem.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-curmem.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
2006-10-09 14:32:07 +00:00
|
|
|
|
2006-11-15 00:38:13 +00:00
|
|
|
static int testCompareNetRouted(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-net-routed.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-net-routed.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testCompareNetBridged(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-net-bridged.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-net-bridged.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
2007-04-11 16:06:30 +00:00
|
|
|
static int testCompareNoSourceCDRom(void *data ATTRIBUTE_UNUSED) {
|
|
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-no-source-cdrom.xml",
|
|
|
|
"sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr",
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
2006-11-15 00:38:13 +00:00
|
|
|
|
2006-08-24 15:05:19 +00:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2006-10-09 14:32:07 +00:00
|
|
|
|
2006-08-24 15:05:19 +00:00
|
|
|
progname = argv[0];
|
2006-10-09 14:32:07 +00:00
|
|
|
|
2006-08-24 15:05:19 +00:00
|
|
|
if (argc > 1) {
|
2006-10-09 14:32:07 +00:00
|
|
|
fprintf(stderr, "Usage: %s\n", progname);
|
|
|
|
exit(EXIT_FAILURE);
|
2006-08-24 15:05:19 +00:00
|
|
|
}
|
2006-10-09 14:32:07 +00:00
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML PV config (version 1)",
|
2006-09-12 01:16:22 +00:00
|
|
|
1, testComparePVversion1, NULL) != 0)
|
2006-10-09 14:32:07 +00:00
|
|
|
ret = -1;
|
2006-09-12 01:16:22 +00:00
|
|
|
|
2006-10-09 14:32:07 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML FV config (version 1)",
|
2006-09-12 01:16:22 +00:00
|
|
|
1, testCompareFVversion1, NULL) != 0)
|
2006-10-09 14:32:07 +00:00
|
|
|
ret = -1;
|
2006-09-12 01:16:22 +00:00
|
|
|
|
2006-10-09 14:32:07 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML PV config (version 2)",
|
2006-09-12 01:16:22 +00:00
|
|
|
1, testComparePVversion2, NULL) != 0)
|
2006-10-09 14:32:07 +00:00
|
|
|
ret = -1;
|
2006-12-13 14:08:51 +00:00
|
|
|
|
2006-12-06 23:44:17 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML PV config (Orig VFB)",
|
|
|
|
1, testComparePVOrigVFB, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML PV config (New VFB)",
|
|
|
|
1, testComparePVNewVFB, NULL) != 0)
|
|
|
|
ret = -1;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
2006-12-06 23:44:17 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML FV config (version 2)",
|
2006-09-12 01:16:22 +00:00
|
|
|
1, testCompareFVversion2, NULL) != 0)
|
2006-10-09 14:32:07 +00:00
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML Disk File config",
|
|
|
|
1, testCompareDiskFile, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML Disk Block config",
|
|
|
|
1, testCompareDiskBlock, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML Disk Driver blktap qcow config",
|
|
|
|
1, testCompareDiskDrvBlktapQcow, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML Disk Driver blktap raw config",
|
|
|
|
1, testCompareDiskDrvBlktapRaw, NULL) != 0)
|
|
|
|
ret = -1;
|
2006-08-24 15:05:19 +00:00
|
|
|
|
2006-11-10 11:13:01 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML Resized memory config",
|
|
|
|
1, testCompareResizedMemory, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2006-11-15 00:38:13 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML net routed",
|
|
|
|
1, testCompareNetRouted, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (virtTestRun("SEXPR-2-XML net bridged",
|
|
|
|
1, testCompareNetBridged, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2007-04-11 16:06:30 +00:00
|
|
|
if (virtTestRun("SEXPR-2-XML no source CDRom",
|
|
|
|
1, testCompareNoSourceCDRom, NULL) != 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2006-08-24 15:05:19 +00:00
|
|
|
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|
2007-03-15 07:43:16 +00:00
|
|
|
#else /* WITHOUT_XEN */
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "libvirt compiled without Xen support\n");
|
2007-03-16 14:55:51 +00:00
|
|
|
return(0);
|
2007-03-15 07:43:16 +00:00
|
|
|
}
|
|
|
|
#endif /* WITH_XEN */
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* c-indent-level: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 4
|
|
|
|
* End:
|
|
|
|
*/
|