testutils: Explicitly name virTestCompare*() arguments

Currently, some arguments are called strcontent and strsrc, or
content and src or some other combination. This makes it
impossible to see at the first glance what argument is supposed
to represent 'expected' value and which one represents 'actual'
value. Rename the arguments to make it obvious.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2019-02-19 18:15:23 +01:00
parent 9de317d0d1
commit 740aeb349f
2 changed files with 18 additions and 26 deletions

View File

@ -767,19 +767,19 @@ int virTestDifferenceBin(FILE *stream,
} }
/* /*
* @param strcontent: String input content * @param actual: String input content
* @param filename: File to compare strcontent against * @param filename: File to compare @actual against
* *
* If @strcontent is NULL, it's treated as an empty string. * If @actual is NULL, it's treated as an empty string.
*/ */
int int
virTestCompareToFile(const char *strcontent, virTestCompareToFile(const char *actual,
const char *filename) const char *filename)
{ {
int ret = -1; int ret = -1;
char *filecontent = NULL; char *filecontent = NULL;
char *fixedcontent = NULL; char *fixedcontent = NULL;
const char *cmpcontent = strcontent; const char *cmpcontent = actual;
if (!cmpcontent) if (!cmpcontent)
cmpcontent = ""; cmpcontent = "";
@ -814,36 +814,28 @@ virTestCompareToFile(const char *strcontent,
return ret; return ret;
} }
/*
* @param content: Input content
* @param src: Source to compare @content against
*/
int int
virTestCompareToULL(unsigned long long content, virTestCompareToULL(unsigned long long expect,
unsigned long long src) unsigned long long actual)
{ {
VIR_AUTOFREE(char *) expectStr = NULL; VIR_AUTOFREE(char *) expectStr = NULL;
VIR_AUTOFREE(char *) actualStr = NULL; VIR_AUTOFREE(char *) actualStr = NULL;
if (virAsprintf(&expectStr, "%llu", content) < 0) if (virAsprintf(&expectStr, "%llu", expect) < 0)
return -1; return -1;
if (virAsprintf(&actualStr, "%llu", src) < 0) if (virAsprintf(&actualStr, "%llu", actual) < 0)
return -1; return -1;
return virTestCompareToString(expectStr, actualStr); return virTestCompareToString(expectStr, actualStr);
} }
/*
* @param strcontent: String input content
* @param strsrc: String source to compare strcontent against
*/
int int
virTestCompareToString(const char *strcontent, virTestCompareToString(const char *expect,
const char *strsrc) const char *actual)
{ {
if (STRNEQ_NULLABLE(strcontent, strsrc)) { if (STRNEQ_NULLABLE(expect, actual)) {
virTestDifference(stderr, strcontent, strsrc); virTestDifference(stderr, expect, actual);
return -1; return -1;
} }

View File

@ -76,12 +76,12 @@ int virTestDifferenceBin(FILE *stream,
const char *expect, const char *expect,
const char *actual, const char *actual,
size_t length); size_t length);
int virTestCompareToFile(const char *strcontent, int virTestCompareToFile(const char *actual,
const char *filename); const char *filename);
int virTestCompareToString(const char *strcontent, int virTestCompareToString(const char *expect,
const char *strsrc); const char *actual);
int virTestCompareToULL(unsigned long long content, int virTestCompareToULL(unsigned long long expect,
unsigned long long src); unsigned long long actual);
unsigned int virTestGetDebug(void); unsigned int virTestGetDebug(void);
unsigned int virTestGetVerbose(void); unsigned int virTestGetVerbose(void);