提交 8bacdde9 编写于 作者: J Ján Tomko

virshtest: refactor testCompareOutputLit

Use g_autofree and get rid of the cleanup label.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 994688e0
...@@ -60,26 +60,20 @@ static int ...@@ -60,26 +60,20 @@ static int
testCompareOutputLit(const char *expectData, testCompareOutputLit(const char *expectData,
const char *filter, const char *const argv[]) const char *filter, const char *const argv[])
{ {
int result = -1; g_autofree char *actualData = NULL;
char *actualData = NULL;
if (virTestCaptureProgramOutput(argv, &actualData, 4096) < 0) if (virTestCaptureProgramOutput(argv, &actualData, 4096) < 0)
goto cleanup; return -1;
if (filter && testFilterLine(actualData, filter) < 0) if (filter && testFilterLine(actualData, filter) < 0)
goto cleanup; return -1;
if (STRNEQ(expectData, actualData)) { if (STRNEQ(expectData, actualData)) {
virTestDifference(stderr, expectData, actualData); virTestDifference(stderr, expectData, actualData);
goto cleanup; return -1;
} }
result = 0; return 0;
cleanup:
VIR_FREE(actualData);
return result;
} }
# define VIRSH_DEFAULT abs_top_builddir "/tools/virsh", \ # define VIRSH_DEFAULT abs_top_builddir "/tools/virsh", \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册