mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
nodedevmdevctltest: Use internal linewrapping and variable command path stripping
Remove `nodedevCompareToFile` which was stripping the path to mdevctl since it's no longer needed if we use the new features of virCommandSetDryRun. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
2dcbdc7f4b
commit
d146b193e2
@ -1,2 +1,5 @@
|
||||
$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin \
|
||||
mdevctl \
|
||||
define \
|
||||
-p 0000:00:02.0 \
|
||||
--jsonfile /dev/stdin \
|
||||
--uuid=d069d019-36ea-4111-8f0a-8c9a70e21366
|
||||
|
@ -1,2 +1,5 @@
|
||||
$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin \
|
||||
mdevctl \
|
||||
start \
|
||||
-p 0000:00:02.0 \
|
||||
--jsonfile /dev/stdin \
|
||||
--uuid=d069d019-36ea-4111-8f0a-8c9a70e21366
|
||||
|
@ -1 +1,4 @@
|
||||
$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin
|
||||
mdevctl \
|
||||
define \
|
||||
-p 0000:00:02.0 \
|
||||
--jsonfile /dev/stdin
|
||||
|
@ -1 +1,4 @@
|
||||
$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin
|
||||
mdevctl \
|
||||
start \
|
||||
-p 0000:00:02.0 \
|
||||
--jsonfile /dev/stdin
|
||||
|
@ -1 +1,4 @@
|
||||
$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin
|
||||
mdevctl \
|
||||
define \
|
||||
-p 0000:00:02.0 \
|
||||
--jsonfile /dev/stdin
|
||||
|
@ -1 +1,4 @@
|
||||
$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin
|
||||
mdevctl \
|
||||
start \
|
||||
-p 0000:00:02.0 \
|
||||
--jsonfile /dev/stdin
|
||||
|
@ -1 +1,3 @@
|
||||
$MDEVCTL_BINARY$ start -u 8a05ad83-3472-497d-8631-8142f31460e8
|
||||
mdevctl \
|
||||
start \
|
||||
-u 8a05ad83-3472-497d-8631-8142f31460e8
|
||||
|
@ -1 +1,4 @@
|
||||
$MDEVCTL_BINARY$ list --dumpjson --defined
|
||||
mdevctl \
|
||||
list \
|
||||
--dumpjson \
|
||||
--defined
|
||||
|
@ -1 +1,3 @@
|
||||
$MDEVCTL_BINARY$ stop -u e2451f73-c95b-4124-b900-e008af37c576
|
||||
mdevctl \
|
||||
stop \
|
||||
-u e2451f73-c95b-4124-b900-e008af37c576
|
||||
|
@ -1 +1,3 @@
|
||||
$MDEVCTL_BINARY$ undefine -u d76a6b78-45ed-4149-a325-005f9abc5281
|
||||
mdevctl \
|
||||
undefine \
|
||||
-u d76a6b78-45ed-4149-a325-005f9abc5281
|
||||
|
@ -40,21 +40,6 @@ testCommandDryRunCallback(const char *const*args G_GNUC_UNUSED,
|
||||
*stdinbuf = g_strdup(input);
|
||||
}
|
||||
|
||||
/* We don't want the result of the test to depend on the path to the mdevctl
|
||||
* binary on the developer's machine, so replace the path to mdevctl with a
|
||||
* placeholder string before comparing to the expected output */
|
||||
static int
|
||||
nodedevCompareToFile(const char *actual,
|
||||
const char *filename)
|
||||
{
|
||||
g_autofree char *replacedCmdline = NULL;
|
||||
|
||||
replacedCmdline = virStringReplace(actual, MDEVCTL, "$MDEVCTL_BINARY$");
|
||||
|
||||
return virTestCompareToFile(replacedCmdline, filename);
|
||||
}
|
||||
|
||||
|
||||
typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef *, char **, char **);
|
||||
|
||||
|
||||
@ -87,14 +72,14 @@ testMdevctlStartOrDefine(const char *virt_type,
|
||||
if (!cmd)
|
||||
goto cleanup;
|
||||
|
||||
virCommandSetDryRun(dryRunToken, &buf, false, false, testCommandDryRunCallback, &stdinbuf);
|
||||
virCommandSetDryRun(dryRunToken, &buf, true, true, testCommandDryRunCallback, &stdinbuf);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(actualCmdline = virBufferCurrentContent(&buf)))
|
||||
goto cleanup;
|
||||
|
||||
if (nodedevCompareToFile(actualCmdline, cmdfile) < 0)
|
||||
if (virTestCompareToFileFull(actualCmdline, cmdfile, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virTestCompareToFile(stdinbuf, jsonfile) < 0)
|
||||
@ -159,14 +144,14 @@ testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, const char
|
||||
if (!cmd)
|
||||
goto cleanup;
|
||||
|
||||
virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL);
|
||||
virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(actualCmdline = virBufferCurrentContent(&buf)))
|
||||
goto cleanup;
|
||||
|
||||
if (nodedevCompareToFile(actualCmdline, outfile) < 0)
|
||||
if (virTestCompareToFileFull(actualCmdline, outfile, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
@ -221,14 +206,14 @@ testMdevctlListDefined(const void *data G_GNUC_UNUSED)
|
||||
if (!cmd)
|
||||
goto cleanup;
|
||||
|
||||
virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL);
|
||||
virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(actualCmdline = virBufferCurrentContent(&buf)))
|
||||
goto cleanup;
|
||||
|
||||
if (nodedevCompareToFile(actualCmdline, cmdlinefile) < 0)
|
||||
if (virTestCompareToFileFull(actualCmdline, cmdlinefile, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
@ -270,7 +255,7 @@ testMdevctlParse(const void *data)
|
||||
virBufferAddStr(&xmloutbuf, devxml);
|
||||
}
|
||||
|
||||
if (nodedevCompareToFile(virBufferCurrentContent(&xmloutbuf), xmloutfile) < 0)
|
||||
if (virTestCompareToFileFull(virBufferCurrentContent(&xmloutbuf), xmloutfile, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user