@@ -598,6 +598,7 @@ virtTestCompareToFile(const char *strcontent,
int ret = -1;
char *filecontent = NULL;
char *fixedcontent = NULL;
+ char *regencontent = NULL;
bool regenerate = !!virTestGetFlag("VIR_TEST_REGENERATE_OUTPUT");
if (virtTestLoadFile(filename, &filecontent) < 0 && !regenerate)
@@ -613,7 +614,10 @@ virtTestCompareToFile(const char *strcontent,
if (STRNEQ_NULLABLE(fixedcontent ? fixedcontent : strcontent,
filecontent)) {
if (regenerate) {
- if (virFileWriteStr(filename, strcontent, 0666) < 0)
+ if (!(regencontent = virStringReplace(strcontent, " -", " \\\n-")))
+ goto failure;
+
+ if (virFileWriteStr(filename, regencontent, 0666) < 0)
goto failure;
goto out;
}
@@ -626,6 +630,7 @@ virtTestCompareToFile(const char *strcontent,
failure:
VIR_FREE(fixedcontent);
VIR_FREE(filecontent);
+ VIR_FREE(regencontent);
return ret;
}