mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-26 15:14:42 +00:00
tests.testutils: use VIR_TEST_REGENERATE_OUTPUT for virTestDifferenceFull
This patch enable regeneration of expected output file for virTestDifferenceFull. It also introduces new virTestDifferenceFullNoRegenerate function for special cases, where we don't want to regenerate output. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
0104c43195
commit
781d70c027
@ -188,9 +188,11 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(actual, expect)) {
|
if (STRNEQ(actual, expect)) {
|
||||||
virtTestDifferenceFull(stderr,
|
/* For status test we don't want to regenerate output to not
|
||||||
expect, data->outActiveName,
|
* add the status data.*/
|
||||||
actual, data->inName);
|
virtTestDifferenceFullNoRegenerate(stderr,
|
||||||
|
expect, data->outActiveName,
|
||||||
|
actual, data->inName);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,16 +440,19 @@ virtTestCaptureProgramOutput(const char *const argv[] ATTRIBUTE_UNUSED,
|
|||||||
* @param expectName: name designator of the expected text
|
* @param expectName: name designator of the expected text
|
||||||
* @param actual: actual output text
|
* @param actual: actual output text
|
||||||
* @param actualName: name designator of the actual text
|
* @param actualName: name designator of the actual text
|
||||||
|
* @param regenerate: enable or disable regenerate functionality
|
||||||
*
|
*
|
||||||
* Display expected and actual output text, trimmed to first and last
|
* Display expected and actual output text, trimmed to first and last
|
||||||
* characters at which differences occur. Displays names of the text strings if
|
* characters at which differences occur. Displays names of the text strings if
|
||||||
* non-NULL.
|
* non-NULL.
|
||||||
*/
|
*/
|
||||||
int virtTestDifferenceFull(FILE *stream,
|
static int
|
||||||
const char *expect,
|
virtTestDifferenceFullInternal(FILE *stream,
|
||||||
const char *expectName,
|
const char *expect,
|
||||||
const char *actual,
|
const char *expectName,
|
||||||
const char *actualName)
|
const char *actual,
|
||||||
|
const char *actualName,
|
||||||
|
bool regenerate)
|
||||||
{
|
{
|
||||||
const char *expectStart;
|
const char *expectStart;
|
||||||
const char *expectEnd;
|
const char *expectEnd;
|
||||||
@ -466,6 +469,12 @@ int virtTestDifferenceFull(FILE *stream,
|
|||||||
actualStart = actual;
|
actualStart = actual;
|
||||||
actualEnd = actual + (strlen(actual)-1);
|
actualEnd = actual + (strlen(actual)-1);
|
||||||
|
|
||||||
|
if (regenerate && virTestGetRegenerate() > 0) {
|
||||||
|
if (expectName && actual &&
|
||||||
|
virFileWriteStr(expectName, actual, 0666) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!virTestGetDebug())
|
if (!virTestGetDebug())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -508,6 +517,52 @@ int virtTestDifferenceFull(FILE *stream,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stream: output stream to write differences to
|
||||||
|
* @param expect: expected output text
|
||||||
|
* @param expectName: name designator of the expected text
|
||||||
|
* @param actual: actual output text
|
||||||
|
* @param actualName: name designator of the actual text
|
||||||
|
*
|
||||||
|
* Display expected and actual output text, trimmed to first and last
|
||||||
|
* characters at which differences occur. Displays names of the text strings if
|
||||||
|
* non-NULL. If VIR_TEST_REGENERATE_OUTPUT is used, this function will
|
||||||
|
* regenerate the expected file.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virtTestDifferenceFull(FILE *stream,
|
||||||
|
const char *expect,
|
||||||
|
const char *expectName,
|
||||||
|
const char *actual,
|
||||||
|
const char *actualName)
|
||||||
|
{
|
||||||
|
return virtTestDifferenceFullInternal(stream, expect, expectName,
|
||||||
|
actual, actualName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stream: output stream to write differences to
|
||||||
|
* @param expect: expected output text
|
||||||
|
* @param expectName: name designator of the expected text
|
||||||
|
* @param actual: actual output text
|
||||||
|
* @param actualName: name designator of the actual text
|
||||||
|
*
|
||||||
|
* Display expected and actual output text, trimmed to first and last
|
||||||
|
* characters at which differences occur. Displays names of the text strings if
|
||||||
|
* non-NULL. If VIR_TEST_REGENERATE_OUTPUT is used, this function will not
|
||||||
|
* regenerate the expected file.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virtTestDifferenceFullNoRegenerate(FILE *stream,
|
||||||
|
const char *expect,
|
||||||
|
const char *expectName,
|
||||||
|
const char *actual,
|
||||||
|
const char *actualName)
|
||||||
|
{
|
||||||
|
return virtTestDifferenceFullInternal(stream, expect, expectName,
|
||||||
|
actual, actualName, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stream: output stream to write differences to
|
* @param stream: output stream to write differences to
|
||||||
* @param expect: expected output text
|
* @param expect: expected output text
|
||||||
@ -516,11 +571,14 @@ int virtTestDifferenceFull(FILE *stream,
|
|||||||
* Display expected and actual output text, trimmed to
|
* Display expected and actual output text, trimmed to
|
||||||
* first and last characters at which differences occur
|
* first and last characters at which differences occur
|
||||||
*/
|
*/
|
||||||
int virtTestDifference(FILE *stream,
|
int
|
||||||
const char *expect,
|
virtTestDifference(FILE *stream,
|
||||||
const char *actual)
|
const char *expect,
|
||||||
|
const char *actual)
|
||||||
{
|
{
|
||||||
return virtTestDifferenceFull(stream, expect, NULL, actual, NULL);
|
return virtTestDifferenceFullNoRegenerate(stream,
|
||||||
|
expect, NULL,
|
||||||
|
actual, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,11 @@ int virtTestDifferenceFull(FILE *stream,
|
|||||||
const char *expectName,
|
const char *expectName,
|
||||||
const char *actual,
|
const char *actual,
|
||||||
const char *actualName);
|
const char *actualName);
|
||||||
|
int virtTestDifferenceFullNoRegenerate(FILE *stream,
|
||||||
|
const char *expect,
|
||||||
|
const char *expectName,
|
||||||
|
const char *actual,
|
||||||
|
const char *actualName);
|
||||||
int virtTestDifferenceBin(FILE *stream,
|
int virtTestDifferenceBin(FILE *stream,
|
||||||
const char *expect,
|
const char *expect,
|
||||||
const char *actual,
|
const char *actual,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user