diff --git a/test-tool/0204_read16_beyondeol.c b/test-tool/0204_read16_beyondeol.c index a617f78..bd82703 100644 --- a/test-tool/0204_read16_beyondeol.c +++ b/test-tool/0204_read16_beyondeol.c @@ -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++) {