mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
tests: Run test-wrap-argv with REGENERATE_OUTPUT
To get properly wrapped output
This commit is contained in:
parent
2aed051d0d
commit
3e9033f78a
@ -433,6 +433,32 @@ virtTestCaptureProgramOutput(const char *const argv[] ATTRIBUTE_UNUSED,
|
||||
}
|
||||
#endif /* !WIN32 */
|
||||
|
||||
static int
|
||||
virTestRewrapFile(const char *filename)
|
||||
{
|
||||
int ret = -1;
|
||||
char *outbuf = NULL;
|
||||
char *script = NULL;
|
||||
virCommandPtr cmd = NULL;
|
||||
|
||||
if (virAsprintf(&script, "%s/test-wrap-argv.pl", abs_srcdir) < 0)
|
||||
goto cleanup;
|
||||
|
||||
cmd = virCommandNewArgList(script, filename, NULL);
|
||||
virCommandSetOutputBuffer(cmd, &outbuf);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virFileWriteStr(filename, outbuf, 0666) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(script);
|
||||
virCommandFree(cmd);
|
||||
VIR_FREE(outbuf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stream: output stream to write differences to
|
||||
@ -470,17 +496,15 @@ virtTestDifferenceFullInternal(FILE *stream,
|
||||
actualEnd = actual + (strlen(actual)-1);
|
||||
|
||||
if (expectName && regenerate && (virTestGetRegenerate() > 0)) {
|
||||
char *regencontent;
|
||||
|
||||
/* Try to properly indent qemu argv files */
|
||||
if (!(regencontent = virStringReplace(actual, " -", " \\\n-")))
|
||||
return -1;
|
||||
|
||||
if (virFileWriteStr(expectName, regencontent, 0666) < 0) {
|
||||
VIR_FREE(regencontent);
|
||||
if (virFileWriteStr(expectName, actual, 0666) < 0) {
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virTestRewrapFile(expectName) < 0) {
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
VIR_FREE(regencontent);
|
||||
}
|
||||
|
||||
if (!virTestGetDebug())
|
||||
|
Loading…
Reference in New Issue
Block a user