bhyvexml2argv: Add loader argv tests.

This commit is contained in:
Conrad Meyer 2014-11-08 11:48:31 -05:00 committed by Michal Privoznik
parent 17722c169c
commit f2ce9d3645
8 changed files with 61 additions and 6 deletions

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/cdrom.iso bhyve

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve

View File

@ -0,0 +1 @@
/usr/sbin/bhyveload -m 214 -d /tmp/freebsd.img bhyve

View File

@ -15,14 +15,16 @@
static bhyveConn driver; static bhyveConn driver;
static int testCompareXMLToArgvFiles(const char *xml, static int testCompareXMLToArgvFiles(const char *xml,
const char *cmdline) const char *cmdline,
const char *ldcmdline,
const char *dmcmdline)
{ {
char *expectargv = NULL; char *expectargv = NULL, *expectld = NULL, *expectdm = NULL;
int len; int len;
char *actualargv = NULL; char *actualargv = NULL, *actualld = NULL, *actualdm = NULL;
virDomainDefPtr vmdef = NULL; virDomainDefPtr vmdef = NULL;
virDomainObj vm; virDomainObj vm;
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL, ldcmd = NULL;
virConnectPtr conn; virConnectPtr conn;
int ret = -1; int ret = -1;
@ -42,6 +44,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (!(actualargv = virCommandToString(cmd))) if (!(actualargv = virCommandToString(cmd)))
goto out; goto out;
if (!(ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, "<device.map>",
&actualdm)))
goto out;
if (actualdm != NULL)
virTrimSpaces(actualdm, NULL);
if (!(actualld = virCommandToString(ldcmd)))
goto out;
len = virtTestLoadFile(cmdline, &expectargv); len = virtTestLoadFile(cmdline, &expectargv);
if (len < 0) if (len < 0)
goto out; goto out;
@ -49,17 +61,49 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (len && expectargv[len - 1] == '\n') if (len && expectargv[len - 1] == '\n')
expectargv[len - 1] = '\0'; expectargv[len - 1] = '\0';
len = virtTestLoadFile(ldcmdline, &expectld);
if (len < 0)
goto out;
if (len && expectld[len - 1] == '\n')
expectld[len - 1] = '\0';
len = virFileReadAllQuiet(dmcmdline, 1000, &expectdm);
if (len < 0) {
if (actualdm != NULL) {
virtTestDifference(stderr, "", actualdm);
goto out;
}
} else if (len && expectdm[len - 1] == '\n') {
expectdm[len - 1] = '\0';
}
if (STRNEQ(expectargv, actualargv)) { if (STRNEQ(expectargv, actualargv)) {
virtTestDifference(stderr, expectargv, actualargv); virtTestDifference(stderr, expectargv, actualargv);
goto out; goto out;
} }
if (STRNEQ(expectld, actualld)) {
virtTestDifference(stderr, expectld, actualld);
goto out;
}
if (expectdm && STRNEQ(expectdm, actualdm)) {
virtTestDifference(stderr, expectdm, actualdm);
goto out;
}
ret = 0; ret = 0;
out: out:
VIR_FREE(expectargv); VIR_FREE(expectargv);
VIR_FREE(expectld);
VIR_FREE(expectdm);
VIR_FREE(actualargv); VIR_FREE(actualargv);
VIR_FREE(actualld);
VIR_FREE(actualdm);
virCommandFree(cmd); virCommandFree(cmd);
virCommandFree(ldcmd);
virDomainDefFree(vmdef); virDomainDefFree(vmdef);
return ret; return ret;
} }
@ -70,15 +114,19 @@ testCompareXMLToArgvHelper(const void *data)
int ret = -1; int ret = -1;
const char *name = data; const char *name = data;
char *xml = NULL; char *xml = NULL;
char *args = NULL; char *args = NULL, *ldargs = NULL, *dmargs = NULL;
if (virAsprintf(&xml, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.xml", if (virAsprintf(&xml, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.xml",
abs_srcdir, name) < 0 || abs_srcdir, name) < 0 ||
virAsprintf(&args, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.args", virAsprintf(&args, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.args",
abs_srcdir, name) < 0 ||
virAsprintf(&ldargs, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.ldargs",
abs_srcdir, name) < 0 ||
virAsprintf(&dmargs, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.devmap",
abs_srcdir, name) < 0) abs_srcdir, name) < 0)
goto cleanup; goto cleanup;
ret = testCompareXMLToArgvFiles(xml, args); ret = testCompareXMLToArgvFiles(xml, args, ldargs, dmargs);
cleanup: cleanup:
VIR_FREE(xml); VIR_FREE(xml);