diff --git a/test-tool/0280_verify12_simple.c b/test-tool/0280_verify12_simple.c index 7c73271..5b7e084 100644 --- a/test-tool/0280_verify12_simple.c +++ b/test-tool/0280_verify12_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" @@ -24,10 +25,10 @@ int T0280_verify12_simple(const char *initiator, const char *url, int data_loss { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_task *vtask; struct scsi_readcapacity16 *rc16; int ret, i, lun; uint32_t block_size; + unsigned char *buf = NULL; printf("0280_verify12_simple:\n"); printf("=====================\n"); @@ -68,73 +69,47 @@ int T0280_verify12_simple(const char *initiator, const char *url, int data_loss scsi_free_scsi_task(task); + buf = malloc(256 * block_size); + if (buf == NULL) { + printf("Failed to allocate buffer.\n"); + ret = -1; + goto finished; + } + + printf("Read first 256 blocks.\n"); + task = iscsi_read10_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); + ret = -1; + goto finished; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); + ret = -1; + scsi_free_scsi_task(task); + goto finished; + } + memcpy(buf, task->datain.data, task->datain.size); + scsi_free_scsi_task(task); + ret = 0; - /* read and verify the first 1 - 256 blocks at the start of the LUN */ - printf("Read+verify first 1-256 blocks ... "); + + /* verify the first 1 - 256 blocks at the start of the LUN */ + printf("Verify first 1-256 blocks.\n"); for (i = 1; i <= 256; i++) { - unsigned char *buf; - - task = iscsi_read12_sync(iscsi, lun, 0, 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; + ret = verify12(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size); + if (ret != 0) { goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - - buf = task->datain.data; - if (buf == NULL) { - printf("[FAILED]\n"); - printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - - vtask = iscsi_verify12_sync(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size); - if (vtask == NULL) { - printf("[FAILED]\n"); - printf("Failed to send verify12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - if (vtask->status == SCSI_STATUS_CHECK_CONDITION - && vtask->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && vtask->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); - ret = -2; - goto finished; - } - if (vtask->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Verify12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); - goto test2; - } - - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); } - printf("[OK]\n"); -test2: finished: + free(buf); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); return ret; diff --git a/test-tool/0281_verify12_mismatch.c b/test-tool/0281_verify12_mismatch.c index f040711..5eb1140 100644 --- a/test-tool/0281_verify12_mismatch.c +++ b/test-tool/0281_verify12_mismatch.c @@ -17,6 +17,7 @@ #include #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" @@ -25,10 +26,10 @@ int T0281_verify12_mismatch(const char *initiator, const char *url, int data_los { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_task *vtask; struct scsi_readcapacity16 *rc16; int ret, i, lun; uint32_t block_size; + unsigned char *buf = NULL; printf("0281_verify12_mismatch:\n"); printf("=======================\n"); @@ -69,84 +70,54 @@ int T0281_verify12_mismatch(const char *initiator, const char *url, int data_los scsi_free_scsi_task(task); + buf = malloc(256 * block_size); + if (buf == NULL) { + printf("Failed to allocate buffer.\n"); + ret = -1; + goto finished; + } + + printf("Read first 256 blocks.\n"); + task = iscsi_read10_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); + ret = -1; + goto finished; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); + ret = -1; + scsi_free_scsi_task(task); + goto finished; + } + memcpy(buf, task->datain.data, task->datain.size); + scsi_free_scsi_task(task); + ret = 0; /* read and verify the first 1 - 256 blocks at the start of the LUN */ - printf("Read+verify first 1-256 blocks ... "); + printf("Verify first 1-256 blocks with a miscompare.\n"); for (i = 1; i <= 256; i++) { - unsigned char *buf; + int offset = random() % (i * block_size); - task = iscsi_read12_sync(iscsi, lun, 0, 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 test2; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - - buf = task->datain.data; - if (buf == NULL) { - printf("[FAILED]\n"); - printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } /* flip a random byte in the data */ - buf[random() % task->datain.size] ^= 'X'; + buf[offset] ^= 'X'; - vtask = iscsi_verify12_sync(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size); - if (vtask == NULL) { - printf("[FAILED]\n"); - printf("Failed to send verify10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - if (vtask->status == SCSI_STATUS_CHECK_CONDITION - && vtask->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && vtask->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); - ret = -2; + ret = verify12_miscompare(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size); + if (ret != 0) { goto finished; } - if (vtask->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Verify12 command returned sense ok but the data is not matching.\n"); - ret = -1; - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); - goto test2; - } - if (vtask->sense.key != SCSI_SENSE_MISCOMPARE) { - printf("[FAILED]\n"); - printf("Verify12 command returned wrong sense key. MISCOMPARE 0x%x expected but got key 0x%x\n", SCSI_SENSE_MISCOMPARE, vtask->sense.key); - ret = -1; - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); - goto test2; - } - - scsi_free_scsi_task(task); - scsi_free_scsi_task(vtask); + /* flip the byte back */ + buf[offset] ^= 'X'; } - printf("[OK]\n"); -test2: finished: + free(buf); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); return ret; diff --git a/test-tool/0282_verify12_mismatch_no_cmp.c b/test-tool/0282_verify12_mismatch_no_cmp.c index 384cc63..7179766 100644 --- a/test-tool/0282_verify12_mismatch_no_cmp.c +++ b/test-tool/0282_verify12_mismatch_no_cmp.c @@ -17,6 +17,7 @@ #include #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" @@ -28,6 +29,7 @@ int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int d struct scsi_readcapacity10 *rc10; int ret, i, lun; uint32_t block_size; + unsigned char *buf = NULL; printf("0282_verify12_mismatch_no_cmp:\n"); printf("==============================\n"); @@ -69,65 +71,54 @@ int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int d scsi_free_scsi_task(task); - ret = 0; + buf = malloc(256 * block_size); + if (buf == NULL) { + printf("Failed to allocate buffer.\n"); + ret = -1; + goto finished; + } - /* read and verify the first 1 - 256 blocks at the start of the LUN */ - printf("Read 256 blocks and verify they are good ... "); - task = iscsi_read12_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0); + printf("Read first 256 blocks.\n"); + task = iscsi_read10_sync(iscsi, lun, 0, 256 * 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)); + printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("READ12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); + printf("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); goto finished; } + memcpy(buf, task->datain.data, task->datain.size); scsi_free_scsi_task(task); - printf("[OK]\n"); + ret = 0; -test2: - printf("Verify first 1-256 ... "); + /* read and verify the first 1 - 256 blocks at the start of the LUN */ + printf("Verify first 1-256 blocks with a miscompare but BYTCHK==0.\n"); for (i = 1; i <= 256; i++) { - task = iscsi_verify12_sync(iscsi, lun, NULL, i * block_size, 0, 0, 1, 0, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto test3; - } - if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - ret = -2; + int offset = random() % (i * block_size); + + /* flip a random byte in the data */ + buf[offset] ^= 'X'; + + ret = verify12(iscsi, lun, buf, i * block_size, 0, 0, 1, 0, block_size); + if (ret != 0) { goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("VERIFY12 returned sense but BYTCHK==1 means it should not check/compare the data. Sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); + /* flip the byte back */ + buf[offset] ^= 'X'; } - printf("[OK]\n"); - - -test3: finished: + free(buf); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); return ret; diff --git a/test-tool/0283_verify12_beyondeol.c b/test-tool/0283_verify12_beyondeol.c index 480e672..6c220a9 100644 --- a/test-tool/0283_verify12_beyondeol.c +++ b/test-tool/0283_verify12_beyondeol.c @@ -16,6 +16,7 @@ */ #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" @@ -28,7 +29,7 @@ int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_lo int ret, i, lun; uint32_t block_size; uint64_t num_blocks; - unsigned char buf[4096 * 256]; + unsigned char *buf = NULL; printf("0283_verify12_beyond_eol:\n"); printf("========================\n"); @@ -81,48 +82,20 @@ int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_lo goto finished; } + buf = malloc(256 * block_size); + /* verify 2 - 256 blocks beyond the end of the device */ - printf("Verifying 2-256 blocks beyond end-of-device ... "); + printf("Verifying 2-256 blocks beyond end-of-device.\n"); for (i = 2; i <= 256; i++) { - task = iscsi_verify12_sync(iscsi, lun, buf, i * block_size, num_blocks, 0, 1, 1, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send verify12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto test2; - } - if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - ret = -2; + ret = verify12_lbaoutofrange(iscsi, lun, buf, i * block_size, num_blocks, 0, 1, 1, block_size); + if (ret != 0) { goto finished; } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("VERIFY12 command should fail when reading beyond end of device\n"); - ret = -1; - scsi_free_scsi_task(task); - 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("VERIFY12 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); } - printf("[OK]\n"); -test2: finished: + free(buf); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); return ret; diff --git a/test-tool/0370_nomedia.c b/test-tool/0370_nomedia.c index f182945..a8af070 100644 --- a/test-tool/0370_nomedia.c +++ b/test-tool/0370_nomedia.c @@ -370,27 +370,11 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho } - printf("Test VERIFY12 ... "); - task = iscsi_verify12_sync(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; + printf("Test VERIFY12.\n"); + ret = verify12_nomedium(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size); + if (ret != 0) { goto finished; } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_NOT_READY - || (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { - printf("[FAILED]\n"); - printf("VERIFY12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); printf("Test VERIFY16 ... "); diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 98bc564..3b59648 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -1133,6 +1133,148 @@ int verify10_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char * return 0; } +int verify12(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY12 LBA:%d blocks:%d vprotect:%d dpo:%d bytchk:%d ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify12_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); + return -1; + } + if (task->status == SCSI_STATUS_CHECK_CONDITION + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + printf("[SKIPPED]\n"); + printf("VERIFY12 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("VERIFY12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + return -1; + } + + printf("[OK]\n"); + scsi_free_scsi_task(task); + return 0; +} + +int verify12_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY12 LBA:%d blocks:%d vprotect:%d dpo:%d bytchk:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify12_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); + return -1; + } + if (task->status == SCSI_STATUS_CHECK_CONDITION + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + printf("[SKIPPED]\n"); + printf("VERIFY12 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status != SCSI_STATUS_CHECK_CONDITION + || task->sense.key != SCSI_SENSE_NOT_READY + || (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT + && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN + && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { + printf("[FAILED]\n"); + printf("VERIFY12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); + scsi_free_scsi_task(task); + return -1; + } + + printf("[OK]\n"); + scsi_free_scsi_task(task); + return 0; +} + +int verify12_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY12 LBA:%d blocks:%d vprotect:%d dpo:%d bytchk:%d (expecting MISCOMPARE) ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify12_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); + return -1; + } + if (task->status == SCSI_STATUS_CHECK_CONDITION + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + printf("[SKIPPED]\n"); + printf("VERIFY12 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status == SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("VERIFY12 command successful but should have failed with MISCOMPARE\n"); + scsi_free_scsi_task(task); + return -1; + } + if (task->sense.key != SCSI_SENSE_MISCOMPARE) { + printf("[FAILED]\n"); + printf("VERIFY12 command returned wrong sense key. MISCOMPARE MISCOMPARE 0x%x expected but got key 0x%x. Sense:%s\n", SCSI_SENSE_MISCOMPARE, task->sense.key, iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + return -1; + } + + printf("[OK]\n"); + scsi_free_scsi_task(task); + return 0; +} + +int verify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY12 LBA:%d blocks:%d vprotect:%d dpo:%d bytchk:%d (expecting LBA_OUT_OF_RANGE) ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify12_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); + return -1; + } + if (task->status == SCSI_STATUS_CHECK_CONDITION + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + printf("[SKIPPED]\n"); + printf("VERIFY12 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status == SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("VERIFY12 command successful but should have failed with LBA_OUT_OF_RANGE\n"); + scsi_free_scsi_task(task); + return -1; + } + 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("VERIFY12 should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + return -1; + } + + printf("[OK]\n"); + scsi_free_scsi_task(task); + return 0; +} + int main(int argc, const char *argv[]) { poptContext pc; diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index d9ae105..ef010a4 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -265,6 +265,10 @@ int verify10(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t int verify10_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); int verify10_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); int verify10_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify12(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify12_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify12_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize); #endif /* _ISCSI_TEST_H_ */