mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
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.
This commit is contained in:
parent
259a16d514
commit
8b3a0b28ba
@ -777,6 +777,8 @@ int virTestDifferenceBin(FILE *stream,
|
|||||||
/*
|
/*
|
||||||
* @param strcontent: String input content
|
* @param strcontent: String input content
|
||||||
* @param filename: File to compare strcontent against
|
* @param filename: File to compare strcontent against
|
||||||
|
*
|
||||||
|
* If @strcontent is NULL, it's treated as an empty string.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virTestCompareToFile(const char *strcontent,
|
virTestCompareToFile(const char *strcontent,
|
||||||
@ -787,6 +789,9 @@ virTestCompareToFile(const char *strcontent,
|
|||||||
char *fixedcontent = NULL;
|
char *fixedcontent = NULL;
|
||||||
const char *cmpcontent = strcontent;
|
const char *cmpcontent = strcontent;
|
||||||
|
|
||||||
|
if (!cmpcontent)
|
||||||
|
cmpcontent = "";
|
||||||
|
|
||||||
if (virTestLoadFile(filename, &filecontent) < 0 && !virTestGetRegenerate())
|
if (virTestLoadFile(filename, &filecontent) < 0 && !virTestGetRegenerate())
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user