TESTS: Improve the tests when reading from LBA -1

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-06-03 10:16:18 +10:00
parent 26873ea6ce
commit d908c1a642
2 changed files with 79 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss
if (show_info) {
printf("Test that READ16 fails if reading beyond end-of-lun.\n");
printf("1, Read 1-256 blocks one block beyond end-of-lun.\n");
printf("2, Read 1-256 blocks at LBA -1\n");
printf("\n");
return 0;
}
@@ -89,10 +90,48 @@ int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss
scsi_free_scsi_task(task);
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
/* read 1 - 256 blocks at LBA -1 */
printf("Reading 1-256 blocks at LBA -1 ... ");
for (i = 2; i <= 257; i++) {
task = iscsi_read16_sync(iscsi, lun, -1, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command should fail when reading at LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
finished:
iscsi_logout_sync(iscsi);

View File

@@ -34,6 +34,7 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss
if (show_info) {
printf("Test that READ12 fails if reading beyond end-of-lun.\n");
printf("1, Read 1-256 blocks one block beyond end-of-lun.\n");
printf("2, Read 1-256 blocks at LBA -1\n");
printf("\n");
return 0;
}
@@ -89,6 +90,45 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss
scsi_free_scsi_task(task);
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ12 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
/* read 1 - 256 blocks at LBA -1 */
printf("Reading 1-256 blocks at LBA -1 ... ");
for (i = 2; i <= 257; i++) {
task = iscsi_read12_sync(iscsi, lun, -1, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read12 command should fail when reading from LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ12 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");