TESTS: move the default url, lun and iscsi context into a structure

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2014-09-18 16:42:45 -07:00
parent 40de7d95a9
commit 9b768f7de9
177 changed files with 939 additions and 934 deletions

View File

@@ -36,53 +36,53 @@ test_preventallow_itnexus_loss(void)
logging(LOG_VERBOSE, "Test that IT-Nexus loss clears PREVENT MEDIUM REMOVAL");
logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1);
ret = preventallow(sd->iscsi_ctx, sd->iscsi_lun, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
ret = startstopunit(sd->iscsi_ctx, sd->iscsi_lun, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun,
ret = testunitready(sd->iscsi_ctx, sd->iscsi_lun,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Disconnect from the target.");
iscsi_destroy_context(iscsic);
iscsi_destroy_context(sd->iscsi_ctx);
logging(LOG_VERBOSE, "Reconnect to target");
iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun);
if (iscsic == NULL) {
sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
if (sd->iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target");
return;
}
logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
ret = startstopunit(sd->iscsi_ctx, sd->iscsi_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready(iscsic, tgt_lun,
ret = testunitready(sd->iscsi_ctx, sd->iscsi_lun,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
ret = startstopunit(sd->iscsi_ctx, sd->iscsi_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0);
ret = preventallow(sd->iscsi_ctx, sd->iscsi_lun, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
ret = startstopunit(sd->iscsi_ctx, sd->iscsi_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);