提交 8b3a0b28 编写于 作者: P Peter Krempa

tests: utils: Allow NULL strings to be equal to empty file in virTestCompareToFile

Treat an NULL string equivalent to an empty string in
virTestCompareToFile so that callers don't need to add additional logic
in case when a test produces no output.
上级 259a16d5
......@@ -777,6 +777,8 @@ int virTestDifferenceBin(FILE *stream,
/*
* @param strcontent: String input content
* @param filename: File to compare strcontent against
*
* If @strcontent is NULL, it's treated as an empty string.
*/
int
virTestCompareToFile(const char *strcontent,
......@@ -787,6 +789,9 @@ virTestCompareToFile(const char *strcontent,
char *fixedcontent = NULL;
const char *cmpcontent = strcontent;
if (!cmpcontent)
cmpcontent = "";
if (virTestLoadFile(filename, &filecontent) < 0 && !virTestGetRegenerate())
goto failure;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册