TESTS: Add tests for writing beyond the end of the LUN for WRITEVERIFY10/12/16

This commit is contained in:
Ronnie Sahlberg
2012-07-14 10:54:15 +10:00
parent 477ee0f6f6
commit f6705d4691
8 changed files with 653 additions and 19 deletions
+59 -17
View File
@@ -34,7 +34,8 @@ 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("2, Read 1-256 blocks at LBA 2^31 (Only on LUN < 1TB)\n");
printf("2, Read 1-256 blocks at LBA -1 (Only on LUN < 2TB)\n");
printf("\n");
return 0;
}
@@ -79,60 +80,101 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss
task = iscsi_read12_sync(iscsi, lun, num_blocks, 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;
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read12 command should fail when reading beyond end of device\n");
ret = -1;
printf("READ12 command should fail when reading beyond end of device\n");
ret++;
scsi_free_scsi_task(task);
goto finished;
goto test2;
}
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;
ret++;
scsi_free_scsi_task(task);
goto finished;
goto test2;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 256 blocks at LBA -1 */
printf("Reading 1-256 blocks at LBA -1 ... ");
if (num_blocks >= 0xffffffff) {
printf("LUN is too big, skipping test\n");
goto test3;
}
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;
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read12 command should fail when reading from LBA -1\n");
ret = -1;
printf("READ12 command should fail when reading from LBA -1\n");
ret++;
scsi_free_scsi_task(task);
goto finished;
goto test3;
}
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;
ret++;
scsi_free_scsi_task(task);
goto finished;
goto test3;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at LBA -1 */
printf("Reading 1-256 blocks at LBA -1 ... ");
if (num_blocks > 0x80000000) {
printf("LUN is too big, skipping test\n");
goto test4;
}
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++;
goto test4;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command should fail when reading from LBA -1\n");
ret++;
scsi_free_scsi_task(task);
goto test4;
}
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++;
scsi_free_scsi_task(task);
goto test4;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
finished:
iscsi_logout_sync(iscsi);