Introduce one basic test that tests the simplest case:
logging into portal without any IQN.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/viriscsitest.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c
index 3bb3993196..a7287069ba 100644
--- a/tests/viriscsitest.c
+++ b/tests/viriscsitest.c
@@ -94,6 +94,16 @@ static void testIscsiadmCb(const char *const*args,
args[8] && STREQ(args[8], "nonpersistent") &&
args[9] == NULL) {
ignore_value(VIR_STRDUP(*output, iscsiadmSendtargetsOutput));
+ } else if (args[0] && STREQ(args[0], ISCSIADM) &&
+ args[1] && STREQ(args[1], "--mode") &&
+ args[2] && STREQ(args[2], "node") &&
+ args[3] && STREQ(args[3], "--portal") &&
+ args[4] && STREQ(args[4], "10.20.30.40:3260,1")
&&
+ args[5] && STREQ(args[5], "--targetname") &&
+ args[6] && STREQ(args[6],
"iqn.2004-06.example:example1:iscsi.test") &&
+ args[7] && STREQ(args[7], "--login") &&
+ args[8] == NULL) {
+ /* nada */
} else {
*status = -1;
}
@@ -175,6 +185,32 @@ testISCSIScanTargets(const void *data)
return ret;
}
+
+struct testConnectionInfoLogin {
+ const char *portal;
+ const char *initiatoriqn;
+ const char *target;
+};
+
+
+static int
+testISCSIConnectionLogin(const void *data)
+{
+ const struct testConnectionInfoLogin *info = data;
+ int ret = -1;
+
+ virCommandSetDryRun(NULL, testIscsiadmCb, NULL);
+
+ if (virISCSIConnectionLogin(info->portal, info->initiatoriqn, info->target)
< 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ virCommandSetDryRun(NULL, NULL, NULL);
+ return ret;
+}
+
+
static int
mymain(void)
{
@@ -213,6 +249,16 @@ mymain(void)
if (virTestRun("ISCSI scan targets", testISCSIScanTargets,
&infoTargets) < 0)
rv = -1;
+# define DO_LOGIN_TEST(portal, iqn, target) \
+ do { \
+ struct testConnectionInfoLogin info = {portal, iqn, target }; \
+ if (virTestRun("ISCSI login " portal, \
+ testISCSIConnectionLogin, &info) < 0) \
+ rv = -1; \
+ } while (0)
+
+ DO_LOGIN_TEST("10.20.30.40:3260,1", NULL,
"iqn.2004-06.example:example1:iscsi.test");
+
if (rv < 0)
return EXIT_FAILURE;
return EXIT_SUCCESS;
--
2.16.4