mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 01:04:59 +00:00
94 lines
2.2 KiB
C
94 lines
2.2 KiB
C
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "xml.h"
|
|
#include "xend_internal.h"
|
|
#include "testutils.h"
|
|
#include "internal.h"
|
|
|
|
static char *progname;
|
|
|
|
#define MAX_FILE 4096
|
|
|
|
static int testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) {
|
|
char xmlData[MAX_FILE];
|
|
char sexprData[MAX_FILE];
|
|
char *gotxml = NULL;
|
|
char *xmlPtr = &(xmlData[0]);
|
|
char *sexprPtr = &(sexprData[0]);
|
|
|
|
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
|
|
return -1;
|
|
|
|
if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
|
|
return -1;
|
|
|
|
if (!(gotxml = xend_parse_domain_sexp(NULL, sexprData, xendConfigVersion)))
|
|
return -1;
|
|
|
|
if (getenv("DEBUG_TESTS")) {
|
|
printf("In %d '%s'\n", strlen(xmlData), xmlData);
|
|
printf("Out %d '%s'\n", strlen(gotxml), gotxml);
|
|
}
|
|
if (strcmp(xmlData, gotxml))
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int testComparePVversion1(void *data ATTRIBUTE_UNUSED) {
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
|
|
"sexpr2xmldata/sexpr2xml-pv.sexpr",
|
|
1);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
|
|
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-v2.xml",
|
|
"sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
|
|
2);
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
int ret = 0;
|
|
|
|
progname = argv[0];
|
|
|
|
if (argc > 1) {
|
|
fprintf(stderr, "Usage: %s\n", progname);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
if (virtTestRun("SEXPR-2-XML PV config (version 1)",
|
|
1, testComparePVversion1, NULL) != 0)
|
|
ret = -1;
|
|
|
|
if (virtTestRun("SEXPR-2-XML FV config (version 1)",
|
|
1, testCompareFVversion1, NULL) != 0)
|
|
ret = -1;
|
|
|
|
if (virtTestRun("SEXPR-2-XML PV config (version 2)",
|
|
1, testComparePVversion2, NULL) != 0)
|
|
ret = -1;
|
|
|
|
if (virtTestRun("SEXPR-2-XML FV config (version 2)",
|
|
1, testCompareFVversion2, NULL) != 0)
|
|
ret = -1;
|
|
|
|
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
}
|