TESTS: change the function signatures for the helpers

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2014-09-18 18:19:04 -07:00
parent 9b768f7de9
commit 072291c852
169 changed files with 1071 additions and 1030 deletions
+50 -27
View File
@@ -25,8 +25,7 @@
static void
verify_persistent_reserve_access(struct iscsi_context *iscsi1, int lun1,
struct iscsi_context *iscsi2, int lun2,
verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd2,
const enum scsi_persistent_out_type pr_type,
int reg_i2_can_read,
int reg_i2_can_write,
@@ -44,26 +43,26 @@ verify_persistent_reserve_access(struct iscsi_context *iscsi1, int lun1,
scsi_pr_type_str(pr_type));
/* send TURs to clear possible check conditions */
(void) testunitready_clear_ua(iscsi1, lun1);
(void) testunitready_clear_ua(iscsi2, lun2);
(void) testunitready_clear_ua(sd1);
(void) testunitready_clear_ua(sd2);
/* register our reservation key with the target */
ret = prout_register_and_ignore(iscsi1, lun1, key);
ret = prout_register_and_ignore(sd1, key);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
return;
}
CU_ASSERT_EQUAL(0, ret);
ret = prout_register_and_ignore(iscsi2, lun2, key2);
ret = prout_register_and_ignore(sd2, key2);
CU_ASSERT_EQUAL(0, ret);
/* reserve the target through initiator 1 */
ret = prout_reserve(iscsi1, lun1, key, pr_type);
ret = prout_reserve(sd1, key, pr_type);
CU_ASSERT_EQUAL(0, ret);
/* verify target reservation */
ret = prin_verify_reserved_as(iscsi1, lun1,
ret = prin_verify_reserved_as(sd1,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
CU_ASSERT_EQUAL(0, ret);
@@ -72,58 +71,62 @@ verify_persistent_reserve_access(struct iscsi_context *iscsi1, int lun1,
CU_ASSERT_PTR_NOT_NULL(read_write_buf);
/* make sure init1 can read */
ret = verify_read_works(iscsi1, lun1, read_write_buf);
ret = verify_read_works(sd1, read_write_buf);
CU_ASSERT_EQUAL(0, ret);
/* make sure init1 can write */
ret = verify_write_works(iscsi1, lun1, read_write_buf);
ret = verify_write_works(sd1, read_write_buf);
CU_ASSERT_EQUAL(0, ret);
/* verify registered init2 read access */
if (reg_i2_can_read)
ret = verify_read_works(iscsi2, lun2, read_write_buf);
ret = verify_read_works(sd2, read_write_buf);
else
ret = verify_read_fails(iscsi2, lun2, read_write_buf);
ret = verify_read_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret);
/* verify registered init2 write access */
if (reg_i2_can_write)
ret = verify_write_works(iscsi2, lun2, read_write_buf);
ret = verify_write_works(sd2, read_write_buf);
else
ret = verify_write_fails(iscsi2, lun2, read_write_buf);
ret = verify_write_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret);
/* unregister init2 */
ret = prout_register_key(iscsi2, lun2, 0, key);
ret = prout_register_key(sd2, 0, key);
CU_ASSERT_EQUAL(0, ret);
/* verify unregistered init2 read access */
if (unreg_i2_can_read)
ret = verify_read_works(iscsi2, lun2, read_write_buf);
ret = verify_read_works(sd2, read_write_buf);
else
ret = verify_read_fails(iscsi2, lun2, read_write_buf);
ret = verify_read_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret);
/* verify unregistered init2 write access */
if (unreg_i2_can_write)
ret = verify_write_works(iscsi2, lun2, read_write_buf);
ret = verify_write_works(sd2, read_write_buf);
else
ret = verify_write_fails(iscsi2, lun2, read_write_buf);
ret = verify_write_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret);
/* release our reservation */
ret = prout_release(iscsi1, lun1, key, pr_type);
ret = prout_release(sd1, key, pr_type);
CU_ASSERT_EQUAL(0, ret);
/* remove our key from the target */
ret = prout_register_key(iscsi1, lun1, 0, key);
ret = prout_register_key(sd1, 0, key);
CU_ASSERT_EQUAL(0, ret);
}
void
test_prout_reserve_access_ea(void)
{
verify_persistent_reserve_access(sd->iscsi_ctx, sd->iscsi_lun, iscsic2, tgt_lun2,
struct scsi_device sd2;
sd2.iscsi_ctx = iscsic2;
sd2.iscsi_lun = tgt_lun2;
verify_persistent_reserve_access(sd, &sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
0, 0, 0, 0);
}
@@ -131,7 +134,11 @@ test_prout_reserve_access_ea(void)
void
test_prout_reserve_access_we(void)
{
verify_persistent_reserve_access(sd->iscsi_ctx, sd->iscsi_lun, iscsic2, tgt_lun2,
struct scsi_device sd2;
sd2.iscsi_ctx = iscsic2;
sd2.iscsi_lun = tgt_lun2;
verify_persistent_reserve_access(sd, &sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
1, 0, 1, 0);
}
@@ -139,7 +146,11 @@ test_prout_reserve_access_we(void)
void
test_prout_reserve_access_earo(void)
{
verify_persistent_reserve_access(sd->iscsi_ctx, sd->iscsi_lun, iscsic2, tgt_lun2,
struct scsi_device sd2;
sd2.iscsi_ctx = iscsic2;
sd2.iscsi_lun = tgt_lun2;
verify_persistent_reserve_access(sd, &sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
1, 1, 0, 0);
}
@@ -147,7 +158,11 @@ test_prout_reserve_access_earo(void)
void
test_prout_reserve_access_wero(void)
{
verify_persistent_reserve_access(sd->iscsi_ctx, sd->iscsi_lun, iscsic2, tgt_lun2,
struct scsi_device sd2;
sd2.iscsi_ctx = iscsic2;
sd2.iscsi_lun = tgt_lun2;
verify_persistent_reserve_access(sd, &sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
1, 1, 1, 0);
}
@@ -155,7 +170,11 @@ test_prout_reserve_access_wero(void)
void
test_prout_reserve_access_eaar(void)
{
verify_persistent_reserve_access(sd->iscsi_ctx, sd->iscsi_lun, iscsic2, tgt_lun2,
struct scsi_device sd2;
sd2.iscsi_ctx = iscsic2;
sd2.iscsi_lun = tgt_lun2;
verify_persistent_reserve_access(sd, &sd2,
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
1, 1, 0, 0);
}
@@ -163,7 +182,11 @@ test_prout_reserve_access_eaar(void)
void
test_prout_reserve_access_wear(void)
{
verify_persistent_reserve_access(sd->iscsi_ctx, sd->iscsi_lun, iscsic2, tgt_lun2,
struct scsi_device sd2;
sd2.iscsi_ctx = iscsic2;
sd2.iscsi_lun = tgt_lun2;
verify_persistent_reserve_access(sd, &sd2,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
1, 1, 1, 0);
}