TEST: Add test for READ16 at LBA 2^63.

Surprisingly many targets do a LBA << 9 to covert to file offset internally
and thus return data from LBA==0   instead of returning a check condition and lba out of range

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-06-03 14:35:33 +10:00
parent d908c1a642
commit 34778d353c

View File

@@ -34,7 +34,8 @@ 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("2, Read 1-256 blocks at LBA 2^63\n");
printf("3, Read 1-256 blocks at LBA -1\n");
printf("\n");
return 0;
}
@@ -103,6 +104,36 @@ int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss
}
printf("[OK]\n");
/* read 1 - 256 blocks at LBA 2^63 */
printf("Reading 1-256 blocks at LBA 2^63 ... ");
for (i = 2; i <= 257; i++) {
task = iscsi_read16_sync(iscsi, lun, 0x8000000000000000ULL, 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");
/* read 1 - 256 blocks at LBA -1 */
printf("Reading 1-256 blocks at LBA -1 ... ");
for (i = 2; i <= 257; i++) {