mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
testVshTableHeader: Cleanup
Remove unnecessary label and goto. This also fixes a bug where a failure to create the table would result in the test passing. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1fc3f05293
commit
f976f90465
@ -45,7 +45,8 @@ static int
|
|||||||
testVshTableHeader(const void *opaque G_GNUC_UNUSED)
|
testVshTableHeader(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *act = NULL;
|
g_autofree char *act = NULL;
|
||||||
|
g_autofree char *act2 = NULL;
|
||||||
const char *exp =
|
const char *exp =
|
||||||
" 1 fedora28 running\n"
|
" 1 fedora28 running\n"
|
||||||
" 2 rhel7.5 running\n";
|
" 2 rhel7.5 running\n";
|
||||||
@ -58,7 +59,7 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED)
|
|||||||
g_autoptr(vshTable) table = vshTableNew("Id", "Name", "State",
|
g_autoptr(vshTable) table = vshTableNew("Id", "Name", "State",
|
||||||
NULL); //to ask about return
|
NULL); //to ask about return
|
||||||
if (!table)
|
if (!table)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
vshTableRowAppend(table, "1", "fedora28", "running", NULL);
|
vshTableRowAppend(table, "1", "fedora28", "running", NULL);
|
||||||
vshTableRowAppend(table, "2", "rhel7.5", "running",
|
vshTableRowAppend(table, "2", "rhel7.5", "running",
|
||||||
@ -68,13 +69,10 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED)
|
|||||||
if (virTestCompareToString(exp, act) < 0)
|
if (virTestCompareToString(exp, act) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
VIR_FREE(act);
|
act2 = vshTablePrintToString(table, true);
|
||||||
act = vshTablePrintToString(table, true);
|
if (virTestCompareToString(exp2, act2) < 0)
|
||||||
if (virTestCompareToString(exp2, act) < 0)
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(act);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user