Cleanup to make tests easier to read.

This commit is contained in:
Lee Duncan
2012-12-22 14:12:10 -08:00
parent 474cec5556
commit 9ea26fbca5
3 changed files with 56 additions and 43 deletions

View File

@@ -262,6 +262,23 @@ struct scsi_test tests[] = {
{ NULL, NULL }
};
struct resvn_type_info reservation_types[] = {
{"Write Exclusive",
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE},
{"Exclusive Access",
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS},
{"Write Exclusive, Registrants Only",
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY},
{"Exclusive Access, Registrants Only",
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY},
{"Write Exclusive, All Registrants",
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS},
{"Exclusive Access, All Registrants",
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS},
{NULL, 0}
};
void print_usage(void)
{
fprintf(stderr, "Usage: iscsi-test [-?] [-?|--help] [--usage] [-t|--test=<test>] [-s|--skip=<test>]\n"
@@ -440,7 +457,8 @@ int register_key(struct iscsi_context *iscsi, int lun,
/* register our reservation key with the target */
printf("Send PROUT/REGISTER to register ... ");
printf("Send PROUT/REGISTER to %s ... ",
sark != 0 ? "register" : "unregister");
memset(&poc, 0, sizeof (poc));
poc.service_action_reservation_key = sark;
poc.reservation_key = rk;
@@ -571,21 +589,22 @@ int reregister_key_fails(struct iscsi_context *iscsi, int lun,
int reserve(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
unsigned long long key, struct resvn_type_info *rtip)
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
/* reserve the target using specified reservation type */
printf("Send PROUT/RESERVE to reserve, type=%d ... ", pr_type);
printf("Send PROUT/RESERVE to reserve, type=%d (%s) ... ",
rtip->pr_type, rtip->pr_type_str);
memset(&poc, 0, sizeof (poc));
poc.reservation_key = key;
task = iscsi_persistent_reserve_out_sync(iscsi, lun,
SCSI_PERSISTENT_RESERVE_RESERVE,
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
pr_type, &poc);
rtip->pr_type, &poc);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PROUT command: %s\n",
@@ -608,7 +627,7 @@ int reserve(struct iscsi_context *iscsi, int lun,
int release(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
unsigned long long key, struct resvn_type_info *rtip)
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
@@ -616,14 +635,14 @@ int release(struct iscsi_context *iscsi, int lun,
/* release the target using specified reservation type */
printf("Send PROUT/RELEASE to release reservation, type=%d ... ",
pr_type);
rtip->pr_type);
memset(&poc, 0, sizeof (poc));
poc.reservation_key = key;
task = iscsi_persistent_reserve_out_sync(iscsi, lun,
SCSI_PERSISTENT_RESERVE_RELEASE,
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
pr_type, &poc);
rtip->pr_type, &poc);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PROUT command: %s\n",
@@ -645,7 +664,7 @@ int release(struct iscsi_context *iscsi, int lun,
}
int verify_reserved_as(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
unsigned long long key, struct resvn_type_info *rtip)
{
struct scsi_task *task;
const int buf_sz = 16384;
@@ -653,7 +672,7 @@ int verify_reserved_as(struct iscsi_context *iscsi, int lun,
printf("Send PRIN/READ_RESERVATION to verify type=%d ... ",
pr_type);
rtip->pr_type);
task = iscsi_persistent_reserve_in_sync(iscsi, lun,
SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
if (task == NULL) {
@@ -692,9 +711,9 @@ int verify_reserved_as(struct iscsi_context *iscsi, int lun,
key, rr->reservation_key);
return -1;
}
if (rr->pr_type != pr_type) {
if (rr->pr_type != rtip->pr_type) {
printf("Failed to find reservation type %d: found %d.\n",
pr_type, rr->pr_type);
rtip->pr_type, rr->pr_type);
return -1;
}