提交 0104c431 编写于 作者: P Pavel Hrdina

tests: add helper for VIR_TEST_REGENERATE_OUTPUT flag

When this flag is specified, some of the expected output files will be
regenerated with the actual output data.  Use helper function like for
other flags.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 4100aecd
......@@ -67,6 +67,7 @@ VIR_LOG_INIT("tests.testutils");
static unsigned int testDebug = -1;
static unsigned int testVerbose = -1;
static unsigned int testExpensive = -1;
static unsigned int testRegenerate = -1;
#ifdef TEST_OOM
static unsigned int testOOM;
......@@ -598,9 +599,8 @@ virtTestCompareToFile(const char *strcontent,
int ret = -1;
char *filecontent = NULL;
char *fixedcontent = NULL;
bool regenerate = !!virTestGetFlag("VIR_TEST_REGENERATE_OUTPUT");
if (virtTestLoadFile(filename, &filecontent) < 0 && !regenerate)
if (virtTestLoadFile(filename, &filecontent) < 0 && !virTestGetRegenerate())
goto failure;
if (filecontent &&
......@@ -612,7 +612,7 @@ virtTestCompareToFile(const char *strcontent,
if (STRNEQ_NULLABLE(fixedcontent ? fixedcontent : strcontent,
filecontent)) {
if (regenerate) {
if (virTestGetRegenerate()) {
if (virFileWriteStr(filename, strcontent, 0666) < 0)
goto failure;
goto out;
......@@ -716,6 +716,14 @@ virTestGetExpensive(void)
return testExpensive;
}
unsigned int
virTestGetRegenerate(void)
{
if (testRegenerate == -1)
testRegenerate = virTestGetFlag("VIR_TEST_REGENERATE_OUTPUT");
return testRegenerate;
}
int virtTestMain(int argc,
char **argv,
int (*func)(void))
......
......@@ -77,6 +77,7 @@ int virtTestCompareToFile(const char *strcontent,
unsigned int virTestGetDebug(void);
unsigned int virTestGetVerbose(void);
unsigned int virTestGetExpensive(void);
unsigned int virTestGetRegenerate(void);
# define VIR_TEST_DEBUG(...) \
do { \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册