The ScanTargets testing code declares some variables in the middle of main. Split it out into a separate function. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- tests/viriscsitest.c | 47 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index 76f0aa2946..e86d3970b6 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -311,26 +311,8 @@ testISCSIConnectionLogin(const void *data) static int -mymain(void) +testISCSIScanTargetsTests(void) { - int rv = 0; - -# define DO_SESSION_TEST(name, session) \ - do { \ - struct testSessionInfo info = {name, false, session}; \ - if (virTestRun("ISCSI get session test" name, \ - testISCSIGetSession, &info) < 0) \ - rv = -1; \ - info.output_version = true; \ - if (virTestRun("ISCSI get (non-flash) session test" name, \ - testISCSIGetSession, &info) < 0) \ - rv = -1; \ - } while (0) - - DO_SESSION_TEST("iqn.2004-06.example:example1:iscsi.test", "1"); - DO_SESSION_TEST("iqn.2009-04.example:example1:iscsi.seven", "7"); - DO_SESSION_TEST("iqn.2009-04.example:example1:iscsi.eight", NULL); - const char *targets[] = { "iqn.2004-06.example:example1:iscsi.test", "iqn.2005-05.example:example1:iscsi.hello", @@ -346,6 +328,33 @@ mymain(void) .nexpected = G_N_ELEMENTS(targets), }; if (virTestRun("ISCSI scan targets", testISCSIScanTargets, &infoTargets) < 0) + return -1; + return 0; +} + + +static int +mymain(void) +{ + int rv = 0; + +# define DO_SESSION_TEST(name, session) \ + do { \ + struct testSessionInfo info = {name, false, session}; \ + if (virTestRun("ISCSI get session test" name, \ + testISCSIGetSession, &info) < 0) \ + rv = -1; \ + info.output_version = true; \ + if (virTestRun("ISCSI get (non-flash) session test" name, \ + testISCSIGetSession, &info) < 0) \ + rv = -1; \ + } while (0) + + DO_SESSION_TEST("iqn.2004-06.example:example1:iscsi.test", "1"); + DO_SESSION_TEST("iqn.2009-04.example:example1:iscsi.seven", "7"); + DO_SESSION_TEST("iqn.2009-04.example:example1:iscsi.eight", NULL); + + if (testISCSIScanTargetsTests() < 0) rv = -1; # define DO_LOGIN_TEST(portal, iqn, target) \ -- 2.26.2