On 07/04/2018 05:23 AM, Michal Privoznik wrote: > Introduce one basic test that tests the simplest case: > logging into portal without any IQN. > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > 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 */ Hmm.. can we place a hold on that R-By - I missed this gem "nada" - why is that? If we have *output because we've sent the dryRun, then why not compare? John > } 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; > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list