]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: iscsitest: split out testISCSIScanTargetsTests
authorJán Tomko <jtomko@redhat.com>
Tue, 28 Jul 2020 18:11:09 +0000 (20:11 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 25 Aug 2020 17:03:12 +0000 (19:03 +0200)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/viriscsitest.c

index 76f0aa29465f68a6eadb185eb5b0af3ec15b57fc..e86d3970b692e715dcbd623e54e8ff508539b0ee 100644 (file)
@@ -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) \