From aeb59ff576c71e6f5ed2ee73e1ac15de63f56633 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Tue, 28 Jul 2020 20:11:09 +0200 Subject: [PATCH] tests: iscsitest: split out testISCSIScanTargetsTests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Michal Privoznik --- tests/viriscsitest.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index 76f0aa2946..e86d3970b6 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -310,6 +310,29 @@ testISCSIConnectionLogin(const void *data) } +static int +testISCSIScanTargetsTests(void) +{ + const char *targets[] = { + "iqn.2004-06.example:example1:iscsi.test", + "iqn.2005-05.example:example1:iscsi.hello", + "iqn.2006-04.example:example1:iscsi.world", + "iqn.2007-04.example:example1:iscsi.foo", + "iqn.2008-04.example:example1:iscsi.bar", + "iqn.2009-04.example:example1:iscsi.seven" + }; + struct testScanTargetsInfo infoTargets = { + .fake_cmd_output = "iscsiadm_sendtargets", + .portal = "10.20.30.40:3260,1", + .expected_targets = targets, + .nexpected = G_N_ELEMENTS(targets), + }; + if (virTestRun("ISCSI scan targets", testISCSIScanTargets, &infoTargets) < 0) + return -1; + return 0; +} + + static int mymain(void) { @@ -331,21 +354,7 @@ mymain(void) 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", - "iqn.2006-04.example:example1:iscsi.world", - "iqn.2007-04.example:example1:iscsi.foo", - "iqn.2008-04.example:example1:iscsi.bar", - "iqn.2009-04.example:example1:iscsi.seven" - }; - struct testScanTargetsInfo infoTargets = { - .fake_cmd_output = "iscsiadm_sendtargets", - .portal = "10.20.30.40:3260,1", - .expected_targets = targets, - .nexpected = G_N_ELEMENTS(targets), - }; - if (virTestRun("ISCSI scan targets", testISCSIScanTargets, &infoTargets) < 0) + if (testISCSIScanTargetsTests() < 0) rv = -1; # define DO_LOGIN_TEST(portal, iqn, target) \ -- 2.47.2