From 3c960c1d42df12c9cfaa4da2d0f792a83f2b581c Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 26 Dec 2012 09:25:45 -0800 Subject: [PATCH 1/4] TESTS: Create helpers for VERIFY16 and switch all tests over to use them --- test-tool/0270_verify16_simple.c | 91 +++++--------- test-tool/0271_verify16_mismatch.c | 99 ++++++--------- test-tool/0272_verify16_mismatch_no_cmp.c | 63 ++++------ test-tool/0273_verify16_beyondeol.c | 107 +++------------- test-tool/0370_nomedia.c | 24 +--- test-tool/iscsi-test.c | 142 ++++++++++++++++++++++ test-tool/iscsi-test.h | 4 + 7 files changed, 261 insertions(+), 269 deletions(-) diff --git a/test-tool/0270_verify16_simple.c b/test-tool/0270_verify16_simple.c index e79b498..2401f7d 100644 --- a/test-tool/0270_verify16_simple.c +++ b/test-tool/0270_verify16_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" @@ -24,10 +25,10 @@ int T0270_verify16_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("0270_verify16_simple:\n"); printf("=====================\n"); @@ -68,73 +69,47 @@ int T0270_verify16_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_read16_sync(iscsi, lun, 0, 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 test2; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 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_verify16_sync(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size); - if (vtask == NULL) { - printf("[FAILED]\n"); - printf("Failed to send verify16 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 = verify16(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("Verify16 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/0271_verify16_mismatch.c b/test-tool/0271_verify16_mismatch.c index 90c625a..d0384ed 100644 --- a/test-tool/0271_verify16_mismatch.c +++ b/test-tool/0271_verify16_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 T0271_verify16_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("0271_verify16_mismatch:\n"); printf("=======================\n"); @@ -69,84 +70,54 @@ int T0271_verify16_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_read16_sync(iscsi, lun, 0, 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 test2; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 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_verify16_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 = verify16_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("Verify16 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("Verify16 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/0272_verify16_mismatch_no_cmp.c b/test-tool/0272_verify16_mismatch_no_cmp.c index e9e4c2d..5feeae5 100644 --- a/test-tool/0272_verify16_mismatch_no_cmp.c +++ b/test-tool/0272_verify16_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 T0272_verify16_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("0272_verify16_mismatch_no_cmp:\n"); printf("==============================\n"); @@ -69,65 +71,54 @@ int T0272_verify16_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_read16_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 READ16 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("READ16 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_verify16_sync(iscsi, lun, NULL, i * block_size, 0, 0, 1, 0, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY16 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 = verify16(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("VERIFY16 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/0273_verify16_beyondeol.c b/test-tool/0273_verify16_beyondeol.c index 083aff9..1f8ac4b 100644 --- a/test-tool/0273_verify16_beyondeol.c +++ b/test-tool/0273_verify16_beyondeol.c @@ -16,6 +16,7 @@ */ #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" @@ -28,7 +29,7 @@ int T0273_verify16_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("0273_verify16_beyond_eol:\n"); printf("========================\n"); @@ -71,112 +72,36 @@ int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_lo num_blocks = rc16->returned_lba; scsi_free_scsi_task(task); - - - ret = 0; + 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_verify16_sync(iscsi, lun, buf, i * block_size, num_blocks, 0, 1, 1, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = verify16_lbaoutofrange(iscsi, lun, buf, i * block_size, num_blocks, 0, 1, 1, block_size); + if (ret != 0) { goto finished; } - 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; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("VERIFY16 command should fail when reading beyond end of device\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("VERIFY16 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 finished; - } - scsi_free_scsi_task(task); } - printf("[OK]\n"); /* verify 1 - 256 blocks at LBA 2^63 */ - printf("Verify 1-256 blocks at LBA 2^63 ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, 0x8000000000000000ULL, 0, 1, 1, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; + printf("Verifying 1-256 blocks at LBA 2^63.\n"); + for (i = 1; i <= 256; i++) { + ret = verify16_lbaoutofrange(iscsi, lun, buf, i * block_size, 0x8000000000000000, 0, 1, 1, block_size); + if (ret != 0) { goto finished; } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("VERIFY16 command should fail when reading at LBA 2^63\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("VERIFY16 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 finished; - } - scsi_free_scsi_task(task); } - printf("[OK]\n"); /* verify 1 - 256 blocks at LBA -1 */ - printf("Verifying 1-256 blocks at LBA -1 ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, -1LL, 0, 1, 1, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto test2; + printf("Verifying 1-256 blocks at LBA -1.\n"); + for (i = 1; i <= 256; i++) { + ret = verify16_lbaoutofrange(iscsi, lun, buf, i * block_size, 0xffffffffffffffff, 0, 1, 1, block_size); + if (ret != 0) { + goto finished; } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("VERIFY16 command should fail when reading at LBA -1\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("VERIFY16 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 a8af070..32d6bf3 100644 --- a/test-tool/0370_nomedia.c +++ b/test-tool/0370_nomedia.c @@ -376,28 +376,12 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho goto finished; } - - printf("Test VERIFY16 ... "); - task = iscsi_verify16_sync(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; + printf("Test VERIFY16.\n"); + ret = verify16_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("VERIFY16 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"); + if (!data_loss) { diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 9d6fa13..8391fea 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -1256,6 +1256,148 @@ int verify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char * return 0; } +int verify16(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY16 LBA:%" PRIu64 " blocks:%d vprotect:%d dpo:%d bytchk:%d ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify16_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY16 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("VERIFY16 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("VERIFY16 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 verify16_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY16 LBA:%" PRIu64 " blocks:%d vprotect:%d dpo:%d bytchk:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify16_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY16 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("VERIFY16 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("VERIFY16 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 verify16_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY16 LBA:%" PRIu64 " blocks:%d vprotect:%d dpo:%d bytchk:%d (expecting MISCOMPARE) ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify16_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY16 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("VERIFY16 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status == SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("VERIFY16 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("VERIFY16 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 verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize) +{ + struct scsi_task *task; + + printf("Send VERIFY16 LBA:%" PRIu64 " blocks:%d vprotect:%d dpo:%d bytchk:%d (expecting LBA_OUT_OF_RANGE) ... ", lba, datalen / blocksize, vprotect, dpo, bytchk); + task = iscsi_verify16_sync(iscsi, lun, data, datalen, lba, vprotect, dpo, bytchk, blocksize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send VERIFY16 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("VERIFY16 is not implemented on target\n"); + scsi_free_scsi_task(task); + return -2; + } + if (task->status == SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("VERIFY16 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("VERIFY16 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 4d4beee..baf8c68 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -262,5 +262,9 @@ int verify12(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t 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); +int verify16(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify16_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify16_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); #endif /* _ISCSI_TEST_H_ */ From 5ad957b8732acf341ee91bfb9497ec5fc6c394a1 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 26 Dec 2012 18:34:12 -0800 Subject: [PATCH 2/4] TESTS: Start fixing up the tests so we can test-suite them properly Dont call READCAPACITY from every single test. Remove two arguments from the test signatures and turn them into globals. remove the ret++ silliness. Tests return 0 : all ok, -2, skipped or -1 : test failed --- test-tool/0000_testunitready_simple.c | 2 +- test-tool/0100_read10_simple.c | 30 +-- test-tool/0101_read10_beyond_eol.c | 59 +--- test-tool/0102_read10_0blocks.c | 64 ++--- test-tool/0103_read10_rdprotect.c | 27 +- test-tool/0104_read10_flags.c | 27 +- test-tool/0105_read10_invalid.c | 51 +--- test-tool/0110_readcapacity10_simple.c | 2 +- test-tool/0120_read6_simple.c | 28 +- test-tool/0121_read6_beyond_eol.c | 45 +--- test-tool/0122_read6_invalid.c | 52 +--- test-tool/0130_verify10_simple.c | 27 +- test-tool/0131_verify10_mismatch.c | 27 +- test-tool/0132_verify10_mismatch_no_cmp.c | 27 +- test-tool/0133_verify10_beyondeol.c | 31 +-- test-tool/0160_readcapacity16_simple.c | 14 +- test-tool/0161_readcapacity16_alloclen.c | 11 +- test-tool/0170_unmap_simple.c | 5 +- test-tool/0171_unmap_zero.c | 5 +- test-tool/0180_writesame10_unmap.c | 46 ++-- test-tool/0181_writesame10_unmap_unaligned.c | 7 +- test-tool/0182_writesame10_beyondeol.c | 51 +--- test-tool/0183_writesame10_wrprotect.c | 35 +-- test-tool/0184_writesame10_0blocks.c | 63 ++--- test-tool/0190_writesame16_unmap.c | 45 ++-- test-tool/0191_writesame16_unmap_unaligned.c | 2 +- test-tool/0192_writesame16_beyondeol.c | 51 +--- test-tool/0193_writesame16_wrprotect.c | 36 +-- test-tool/0194_writesame16_0blocks.c | 56 +--- test-tool/0200_read16_simple.c | 29 +- test-tool/0201_read16_rdprotect.c | 35 +-- test-tool/0202_read16_flags.c | 28 +- test-tool/0203_read16_0blocks.c | 58 +--- test-tool/0204_read16_beyondeol.c | 30 +-- test-tool/0210_read12_simple.c | 29 +- test-tool/0211_read12_rdprotect.c | 36 +-- test-tool/0212_read12_flags.c | 28 +- test-tool/0213_read12_0blocks.c | 64 ++--- test-tool/0214_read12_beyondeol.c | 75 ++---- test-tool/0220_write16_simple.c | 29 +- test-tool/0221_write16_wrprotect.c | 35 +-- test-tool/0222_write16_flags.c | 28 +- test-tool/0223_write16_0blocks.c | 58 +--- test-tool/0224_write16_beyondeol.c | 28 +- test-tool/0230_write12_simple.c | 29 +- test-tool/0231_write12_wrprotect.c | 35 +-- test-tool/0232_write12_flags.c | 28 +- test-tool/0233_write12_0blocks.c | 63 ++--- test-tool/0234_write12_beyondeol.c | 29 +- test-tool/0240_prefetch10_simple.c | 28 +- test-tool/0241_prefetch10_flags.c | 26 +- test-tool/0242_prefetch10_beyondeol.c | 27 +- test-tool/0243_prefetch10_0blocks.c | 27 +- test-tool/0250_prefetch16_simple.c | 28 +- test-tool/0251_prefetch16_flags.c | 26 +- test-tool/0252_prefetch16_beyondeol.c | 28 +- test-tool/0253_prefetch16_0blocks.c | 28 +- test-tool/0260_get_lba_status_simple.c | 5 +- test-tool/0264_get_lba_status_beyondeol.c | 6 +- test-tool/0270_verify16_simple.c | 27 +- test-tool/0271_verify16_mismatch.c | 27 +- test-tool/0272_verify16_mismatch_no_cmp.c | 28 +- test-tool/0273_verify16_beyondeol.c | 29 +- test-tool/0280_verify12_simple.c | 27 +- test-tool/0281_verify12_mismatch.c | 27 +- test-tool/0282_verify12_mismatch_no_cmp.c | 27 +- test-tool/0283_verify12_beyondeol.c | 31 +-- test-tool/0290_write10_simple.c | 29 +- test-tool/0291_write10_wrprotect.c | 34 +-- test-tool/0292_write10_flags.c | 28 +- test-tool/0293_write10_0blocks.c | 63 ++--- test-tool/0294_write10_beyondeol.c | 28 +- test-tool/0300_readonly.c | 190 ++++++------- test-tool/0310_writeverify10_simple.c | 48 +--- test-tool/0311_writeverify10_wrprotect.c | 43 +-- test-tool/0314_writeverify10_beyondeol.c | 74 ++--- test-tool/0320_writeverify12_simple.c | 48 +--- test-tool/0321_writeverify12_wrprotect.c | 43 +-- test-tool/0324_writeverify12_beyondeol.c | 74 ++--- test-tool/0330_writeverify16_simple.c | 48 +--- test-tool/0331_writeverify16_wrprotect.c | 43 +-- test-tool/0334_writeverify16_beyondeol.c | 70 ++--- test-tool/0340_compareandwrite_simple.c | 72 ++--- test-tool/0341_compareandwrite_mismatch.c | 79 ++---- test-tool/0343_compareandwrite_beyondeol.c | 71 ++--- test-tool/0350_orwrite_simple.c | 103 +++---- test-tool/0351_orwrite_wrprotect.c | 43 +-- test-tool/0354_orwrite_beyondeol.c | 71 ++--- test-tool/0360_startstopunit_simple.c | 2 +- test-tool/0361_startstopunit_pwrcnd.c | 10 +- test-tool/0362_startstopunit_noloej.c | 43 ++- test-tool/0370_nomedia.c | 27 +- test-tool/0380_preventallow_simple.c | 25 +- test-tool/0381_preventallow_eject.c | 40 ++- test-tool/0382_preventallow_itnexus_loss.c | 51 ++-- .../0383_preventallow_target_warm_reset.c | 2 +- .../0384_preventallow_target_cold_reset.c | 2 +- test-tool/0385_preventallow_lun_reset.c | 2 +- test-tool/0386_preventallow_2_it_nexuses.c | 63 ++--- test-tool/0390_mandatory_opcodes_sbc.c | 187 ++++++------- test-tool/0400_inquiry_basic.c | 3 +- test-tool/0401_inquiry_alloclen.c | 3 +- test-tool/0402_inquiry_evpd.c | 3 +- test-tool/0403_inquiry_supported_vpd.c | 3 +- test-tool/0404_inquiry_all_reported_vpd.c | 3 +- test-tool/0410_readtoc_basic.c | 3 +- test-tool/0420_reserve6_simple.c | 3 +- test-tool/0421_reserve6_lun_reset.c | 3 +- test-tool/0422_reserve6_logout.c | 3 +- test-tool/0423_reserve6_sessionloss.c | 3 +- test-tool/0424_reserve6_target_reset.c | 3 +- test-tool/0430_report_all_supported_ops.c | 3 +- test-tool/1000_cmdsn_invalid.c | 46 +--- test-tool/1010_datasn_invalid.c | 66 ++--- test-tool/1020_bufferoffset_invalid.c | 47 +--- test-tool/1030_unsolicited_data_overflow.c | 34 +-- test-tool/1031_unsolicited_data_out.c | 30 +-- test-tool/1040_saturate_maxcmdsn.c | 48 +--- test-tool/1041_unsolicited_immediate_data.c | 28 +- .../1042_unsolicited_nonimmediate_data.c | 29 +- ...0_persistent_reserve_in_read_keys_simple.c | 2 +- ...ersistent_reserve_in_serviceaction_range.c | 2 +- test-tool/1120_persistent_register_simple.c | 3 +- test-tool/1130_persistent_reserve_simple.c | 5 +- test-tool/iscsi-test.c | 111 ++++++-- test-tool/iscsi-test.h | 255 +++++++++--------- 126 files changed, 1096 insertions(+), 3554 deletions(-) diff --git a/test-tool/0000_testunitready_simple.c b/test-tool/0000_testunitready_simple.c index 818eb1c..9bc13d0 100644 --- a/test-tool/0000_testunitready_simple.c +++ b/test-tool/0000_testunitready_simple.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0000_testunitready_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0000_testunitready_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; int ret, lun; diff --git a/test-tool/0100_read10_simple.c b/test-tool/0100_read10_simple.c index d3df442..9591e0c 100644 --- a/test-tool/0100_read10_simple.c +++ b/test-tool/0100_read10_simple.c @@ -1,3 +1,4 @@ + /* Copyright (C) 2010 by Ronnie Sahlberg @@ -20,13 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0100_read10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0100_read10_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size, num_blocks; printf("0100_read10_simple:\n"); printf("===================\n"); @@ -44,31 +43,6 @@ int T0100_read10_simple(const char *initiator, const char *url, int data_loss _U return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - num_blocks = rc10->lba; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0101_read10_beyond_eol.c b/test-tool/0101_read10_beyond_eol.c index bfbb33b..5c9be18 100644 --- a/test-tool/0101_read10_beyond_eol.c +++ b/test-tool/0101_read10_beyond_eol.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0101_read10_beyond_eol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size, num_blocks; printf("0101_read10_beyond_eol:\n"); printf("=======================\n"); @@ -47,31 +45,6 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - num_blocks = rc10->lba; - scsi_free_scsi_task(task); - - ret = 0; if (num_blocks >= 0x80000000) { @@ -89,14 +62,14 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los printf("[FAILED]\n"); 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("READ10 beyond end-of-lun did not fail with sense.\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -105,13 +78,13 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los printf("READ10 failed but ascq was wrong. 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: + /* Reading 1 - 256 blocks at LBA 2^31 */ printf("Reaing 1-256 blocks at LBA 2^31 ... "); for (i = 1; i <= 256; i++) { @@ -120,14 +93,14 @@ test2: printf("[FAILED]\n"); printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ10 command should fail when reading from LBA 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -136,14 +109,13 @@ test2: printf("READ10 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 1 - 256 blocks at LBA -1 */ printf("Read 1-256 blocks at LBA -1 ... "); for (i = 1; i <= 256; i++) { @@ -152,14 +124,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ10 command should fail when reading at LBA -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -168,14 +140,13 @@ test3: printf("READ10 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); - test4: /* read 2-256 blocks, all but one block beyond the eol */ printf("Reading 1-255 blocks beyond eol starting at last block ... "); for (i=2; i<=256; i++) { @@ -184,14 +155,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ10 beyond end-of-lun did not return sense.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -200,15 +171,13 @@ test3: printf("READ10 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0102_read10_0blocks.c b/test-tool/0102_read10_0blocks.c index 0b26598..924fb5e 100644 --- a/test-tool/0102_read10_0blocks.c +++ b/test-tool/0102_read10_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0102_read10_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0102_read10_0blocks:\n"); printf("====================\n"); @@ -47,31 +44,6 @@ int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss _ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - printf("READ10 0blocks at LBA:0 ... "); task = iscsi_read10_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0); @@ -79,39 +51,38 @@ int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss _ printf("[FAILED]\n"); 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("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("READ10 0blocks at one block beyond ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } task = iscsi_read10_sync(iscsi, lun, num_blocks + 1, 0, 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 test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ10 command: Should fail when reading 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -120,32 +91,31 @@ test2: printf("READ10 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("READ10 0blocks at LBA 2^31 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test4; + goto finished; } task = iscsi_read10_sync(iscsi, lun, 0x80000000, 0, 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 test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ10 command: Should fail when reading 0blocks at 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -154,32 +124,31 @@ test3: printf("READ10 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("READ10 0blocks at LBA -1 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test5; + goto finished; } task = iscsi_read10_sync(iscsi, lun, -1, 0, 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 test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ10 command: Should fail when reading 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -188,15 +157,12 @@ test4: printf("READ10 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0103_read10_rdprotect.c b/test-tool/0103_read10_rdprotect.c index c4d0668..8646a94 100644 --- a/test-tool/0103_read10_rdprotect.c +++ b/test-tool/0103_read10_rdprotect.c @@ -22,14 +22,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0103_read10_rdprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; int full_size; struct scsi_inquiry_standard *inq; - struct scsi_readcapacity10 *rc10; - uint32_t block_size; int ret, i, lun; printf("0103_read10_rdprotect:\n"); @@ -85,29 +83,6 @@ int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss scsi_free_scsi_task(task); - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - ret = 0; diff --git a/test-tool/0104_read10_flags.c b/test-tool/0104_read10_flags.c index a86100c..bb18fbb 100644 --- a/test-tool/0104_read10_flags.c +++ b/test-tool/0104_read10_flags.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0104_read10_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_standard *inq; - struct scsi_readcapacity10 *rc10; - uint32_t block_size; int ret, lun; printf("0104_read10_flags:\n"); @@ -68,29 +66,6 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_ return -2; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - ret = 0; diff --git a/test-tool/0105_read10_invalid.c b/test-tool/0105_read10_invalid.c index 4913892..6e6992f 100644 --- a/test-tool/0105_read10_invalid.c +++ b/test-tool/0105_read10_invalid.c @@ -23,14 +23,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0105_read10_invalid(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct iscsi_data data; char buf[4096]; - struct scsi_readcapacity10 *rc10; - uint32_t block_size; int ret, lun; printf("0105_read10_invalid:\n"); @@ -52,30 +50,6 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - - ret = 0; @@ -111,14 +85,14 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _ if (task->status == SCSI_STATUS_CANCELLED) { scsi_free_scsi_task(task); printf("Target dropped the session [OK]\n"); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("Read10 of 1 block with iscsi ExpectedDataTransferLength==0 should not fail.\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != (int64_t)block_size) { @@ -126,13 +100,12 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _ printf("Read10 returned incorrect residual overflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); @@ -165,7 +138,7 @@ test2: printf("Read10 of 1 block with iscsi ExpectedDataTransferLength==1024 should not fail.\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != (int64_t)block_size) { @@ -173,13 +146,12 @@ test2: printf("Read10 returned incorrect residual underflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: /* Try a read of 1 block but xferlength == 200 */ printf("Read10 1 block but with iscsi ExpectedDataTransferLength==200 ... "); @@ -209,7 +181,7 @@ test3: printf("Read10 of 1 block with iscsi ExpectedDataTransferLength==200 should not fail.\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != (int64_t)(block_size - 200)) { @@ -217,12 +189,12 @@ test3: printf("Read10 returned incorrect residual overflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: + /* Try a read of 2 blocks but xferlength == 'block_size' */ printf("Read10 2 blocks but with iscsi ExpectedDataTransferLength==%d ... ", block_size); @@ -252,7 +224,7 @@ test4: printf("Read10 of 2 blocks with iscsi ExpectedDataTransferLength==%d should succeed.\n", block_size); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != (int64_t)block_size) { @@ -260,14 +232,13 @@ test4: printf("Read10 returned incorrect residual overflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: /* Try a read of 1 block but make it a data-out write on the iscsi layer */ printf("Read10 of 1 block but sent as data-out write in iscsi layer ... "); diff --git a/test-tool/0110_readcapacity10_simple.c b/test-tool/0110_readcapacity10_simple.c index cfbfa9a..09a62de 100644 --- a/test-tool/0110_readcapacity10_simple.c +++ b/test-tool/0110_readcapacity10_simple.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0110_readcapacity10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0110_readcapacity10_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0120_read6_simple.c b/test-tool/0120_read6_simple.c index 5f923fd..af4b362 100644 --- a/test-tool/0120_read6_simple.c +++ b/test-tool/0120_read6_simple.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0120_read6_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0120_read6_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size; printf("0120_read6_simple:\n"); printf("===================\n"); @@ -43,30 +41,6 @@ int T0120_read6_simple(const char *initiator, const char *url, int data_loss _U_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0121_read6_beyond_eol.c b/test-tool/0121_read6_beyond_eol.c index bba83cb..ff1cb68 100644 --- a/test-tool/0121_read6_beyond_eol.c +++ b/test-tool/0121_read6_beyond_eol.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0121_read6_beyond_eol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size, num_blocks; printf("0121_read6_beyond_eol:\n"); printf("======================\n"); @@ -46,29 +44,6 @@ int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - num_blocks = rc10->lba; - scsi_free_scsi_task(task); ret = 0; @@ -88,35 +63,34 @@ int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss printf("[FAILED]\n"); printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ6 beyond end-of-lun did not fail with sense.\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST) { printf("[FAILED]\n"); printf("READ6 beyond end-of-lun did not return sense key ILLEGAL_REQUEST. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { printf("[FAILED]\n"); printf("READ6 beyond end-of-lun did not return sense ascq LBA OUT OF RANGE. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* read 2-256 blocks, all but one block beyond the eol */ printf("Reading 1-255 blocks beyond eol starting at last block ... "); for (i=2; i<=256; i++) { @@ -125,35 +99,34 @@ test2: printf("[FAILED]\n"); printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ6 beyond end-of-lun did not return sense.\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST) { printf("[FAILED]\n"); printf("READ6 beyond end-of-lun did not return sense key ILLEGAL_REQUEST. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { printf("[FAILED]\n"); printf("READ6 beyond end-of-lun did not return sense ascq LBA OUT OF RANGE. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 0 (==256) blocks 128 blocks from eol */ printf("Reading 0(==256) blocks beyond eol starting at 128 blocks before eol ... "); task = iscsi_read6_sync(iscsi, lun, num_blocks-128, i * block_size, block_size); diff --git a/test-tool/0122_read6_invalid.c b/test-tool/0122_read6_invalid.c index f0ebc1c..d1deda5 100644 --- a/test-tool/0122_read6_invalid.c +++ b/test-tool/0122_read6_invalid.c @@ -23,14 +23,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0122_read6_invalid(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct iscsi_data data; char buf[4096]; - struct scsi_readcapacity10 *rc10; - uint32_t block_size; int ret, lun; printf("0122_read6_invalid:\n"); @@ -52,29 +50,6 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - ret = 0; @@ -110,14 +85,14 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U if (task->status == SCSI_STATUS_CANCELLED) { scsi_free_scsi_task(task); printf("Target dropped the session [OK]\n"); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==0 should not fail.\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != (ssize_t)block_size) { @@ -125,13 +100,12 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U printf("Read6 returned incorrect residual overflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); @@ -164,7 +138,7 @@ test2: printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==1024 should not fail.\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != (ssize_t)block_size) { @@ -172,13 +146,12 @@ test2: printf("Read6 returned incorrect residual underflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: /* Try a read of 1 block but xferlength == 200 */ printf("Read6 1 block but with iscsi ExpectedDataTransferLength==200 ... "); @@ -208,7 +181,7 @@ test3: printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==200 should not fail.\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != (ssize_t)block_size - 200) { @@ -216,12 +189,12 @@ test3: printf("Read6 returned incorrect residual overflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: + /* Try a read of 2 blocks but xferlength == block_size */ printf("Read6 2 blocks but with iscsi ExpectedDataTransferLength==%d ... ", block_size); @@ -251,7 +224,7 @@ test4: printf("Read6 of 2 blocks with iscsi ExpectedDataTransferLength==%d should succeed.\n", block_size); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != (ssize_t)block_size) { @@ -259,14 +232,12 @@ test4: printf("Read6 returned incorrect residual overflow.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } - scsi_free_scsi_task(task); printf("[OK]\n"); -test5: /* Try a read of 1 block but make it a data-out write on the iscsi layer */ printf("Read6 of 1 block but sent as data-out write in iscsi layer ... "); @@ -304,6 +275,7 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); + finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0130_verify10_simple.c b/test-tool/0130_verify10_simple.c index 3a27bf2..ad19d58 100644 --- a/test-tool/0130_verify10_simple.c +++ b/test-tool/0130_verify10_simple.c @@ -21,13 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0130_verify10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0130_verify10_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0130_verify10_simple:\n"); @@ -45,29 +43,6 @@ int T0130_verify10_simple(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0131_verify10_mismatch.c b/test-tool/0131_verify10_mismatch.c index 91ba297..47bf2f3 100644 --- a/test-tool/0131_verify10_mismatch.c +++ b/test-tool/0131_verify10_mismatch.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0131_verify10_mismatch(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0131_verify10_mismatch(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; @@ -47,29 +45,6 @@ int T0131_verify10_mismatch(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0132_verify10_mismatch_no_cmp.c b/test-tool/0132_verify10_mismatch_no_cmp.c index 52205b4..19a4943 100644 --- a/test-tool/0132_verify10_mismatch_no_cmp.c +++ b/test-tool/0132_verify10_mismatch_no_cmp.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0132_verify10_mismatch_no_cmp:\n"); @@ -47,29 +45,6 @@ int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url, int d return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0133_verify10_beyondeol.c b/test-tool/0133_verify10_beyondeol.c index 8a5dfa0..6476b25 100644 --- a/test-tool/0133_verify10_beyondeol.c +++ b/test-tool/0133_verify10_beyondeol.c @@ -20,14 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0133_verify10_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0133_verify10_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char *buf = NULL; printf("0133_verify10_beyond_eol:\n"); @@ -46,31 +42,6 @@ int T0133_verify10_beyondeol(const char *initiator, const char *url, int data_lo return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0160_readcapacity16_simple.c b/test-tool/0160_readcapacity16_simple.c index fb27014..90be354 100644 --- a/test-tool/0160_readcapacity16_simple.c +++ b/test-tool/0160_readcapacity16_simple.c @@ -20,18 +20,18 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0160_readcapacity16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0160_readcapacity16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; struct scsi_readcapacity16 *rc16; + struct scsi_task *task; int ret, lun; printf("0160_readcapacity16_simple:\n"); printf("===========================\n"); if (show_info) { printf("Test that basic READCAPACITY16 works\n"); - printf("1, Readcapacity16 should work.\n"); + printf("1, READCAPACITY16 should work.\n"); printf("\n"); return 0; } @@ -44,17 +44,17 @@ int T0160_readcapacity16_simple(const char *initiator, const char *url, int data return -1; } - printf("Test that Readcapacity10 is supported ... "); + printf("Test that READCAPACITY16 is supported ... "); task = iscsi_readcapacity16_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); + printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); + printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); goto finished; @@ -62,7 +62,7 @@ int T0160_readcapacity16_simple(const char *initiator, const char *url, int data rc16 = scsi_datain_unmarshall(task); if (rc16 == NULL) { printf("[FAILED]\n"); - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); + printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); goto finished; diff --git a/test-tool/0161_readcapacity16_alloclen.c b/test-tool/0161_readcapacity16_alloclen.c index b6a74cc..7fd2102 100644 --- a/test-tool/0161_readcapacity16_alloclen.c +++ b/test-tool/0161_readcapacity16_alloclen.c @@ -23,7 +23,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0161_readcapacity16_alloclen(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -33,7 +33,7 @@ int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int da printf("=======================\n"); if (show_info) { printf("Test allocation-length for READCAPACITY16\n"); - printf("1, Readcapacity with alloclen==0 is not an error\n"); + printf("1, READCAPACITY16 with alloclen==0 is not an error\n"); printf("\n"); return 0; } @@ -48,7 +48,6 @@ int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int da printf("READCAPACITY16 with AllocationLength==0 ... "); - task = malloc(sizeof(struct scsi_task)); if (task == NULL) { printf("Failed to allocate task structure\n"); @@ -68,21 +67,19 @@ int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int da printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READCAPACITY16 with AllocationLength==0 should not fail. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0170_unmap_simple.c b/test-tool/0170_unmap_simple.c index 9ede4a6..952bd1b 100644 --- a/test-tool/0170_unmap_simple.c +++ b/test-tool/0170_unmap_simple.c @@ -20,13 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0170_unmap_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0170_unmap_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t num_blocks; printf("0170_unmap_simple:\n"); printf("==================\n"); @@ -72,8 +71,6 @@ int T0170_unmap_simple(const char *initiator, const char *url, int data_loss, in goto finished; } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { diff --git a/test-tool/0171_unmap_zero.c b/test-tool/0171_unmap_zero.c index 45b3e3e..db18278 100644 --- a/test-tool/0171_unmap_zero.c +++ b/test-tool/0171_unmap_zero.c @@ -20,13 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0171_unmap_zero(const char *initiator, const char *url, int data_loss, int show_info) +int T0171_unmap_zero(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t num_blocks; printf("0171_unmap_zero:\n"); printf("================\n"); @@ -74,8 +73,6 @@ int T0171_unmap_zero(const char *initiator, const char *url, int data_loss, int goto finished; } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { diff --git a/test-tool/0180_writesame10_unmap.c b/test-tool/0180_writesame10_unmap.c index 2cbb46b..c398466 100644 --- a/test-tool/0180_writesame10_unmap.c +++ b/test-tool/0180_writesame10_unmap.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0180_writesame10_unmap(const char *initiator, const char *url, int data_loss, int show_info) +int T0180_writesame10_unmap(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -28,7 +28,6 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los int full_size; struct scsi_inquiry_logical_block_provisioning *inq_lbp; int ret, i, lun; - uint32_t num_blocks; int lbppb; int lbpme; int lbpws10 = 0; @@ -53,6 +52,8 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los return -1; } + ret = 0; + /* find the size of the LUN */ task = iscsi_readcapacity16_sync(iscsi, lun); if (task == NULL) { @@ -73,7 +74,6 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los scsi_free_scsi_task(task); goto finished; } - num_blocks = rc16->returned_lba; lbppb = 1 << rc16->lbppbe; lbpme = rc16->lbpme; @@ -81,7 +81,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los if (lbpme == 0){ printf("Logical unit is fully provisioned. All commands should fail with check condition.\n"); - goto test2; + goto finished; } /* Check that id we have logical block provisioning we also have the VPD page for it */ @@ -93,7 +93,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los printf("[FAILED]\n"); printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } full_size = scsi_datain_getfullsize(task); if (full_size > task->datain.size) { @@ -104,7 +104,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los printf("[FAILED]\n"); printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } } @@ -113,7 +113,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los printf("failed to unmarshall inquiry datain blob\n"); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } lbpws10 = inq_lbp->lbpws10; @@ -126,8 +126,6 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los printf("Device does not support WRITE_SAME10 for UNMAP. All WRITE_SAME10 commands to unmap should fail.\n"); } -test2: - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -154,7 +152,7 @@ test2: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -171,7 +169,7 @@ test2: printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test3; + goto finished; } } else { if (task->status != SCSI_STATUS_CHECK_CONDITION @@ -181,7 +179,7 @@ test2: printf("WRITESAME10 command should fail since LBPWS10 is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test3; + goto finished; } } @@ -189,7 +187,7 @@ test2: } printf("[OK]\n"); -test3: + /* unmap the last 1 - 256 blocks at the end of the LUN */ printf("Unmapping last 1-256 blocks ... "); if (lbpws10 == 0) { @@ -209,7 +207,7 @@ test3: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (lbpws10) { if (task->status != SCSI_STATUS_GOOD) { @@ -217,7 +215,7 @@ test3: printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test4; + goto finished; } } else { if (task->status != SCSI_STATUS_CHECK_CONDITION @@ -227,15 +225,13 @@ test3: printf("WRITESAME10 command should fail since LBPWS10 is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test4; + goto finished; } } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: - /* Test that UNMAP=0 and ANCHOR==1 fails with check condition */ printf("Try UNMAP==0 and ANCHOR==1 ... "); @@ -246,7 +242,7 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -258,12 +254,11 @@ test4: scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq); scsi_free_scsi_task(task); ret = -1; - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: /* Test UNMAP=1 and ANCHOR==1 */ printf("Try UNMAP==1 and ANCHOR==1 ... "); @@ -277,7 +272,7 @@ test5: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (anc_sup == 0) { if (task->status != SCSI_STATUS_CHECK_CONDITION @@ -290,7 +285,7 @@ test5: scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq); scsi_free_scsi_task(task); ret = -1; - goto test6; + goto finished; } } else { if (task->status != SCSI_STATUS_GOOD) { @@ -298,15 +293,12 @@ test5: printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test6; + goto finished; } } scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - - finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0181_writesame10_unmap_unaligned.c b/test-tool/0181_writesame10_unmap_unaligned.c index 1de027b..be5ecc2 100644 --- a/test-tool/0181_writesame10_unmap_unaligned.c +++ b/test-tool/0181_writesame10_unmap_unaligned.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, int data_loss, int show_info) +int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -99,7 +99,7 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, in printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -115,13 +115,12 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, in printf("WRITESAME10 command to unmap a fractional physical block should fail\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0182_writesame10_beyondeol.c b/test-tool/0182_writesame10_beyondeol.c index 281eeae..4c4f4be 100644 --- a/test-tool/0182_writesame10_beyondeol.c +++ b/test-tool/0182_writesame10_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0182_writesame10_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char buf[4096]; printf("0182_writesame10_beyondeol:\n"); @@ -48,30 +45,6 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -97,7 +70,7 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -113,7 +86,7 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data printf("WRITESAME10 command should fail when writing beyond end of device\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -122,14 +95,13 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data printf("WRITESAME10 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* writing 1 - 256 blocks at LBA 2^31 */ printf("Writing 1-256 blocks at LBA 2^31 ... "); for (i = 1; i <= 256; i++) { @@ -139,14 +111,14 @@ test2: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command should fail when writing at LBA 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -155,14 +127,13 @@ test2: printf("WRITESAME10 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* write 1 - 256 blocks at LBA -1 */ printf("Writing 1-256 blocks at LBA -1 ... "); for (i = 1; i <= 256; i++) { @@ -172,14 +143,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command should fail when reading at LBA -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -188,15 +159,13 @@ test3: printf("WRITESAME10 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0183_writesame10_wrprotect.c b/test-tool/0183_writesame10_wrprotect.c index 2000b53..2b7b706 100644 --- a/test-tool/0183_writesame10_wrprotect.c +++ b/test-tool/0183_writesame10_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0183_writesame10_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; unsigned char buf[4096]; printf("0183_writesame10_wrptotect:\n"); @@ -44,28 +42,6 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -86,7 +62,7 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -102,7 +78,7 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data printf("WRITESAME10 command should fail when WRPROTECT is set\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -111,16 +87,13 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data printf("WRITESAME10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB.\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); - -test2: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0184_writesame10_0blocks.c b/test-tool/0184_writesame10_0blocks.c index c43ab4e..9ed312c 100644 --- a/test-tool/0184_writesame10_0blocks.c +++ b/test-tool/0184_writesame10_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0184_writesame10_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char buf[4096]; printf("0184_writesame10_0blocks:\n"); @@ -48,30 +45,6 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -88,7 +61,7 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -104,18 +77,17 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("Writesame10 0blocks at one block beyond ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } task = iscsi_writesame10_sync(iscsi, lun, buf, block_size, num_blocks + 1, 0, 0, 0, 0, 0, 0, 0); @@ -123,14 +95,14 @@ test2: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command: Should fail when writing 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -139,18 +111,17 @@ test2: printf("WRITESAME10 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("Writesame10 0blocks at LBA 2^31 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test4; + goto finished; } task = iscsi_writesame10_sync(iscsi, lun, buf, block_size, 0x80000000, 0, 0, 0, 0, 0, 0, 0); @@ -158,14 +129,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command: Should fail when writing 0blocks at 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -174,18 +145,17 @@ test3: printf("WRITESAME10 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Writesame10 0blocks at LBA -1 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test5; + goto finished; } task = iscsi_writesame10_sync(iscsi, lun, buf, block_size, -1, 0, 0, 0, 0, 0, 0, 0); @@ -193,14 +163,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command: Should fail when writing 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -209,15 +179,12 @@ test4: printf("WRITESAME10 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0190_writesame16_unmap.c b/test-tool/0190_writesame16_unmap.c index 0d90941..e40c7e2 100644 --- a/test-tool/0190_writesame16_unmap.c +++ b/test-tool/0190_writesame16_unmap.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0190_writesame16_unmap(const char *initiator, const char *url, int data_loss, int show_info) +int T0190_writesame16_unmap(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -28,7 +28,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los int full_size; struct scsi_inquiry_logical_block_provisioning *inq_lbp; int ret, i, lun; - uint32_t num_blocks; int lbppb; int lbpme; int lbpws = 0; @@ -53,6 +52,8 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los return -1; } + ret = 0; + /* find the size of the LUN */ task = iscsi_readcapacity16_sync(iscsi, lun); if (task == NULL) { @@ -74,7 +75,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los goto finished; } - num_blocks = rc16->returned_lba; lbppb = 1 << rc16->lbppbe; lbpme = rc16->lbpme; @@ -82,7 +82,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los if (lbpme == 0) { printf("LBPME not set. Skip test for CPD page 0xB2 (logical block provisioning)\n"); - goto test2; + goto finished; } /* Check that id we have logical block provisioning we also have the VPD page for it */ @@ -94,7 +94,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los printf("[FAILED]\n"); printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } full_size = scsi_datain_getfullsize(task); if (full_size > task->datain.size) { @@ -105,7 +105,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los printf("[FAILED]\n"); printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } } @@ -114,7 +114,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los printf("failed to unmarshall inquiry datain blob\n"); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } lbpws = inq_lbp->lbpws; @@ -127,7 +127,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los printf("Device does not support WRITE_SAME16 for UNMAP. All WRITE_SAME16 commands to unmap should fail.\n"); } -test2: if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -155,7 +154,7 @@ test2: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -172,7 +171,7 @@ test2: printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test3; + goto finished; } } else { if (task->status != SCSI_STATUS_CHECK_CONDITION @@ -182,7 +181,7 @@ test2: printf("WRITESAME16 command should fail since LBPWS is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test3; + goto finished; } } @@ -190,7 +189,7 @@ test2: } printf("[OK]\n"); -test3: + /* unmap the last 1 - 256 blocks at the end of the LUN */ printf("Unmapping last 1-256 blocks ... "); if (lbpws == 0) { @@ -210,7 +209,7 @@ test3: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (lbpws) { if (task->status != SCSI_STATUS_GOOD) { @@ -218,7 +217,7 @@ test3: printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test4; + goto finished; } } else { if (task->status != SCSI_STATUS_CHECK_CONDITION @@ -228,15 +227,13 @@ test3: printf("WRITESAME16 command should fail since LBPWS is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test4; + goto finished; } } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: - /* Test that UNMAP=0 and ANCHOR==1 fails with check condition */ printf("Try UNMAP==0 and ANCHOR==1 ... "); @@ -247,7 +244,7 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -256,12 +253,11 @@ test4: printf("WRITESAME16 with UNMAP=0 ANCHOR=1 failed with wrong sense code %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: /* Test UNMAP=1 and ANCHOR==1 */ printf("Try UNMAP==1 and ANCHOR==1 ... "); @@ -275,7 +271,7 @@ test5: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (anc_sup == 0) { if (task->status != SCSI_STATUS_CHECK_CONDITION @@ -285,7 +281,7 @@ test5: printf("WRITESAME16 with UNMAP=1 ANCHOR=1 failed with wrong sense code %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test6; + goto finished; } } else { if (task->status != SCSI_STATUS_GOOD) { @@ -293,15 +289,12 @@ test5: printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test6; + goto finished; } } scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - - finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0191_writesame16_unmap_unaligned.c b/test-tool/0191_writesame16_unmap_unaligned.c index da30eab..9ae7553 100644 --- a/test-tool/0191_writesame16_unmap_unaligned.c +++ b/test-tool/0191_writesame16_unmap_unaligned.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url, int data_loss, int show_info) +int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0192_writesame16_beyondeol.c b/test-tool/0192_writesame16_beyondeol.c index 91476ce..da94422 100644 --- a/test-tool/0192_writesame16_beyondeol.c +++ b/test-tool/0192_writesame16_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0192_writesame16_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char buf[4096]; printf("0192_writesame16_beyondeol:\n"); @@ -47,30 +44,6 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -89,7 +62,7 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -105,7 +78,7 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data printf("WRITESAME16 command should fail when writing beyond end of device\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -114,14 +87,13 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data printf("WRITESAME16 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* writing 1 - 256 blocks at LBA 2^63 */ printf("Writing 1-256 blocks at LBA 2^63 ... "); for (i = 1; i <= 256; i++) { @@ -131,14 +103,14 @@ test2: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command should fail when writing at LBA 2^63\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -147,14 +119,13 @@ test2: printf("WRITESAME16 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* write 1 - 256 blocks at LBA -1 */ printf("Writing 1-256 blocks at LBA -1 ... "); for (i = 1; i <= 256; i++) { @@ -164,14 +135,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command should fail when reading at LBA -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -180,15 +151,13 @@ test3: printf("WRITESAME16 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0193_writesame16_wrprotect.c b/test-tool/0193_writesame16_wrprotect.c index 4161be8..d662f8b 100644 --- a/test-tool/0193_writesame16_wrprotect.c +++ b/test-tool/0193_writesame16_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0193_writesame16_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; unsigned char buf[4096]; printf("0193_writesame16_wrptotect:\n"); @@ -44,29 +42,6 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -86,7 +61,7 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -102,7 +77,7 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data printf("WRITESAME16 command should fail when WRPROTECT is set\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -111,16 +86,13 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data printf("WRITESAME16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB.\n"); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); - -test2: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0194_writesame16_0blocks.c b/test-tool/0194_writesame16_0blocks.c index 487dc91..66ff7e5 100644 --- a/test-tool/0194_writesame16_0blocks.c +++ b/test-tool/0194_writesame16_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0194_writesame16_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char buf[4096]; printf("0194_writesame16_0blocks:\n"); @@ -48,30 +45,6 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -88,7 +61,7 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -104,13 +77,12 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("Writesame16 0blocks at one block beyond ... "); task = iscsi_writesame16_sync(iscsi, lun, buf, block_size, num_blocks + 1, 0, 0, 0, 0, 0, 0, 0); @@ -118,14 +90,14 @@ test2: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command: Should fail when writing 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -134,13 +106,12 @@ test2: printf("WRITESAME16 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("Writesame16 0blocks at LBA 2^63 ... "); task = iscsi_writesame16_sync(iscsi, lun, buf, block_size, 0x8000000000000000, 0, 0, 0, 0, 0, 0, 0); @@ -148,14 +119,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command: Should fail when writing 0blocks at 2^63\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -164,13 +135,12 @@ test3: printf("WRITESAME16 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Writesame16 0blocks at LBA -1 ... "); task = iscsi_writesame16_sync(iscsi, lun, buf, block_size, -1, 0, 0, 0, 0, 0, 0, 0); @@ -178,14 +148,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command: Should fail when writing 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -194,14 +164,12 @@ test4: printf("WRITESAME16 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0200_read16_simple.c b/test-tool/0200_read16_simple.c index 923416e..486c516 100644 --- a/test-tool/0200_read16_simple.c +++ b/test-tool/0200_read16_simple.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0200_read16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0200_read16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size, num_blocks; printf("0200_read16_simple:\n"); printf("===================\n"); @@ -44,31 +42,6 @@ int T0200_read16_simple(const char *initiator, const char *url, int data_loss _U return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - num_blocks = rc10->lba; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0201_read16_rdprotect.c b/test-tool/0201_read16_rdprotect.c index 7f3df55..707ba44 100644 --- a/test-tool/0201_read16_rdprotect.c +++ b/test-tool/0201_read16_rdprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0201_read16_rdprotect(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0201_read16_rdprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; printf("0201_read16_rdprotect:\n"); printf("======================\n"); @@ -43,37 +41,6 @@ int T0201_read16_rdprotect(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); - printf("Read16 with RDPROTECT "); for (i = 1; i <= 7; i++) { diff --git a/test-tool/0202_read16_flags.c b/test-tool/0202_read16_flags.c index c006eb4..66e077a 100644 --- a/test-tool/0202_read16_flags.c +++ b/test-tool/0202_read16_flags.c @@ -20,14 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0202_read16_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0202_read16_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; int ret = 0, lun; - uint32_t block_size; printf("0202_read16_flags:\n"); printf("==================\n"); @@ -65,30 +63,6 @@ int T0202_read16_flags(const char *initiator, const char *url, int data_loss _U_ return -2; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - scsi_free_scsi_task(task); - printf("Read16 with DPO "); task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0); diff --git a/test-tool/0203_read16_0blocks.c b/test-tool/0203_read16_0blocks.c index 4528273..cae7984 100644 --- a/test-tool/0203_read16_0blocks.c +++ b/test-tool/0203_read16_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0203_read16_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0203_read16_0blocks:\n"); printf("====================\n"); @@ -47,31 +44,6 @@ int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - printf("READ16 0blocks at LBA:0 ... "); task = iscsi_read16_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0); @@ -79,34 +51,33 @@ int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _ printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("READ16 0blocks at LBA: ... "); task = iscsi_read16_sync(iscsi, lun, num_blocks + 1, 0, 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 test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: Should fail when reading 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -115,27 +86,26 @@ test2: printf("READ16 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("READ16 0blocks at LBA 2^63 ... "); task = iscsi_read16_sync(iscsi, lun, 0x8000000000000000, 0, 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 test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: Should fail when reading 0blocks at 2^63\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -144,27 +114,26 @@ test3: printf("READ16 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("READ16 0blocks at LBA -1 ... "); task = iscsi_read16_sync(iscsi, lun, -1, 0, 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 test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: Should fail when reading 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -173,15 +142,12 @@ test4: printf("READ16 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0204_read16_beyondeol.c b/test-tool/0204_read16_beyondeol.c index b81ddec..675029c 100644 --- a/test-tool/0204_read16_beyondeol.c +++ b/test-tool/0204_read16_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0204_read16_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0204_read16_beyond_eol:\n"); printf("=======================\n"); @@ -46,31 +43,6 @@ int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0210_read12_simple.c b/test-tool/0210_read12_simple.c index 2c8d0fc..63b0650 100644 --- a/test-tool/0210_read12_simple.c +++ b/test-tool/0210_read12_simple.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0210_read12_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0210_read12_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size, num_blocks; printf("0210_read12_simple:\n"); printf("===================\n"); @@ -44,31 +42,6 @@ int T0210_read12_simple(const char *initiator, const char *url, int data_loss _U return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - num_blocks = rc10->lba; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0211_read12_rdprotect.c b/test-tool/0211_read12_rdprotect.c index 6a9d9fa..600ec7e 100644 --- a/test-tool/0211_read12_rdprotect.c +++ b/test-tool/0211_read12_rdprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0211_read12_rdprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; printf("0211_read12_rdprotect:\n"); printf("======================\n"); @@ -43,37 +41,6 @@ int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); - printf("Read12 with RDPROTECT "); for (i = 1; i <= 7; i++) { @@ -97,6 +64,7 @@ int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss } printf("[OK]\n"); + finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0212_read12_flags.c b/test-tool/0212_read12_flags.c index 71f11b7..a67f129 100644 --- a/test-tool/0212_read12_flags.c +++ b/test-tool/0212_read12_flags.c @@ -20,14 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0212_read12_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0212_read12_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; int ret = 0, lun; - uint32_t block_size; printf("0212_read12_flags:\n"); printf("==================\n"); @@ -65,30 +63,6 @@ int T0212_read12_flags(const char *initiator, const char *url, int data_loss _U_ return -2; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - scsi_free_scsi_task(task); - printf("Read12 with DPO "); task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0); diff --git a/test-tool/0213_read12_0blocks.c b/test-tool/0213_read12_0blocks.c index d07d952..0685626 100644 --- a/test-tool/0213_read12_0blocks.c +++ b/test-tool/0213_read12_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0213_read12_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0213_read12_0blocks:\n"); printf("====================\n"); @@ -48,31 +45,6 @@ int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss _ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - printf("READ12 0blocks at LBA:0 ... "); task = iscsi_read12_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0); @@ -80,39 +52,38 @@ int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss _ printf("[FAILED]\n"); printf("Failed to send READ12 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)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("READ12 0blocks at one block beyond ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } task = iscsi_read12_sync(iscsi, lun, num_blocks + 1, 0, 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 test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ12 command: Should fail when reading 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -121,32 +92,31 @@ test2: printf("READ12 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("READ12 0blocks at LBA 2^31 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test4; + goto finished; } task = iscsi_read12_sync(iscsi, lun, 0x80000000, 0, 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 test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ12 command: Should fail when reading 0blocks at 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -155,32 +125,31 @@ test3: printf("READ12 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("READ12 0blocks at LBA -1 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test5; + goto finished; } task = iscsi_read12_sync(iscsi, lun, -1, 0, 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 test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ12 command: Should fail when reading 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -189,15 +158,12 @@ test4: printf("READ12 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0214_read12_beyondeol.c b/test-tool/0214_read12_beyondeol.c index aee94f1..49bc0b1 100644 --- a/test-tool/0214_read12_beyondeol.c +++ b/test-tool/0214_read12_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0214_read12_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0214_read12_beyond_eol:\n"); printf("=======================\n"); @@ -47,31 +44,6 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - - ret = 0; @@ -89,100 +61,99 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ12 command should fail when reading beyond end of device\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + 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. Sense:%s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); - test2: /* read 1 - 256 blocks at LBA 2^31 */ printf("Reading 1-256 blocks at LBA 2^31 ... "); if (num_blocks >= 0xffffffff) { printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } for (i = 2; i <= 257; i++) { task = iscsi_read12_sync(iscsi, lun, 0x80000000U, 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 test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ12 command should fail when reading from LBA 2^31\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + 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. Sense:%s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } 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; + goto finished; } 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; + 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++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + 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. Sense:%s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: + finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0220_write16_simple.c b/test-tool/0220_write16_simple.c index 6d705ec..41fb2e7 100644 --- a/test-tool/0220_write16_simple.c +++ b/test-tool/0220_write16_simple.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0220_write16_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0220_write16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 256]; printf("0220_write16_simple:\n"); @@ -46,30 +43,6 @@ int T0220_write16_simple(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/0221_write16_wrprotect.c b/test-tool/0221_write16_wrprotect.c index abb5854..fe54d1c 100644 --- a/test-tool/0221_write16_wrprotect.c +++ b/test-tool/0221_write16_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0221_write16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0221_write16_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0221_write16_wrprotect:\n"); @@ -44,37 +42,6 @@ int T0221_write16_wrprotect(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0222_write16_flags.c b/test-tool/0222_write16_flags.c index 9e4b818..1eacb65 100644 --- a/test-tool/0222_write16_flags.c +++ b/test-tool/0222_write16_flags.c @@ -20,14 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0222_write16_flags(const char *initiator, const char *url, int data_loss, int show_info) +int T0222_write16_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; int ret = 0, lun; - uint32_t block_size; unsigned char data[4096 * 256]; printf("0222_write16_flags:\n"); @@ -66,30 +64,6 @@ int T0222_write16_flags(const char *initiator, const char *url, int data_loss, i return -2; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - scsi_free_scsi_task(task); - printf("Write16 with DPO "); task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); diff --git a/test-tool/0223_write16_0blocks.c b/test-tool/0223_write16_0blocks.c index 9740d28..8a59d46 100644 --- a/test-tool/0223_write16_0blocks.c +++ b/test-tool/0223_write16_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss, int show_info) +int T0223_write16_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0223_write16_0blocks:\n"); printf("====================\n"); @@ -47,31 +44,6 @@ int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -85,34 +57,33 @@ int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss, printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("WRITE16 0blocks at one block beyond ... "); task = iscsi_write16_sync(iscsi, lun, num_blocks + 1, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE16 command: Should fail when writing 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -121,26 +92,26 @@ test2: printf("WRITE16 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: + printf("WRITE16 0blocks at LBA 2^63 ... "); task = iscsi_write16_sync(iscsi, lun, 0x8000000000000000, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE16 command: Should fail when writing 0blocks at 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -149,27 +120,26 @@ test3: printf("WRITE16 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("WRITE16 0blocks at LBA -1 ... "); task = iscsi_write16_sync(iscsi, lun, -1, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE16 command: Should fail when writing 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -178,14 +148,12 @@ test4: printf("WRITE16 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0224_write16_beyondeol.c b/test-tool/0224_write16_beyondeol.c index c588190..a4cd8b9 100644 --- a/test-tool/0224_write16_beyondeol.c +++ b/test-tool/0224_write16_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0224_write16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0224_write16_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 258]; printf("0224_write16_beyond_eol:\n"); @@ -45,29 +42,6 @@ int T0224_write16_beyondeol(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/0230_write12_simple.c b/test-tool/0230_write12_simple.c index 7ba45ea..4244f39 100644 --- a/test-tool/0230_write12_simple.c +++ b/test-tool/0230_write12_simple.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0230_write12_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0230_write12_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 256]; printf("0230_write12_simple:\n"); @@ -46,30 +43,6 @@ int T0230_write12_simple(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/0231_write12_wrprotect.c b/test-tool/0231_write12_wrprotect.c index 6008f49..1503c47 100644 --- a/test-tool/0231_write12_wrprotect.c +++ b/test-tool/0231_write12_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0231_write12_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0231_write12_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0231_write12_wrprotect:\n"); @@ -44,37 +42,6 @@ int T0231_write12_wrprotect(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0232_write12_flags.c b/test-tool/0232_write12_flags.c index 2e6434f..2b98b20 100644 --- a/test-tool/0232_write12_flags.c +++ b/test-tool/0232_write12_flags.c @@ -20,14 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0232_write12_flags(const char *initiator, const char *url, int data_loss, int show_info) +int T0232_write12_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; int ret = 0, lun; - uint32_t block_size; unsigned char data[4096]; printf("0232_write12_flags:\n"); @@ -66,30 +64,6 @@ int T0232_write12_flags(const char *initiator, const char *url, int data_loss, i return -2; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - scsi_free_scsi_task(task); - printf("Write12 with DPO "); task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); diff --git a/test-tool/0233_write12_0blocks.c b/test-tool/0233_write12_0blocks.c index 412cdd5..14882af 100644 --- a/test-tool/0233_write12_0blocks.c +++ b/test-tool/0233_write12_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss, int show_info) +int T0233_write12_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0233_write12_0blocks:\n"); printf("====================\n"); @@ -47,30 +44,6 @@ int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -85,39 +58,38 @@ int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss, printf("[FAILED]\n"); printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("WRITE12 0blocks at one block beyond ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } task = iscsi_write12_sync(iscsi, lun, num_blocks + 1, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE12 command: Should fail when writing 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -126,31 +98,31 @@ test2: printf("WRITE12 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: + printf("WRITE12 0blocks at LBA 2^31 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test4; + goto finished; } task = iscsi_write12_sync(iscsi, lun, 0x80000000, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE12 command: Should fail when writing 0blocks at 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -159,32 +131,31 @@ test3: printf("WRITE12 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("WRITE12 0blocks at LBA -1 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test5; + goto finished; } task = iscsi_write12_sync(iscsi, lun, -1, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE12 command: Should fail when writing 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -193,14 +164,12 @@ test4: printf("WRITE12 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0234_write12_beyondeol.c b/test-tool/0234_write12_beyondeol.c index eb6503a..955f00c 100644 --- a/test-tool/0234_write12_beyondeol.c +++ b/test-tool/0234_write12_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0234_write12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0234_write12_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 258]; printf("0234_write12_beyond_eol:\n"); @@ -46,30 +43,6 @@ int T0234_write12_beyondeol(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0240_prefetch10_simple.c b/test-tool/0240_prefetch10_simple.c index 163594a..352d378 100644 --- a/test-tool/0240_prefetch10_simple.c +++ b/test-tool/0240_prefetch10_simple.c @@ -20,13 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0240_prefetch10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0240_prefetch10_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0240_prefetch10_simple:\n"); printf("===================\n"); @@ -44,29 +41,6 @@ int T0240_prefetch10_simple(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - ret = 0; /* prefetch the first 0 - 256 blocks at the start of the LUN */ diff --git a/test-tool/0241_prefetch10_flags.c b/test-tool/0241_prefetch10_flags.c index c4c2a23..a3ec6b2 100644 --- a/test-tool/0241_prefetch10_flags.c +++ b/test-tool/0241_prefetch10_flags.c @@ -20,11 +20,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0241_prefetch10_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; printf("0241_prefetch10_flags:\n"); @@ -43,28 +41,6 @@ int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0242_prefetch10_beyondeol.c b/test-tool/0242_prefetch10_beyondeol.c index c6edea9..7928834 100644 --- a/test-tool/0242_prefetch10_beyondeol.c +++ b/test-tool/0242_prefetch10_beyondeol.c @@ -20,13 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0242_prefetch10_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0242_prefetch10_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0242_prefetch10_beyondeol:\n"); printf("===================\n"); @@ -47,28 +44,6 @@ int T0242_prefetch10_beyondeol(const char *initiator, const char *url, int data_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0243_prefetch10_0blocks.c b/test-tool/0243_prefetch10_0blocks.c index cfaf1c4..9b7c930 100644 --- a/test-tool/0243_prefetch10_0blocks.c +++ b/test-tool/0243_prefetch10_0blocks.c @@ -20,13 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0243_prefetch10_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0243_prefetch10_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; - uint64_t num_blocks; printf("0243_prefetch10_0blocks:\n"); printf("===================\n"); @@ -47,28 +44,6 @@ int T0243_prefetch10_0blocks(const char *initiator, const char *url, int data_lo return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0250_prefetch16_simple.c b/test-tool/0250_prefetch16_simple.c index cc9dd98..db2b071 100644 --- a/test-tool/0250_prefetch16_simple.c +++ b/test-tool/0250_prefetch16_simple.c @@ -20,13 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0250_prefetch16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0250_prefetch16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0250_prefetch16_simple:\n"); printf("===================\n"); @@ -44,29 +41,6 @@ int T0250_prefetch16_simple(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - ret = 0; /* prefetch the first 0 - 256 blocks at the start of the LUN */ diff --git a/test-tool/0251_prefetch16_flags.c b/test-tool/0251_prefetch16_flags.c index 5d62dae..f9fcb93 100644 --- a/test-tool/0251_prefetch16_flags.c +++ b/test-tool/0251_prefetch16_flags.c @@ -20,11 +20,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0251_prefetch16_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; printf("0251_prefetch16_flags:\n"); @@ -43,28 +41,6 @@ int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0252_prefetch16_beyondeol.c b/test-tool/0252_prefetch16_beyondeol.c index a3fc6a4..d218e7c 100644 --- a/test-tool/0252_prefetch16_beyondeol.c +++ b/test-tool/0252_prefetch16_beyondeol.c @@ -20,13 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0252_prefetch16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0252_prefetch16_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0252_prefetch16_beyondeol:\n"); printf("===================\n"); @@ -46,29 +43,6 @@ int T0252_prefetch16_beyondeol(const char *initiator, const char *url, int data_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - ret = 0; diff --git a/test-tool/0253_prefetch16_0blocks.c b/test-tool/0253_prefetch16_0blocks.c index 5a62467..faa25b3 100644 --- a/test-tool/0253_prefetch16_0blocks.c +++ b/test-tool/0253_prefetch16_0blocks.c @@ -20,13 +20,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0253_prefetch16_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0253_prefetch16_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; - uint64_t num_blocks; printf("0253_prefetch16_0blocks:\n"); printf("===================\n"); @@ -46,29 +43,6 @@ int T0253_prefetch16_0blocks(const char *initiator, const char *url, int data_lo return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - ret = 0; diff --git a/test-tool/0260_get_lba_status_simple.c b/test-tool/0260_get_lba_status_simple.c index e4b3228..753a2ca 100644 --- a/test-tool/0260_get_lba_status_simple.c +++ b/test-tool/0260_get_lba_status_simple.c @@ -20,13 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0260_get_lba_status_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0260_get_lba_status_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, lun; - uint64_t num_blocks; printf("0260_get_lba_status_simple:\n"); printf("===================\n"); @@ -72,8 +71,6 @@ int T0260_get_lba_status_simple(const char *initiator, const char *url, int data goto finished; } - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0264_get_lba_status_beyondeol.c b/test-tool/0264_get_lba_status_beyondeol.c index 3fa39e0..0dd6df6 100644 --- a/test-tool/0264_get_lba_status_beyondeol.c +++ b/test-tool/0264_get_lba_status_beyondeol.c @@ -20,13 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0264_get_lba_status_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0264_get_lba_status_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, lun; - uint64_t num_blocks; printf("0264_get_lba_status_beyondeol:\n"); printf("==============================\n"); @@ -70,9 +69,6 @@ int T0264_get_lba_status_beyondeol(const char *initiator, const char *url, int d scsi_free_scsi_task(task); goto finished; } - - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0270_verify16_simple.c b/test-tool/0270_verify16_simple.c index 2401f7d..b7d0510 100644 --- a/test-tool/0270_verify16_simple.c +++ b/test-tool/0270_verify16_simple.c @@ -21,13 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0270_verify16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0270_verify16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0270_verify16_simple:\n"); @@ -45,29 +43,6 @@ int T0270_verify16_simple(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0271_verify16_mismatch.c b/test-tool/0271_verify16_mismatch.c index d0384ed..24d3924 100644 --- a/test-tool/0271_verify16_mismatch.c +++ b/test-tool/0271_verify16_mismatch.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0271_verify16_mismatch(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0271_verify16_mismatch(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0271_verify16_mismatch:\n"); @@ -46,29 +44,6 @@ int T0271_verify16_mismatch(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0272_verify16_mismatch_no_cmp.c b/test-tool/0272_verify16_mismatch_no_cmp.c index 5feeae5..9583e69 100644 --- a/test-tool/0272_verify16_mismatch_no_cmp.c +++ b/test-tool/0272_verify16_mismatch_no_cmp.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0272_verify16_mismatch_no_cmp:\n"); @@ -47,30 +45,6 @@ int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url, int d return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - - buf = malloc(256 * block_size); if (buf == NULL) { printf("Failed to allocate buffer.\n"); diff --git a/test-tool/0273_verify16_beyondeol.c b/test-tool/0273_verify16_beyondeol.c index 1f8ac4b..7ce0093 100644 --- a/test-tool/0273_verify16_beyondeol.c +++ b/test-tool/0273_verify16_beyondeol.c @@ -21,14 +21,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0273_verify16_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char *buf = NULL; printf("0273_verify16_beyond_eol:\n"); @@ -48,29 +44,6 @@ int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_lo return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); buf = malloc(256 * block_size); diff --git a/test-tool/0280_verify12_simple.c b/test-tool/0280_verify12_simple.c index 5b7e084..c220007 100644 --- a/test-tool/0280_verify12_simple.c +++ b/test-tool/0280_verify12_simple.c @@ -21,13 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0280_verify12_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0280_verify12_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0280_verify12_simple:\n"); @@ -45,29 +43,6 @@ int T0280_verify12_simple(const char *initiator, const char *url, int data_loss return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0281_verify12_mismatch.c b/test-tool/0281_verify12_mismatch.c index 5eb1140..12c405a 100644 --- a/test-tool/0281_verify12_mismatch.c +++ b/test-tool/0281_verify12_mismatch.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0281_verify12_mismatch(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0281_verify12_mismatch(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0281_verify12_mismatch:\n"); @@ -46,29 +44,6 @@ int T0281_verify12_mismatch(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0282_verify12_mismatch_no_cmp.c b/test-tool/0282_verify12_mismatch_no_cmp.c index 7179766..10a54af 100644 --- a/test-tool/0282_verify12_mismatch_no_cmp.c +++ b/test-tool/0282_verify12_mismatch_no_cmp.c @@ -22,13 +22,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity10 *rc10; int ret, i, lun; - uint32_t block_size; unsigned char *buf = NULL; printf("0282_verify12_mismatch_no_cmp:\n"); @@ -47,29 +45,6 @@ int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int d return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc10->block_size; - scsi_free_scsi_task(task); - buf = malloc(256 * block_size); if (buf == NULL) { diff --git a/test-tool/0283_verify12_beyondeol.c b/test-tool/0283_verify12_beyondeol.c index 6c220a9..4d14f34 100644 --- a/test-tool/0283_verify12_beyondeol.c +++ b/test-tool/0283_verify12_beyondeol.c @@ -21,14 +21,10 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T0283_verify12_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char *buf = NULL; printf("0283_verify12_beyond_eol:\n"); @@ -47,31 +43,6 @@ int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_lo return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - - ret = 0; diff --git a/test-tool/0290_write10_simple.c b/test-tool/0290_write10_simple.c index 2e75cd4..b5824be 100644 --- a/test-tool/0290_write10_simple.c +++ b/test-tool/0290_write10_simple.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0290_write10_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0290_write10_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint32_t num_blocks; unsigned char data[4096 * 256]; printf("0290_write10_simple:\n"); @@ -46,30 +43,6 @@ int T0290_write10_simple(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/0291_write10_wrprotect.c b/test-tool/0291_write10_wrprotect.c index 48722e8..411317f 100644 --- a/test-tool/0291_write10_wrprotect.c +++ b/test-tool/0291_write10_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0291_write10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0291_write10_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0291_write10_wrprotect:\n"); @@ -44,36 +42,6 @@ int T0291_write10_wrprotect(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/0292_write10_flags.c b/test-tool/0292_write10_flags.c index 1f22c00..31a85ac 100644 --- a/test-tool/0292_write10_flags.c +++ b/test-tool/0292_write10_flags.c @@ -20,14 +20,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0292_write10_flags(const char *initiator, const char *url, int data_loss, int show_info) +int T0292_write10_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; int ret = 0, lun; - uint32_t block_size; unsigned char data[4096]; printf("0292_write10_flags:\n"); @@ -66,30 +64,6 @@ int T0292_write10_flags(const char *initiator, const char *url, int data_loss, i return -2; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - scsi_free_scsi_task(task); - printf("Write10 with DPO "); task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); diff --git a/test-tool/0293_write10_0blocks.c b/test-tool/0293_write10_0blocks.c index e2998c2..9b6aaea 100644 --- a/test-tool/0293_write10_0blocks.c +++ b/test-tool/0293_write10_0blocks.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss, int show_info) +int T0293_write10_0blocks(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, lun; - uint32_t block_size; - uint64_t num_blocks; printf("0293_write10_0blocks:\n"); printf("====================\n"); @@ -47,30 +44,6 @@ int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -85,39 +58,38 @@ int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss, printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: printf("WRITE10 0blocks at one block beyond ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } task = iscsi_write10_sync(iscsi, lun, num_blocks + 1, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command: Should fail when writing 0blocks beyond end\n"); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -126,31 +98,31 @@ test2: printf("WRITE10 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: + printf("WRITE10 0blocks at LBA:2^31 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test4; + goto finished; } task = iscsi_write10_sync(iscsi, lun, 0x80000000, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command: Should fail when writing 0blocks at 2^31\n"); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -159,32 +131,31 @@ test3: printf("WRITE10 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("WRITE10 0blocks at LBA:-1 ... "); if (num_blocks > 0x80000000) { printf("[SKIPPED]\n"); printf("LUN is too big, skipping test\n"); - goto test5; + goto finished; } task = iscsi_write10_sync(iscsi, lun, -1, NULL, 0, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command: Should fail when writing 0blocks at -1\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -193,14 +164,12 @@ test4: printf("WRITE10 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0294_write10_beyondeol.c b/test-tool/0294_write10_beyondeol.c index e736382..209acc9 100644 --- a/test-tool/0294_write10_beyondeol.c +++ b/test-tool/0294_write10_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0294_write10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0294_write10_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint32_t num_blocks; unsigned char data[4096 * 258]; printf("0294_write10_beyond_eol:\n"); @@ -46,29 +43,6 @@ int T0294_write10_beyondeol(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/0300_readonly.c b/test-tool/0300_readonly.c index 74759f7..fbb2b7d 100644 --- a/test-tool/0300_readonly.c +++ b/test-tool/0300_readonly.c @@ -20,7 +20,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0300_readonly(const char *initiator, const char *url, int data_loss, int show_info) +int T0300_readonly(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -28,7 +28,6 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh struct scsi_inquiry_standard *inq; struct scsi_mode_sense *ms; int ret, lun; - uint32_t block_size; unsigned char data[4096]; int full_size; int lbpme; @@ -80,7 +79,6 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh scsi_free_scsi_task(task); goto finished; } - block_size = rc16->block_length; lbpme = rc16->lbpme; scsi_free_scsi_task(task); @@ -151,231 +149,216 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITE10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: - /* Write one block at lba 0 */ printf("WRITE12 to LUN 0 ... "); task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE12 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITE12 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: - /* Write one block at lba 0 */ printf("WRITE16 to LUN 0 ... "); task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE16 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITE16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: - /* Write one block at lba 0 */ printf("WRITESAME10 to LUN 0 ... "); task = iscsi_writesame10_sync(iscsi, lun, data, block_size, 0, 1, 0, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITESAME10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - /* Write one block at lba 0 */ printf("WRITESAME16 to LUN 0 ... "); task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test6; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITESAME16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test6; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - - /* UNMAP one block at lba 0 */ printf("WRITESAME10 to UNMAP LUN 0 ... "); if (lbpme == 0) { printf("LUN is not thin-provisioned. [SKIPPED]\n"); - goto test7; + goto finished; } task = iscsi_writesame10_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME10 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITESAME10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test7: - /* UNMAP one block at lba 0 */ printf("WRITESAME16 to UNMAP LUN 0 ... "); if (lbpme == 0) { printf("LUN is not thin-provisioned. [SKIPPED]\n"); - goto test8; + goto finished; } task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test8; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITESAME16 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test8; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITESAME16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test8; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test8: - /* UNMAP one block at lba 0 */ printf("UNMAP LUN 0 ... "); if (lbpme == 0) { printf("LUN is not thin-provisioned. [SKIPPED]\n"); - goto test9; + goto finished; } list[0].lba = 0; list[0].num = 1; @@ -383,60 +366,57 @@ test8: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test9; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("UNMAP command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test9; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("UNMAP failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test9; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test9: - /* Write one block at lba 0 */ printf("WRITEVERIFY10 to LUN 0 ... "); task = iscsi_writeverify10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test10; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test10; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITEVERIFY10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test10; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test10: /* Write one block at lba 0 */ printf("WRITEVERIFY12 to LUN 0 ... "); @@ -444,29 +424,28 @@ test10: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test11; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test11; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITEVERIFY12 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test11; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test11: /* Write one block at lba 0 */ printf("WRITEVERIFY16 to LUN 0 ... "); @@ -474,58 +453,57 @@ test11: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test12; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test12; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("WRITEVERIFY16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test12; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test12: + /* Write one block at lba 0 */ printf("COMPAREWRITE to LUN 0 ... "); task = iscsi_compareandwrite_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test13; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test13; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("COMPAREANDWRITE failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test13; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test13: /* Write one block at lba 0 */ printf("ORWRITE to LUN 0 ... "); @@ -533,30 +511,28 @@ test13: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test14; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE command should fail when writing to readonly devices\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test14; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_DATA_PROTECTION || task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) { printf("[FAILED]\n"); printf("ORWRITE failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test14; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test14: - finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0310_writeverify10_simple.c b/test-tool/0310_writeverify10_simple.c index 1938dac..865bca7 100644 --- a/test-tool/0310_writeverify10_simple.c +++ b/test-tool/0310_writeverify10_simple.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0310_writeverify10_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0310_writeverify10_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint32_t num_blocks; unsigned char data[4096 * 256]; printf("0310_writeverify10_simple:\n"); @@ -46,30 +43,6 @@ int T0310_writeverify10_simple(const char *initiator, const char *url, int data_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,22 +60,21 @@ int T0310_writeverify10_simple(const char *initiator, const char *url, int data_ if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* write the last 1 - 256 blocks at the end of the LUN */ printf("Writing last 1-256 blocks ... "); for (i = 1; i <= 256; i++) { @@ -110,23 +82,21 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0311_writeverify10_wrprotect.c b/test-tool/0311_writeverify10_wrprotect.c index 7eb8c38..5f4fbfb 100644 --- a/test-tool/0311_writeverify10_wrprotect.c +++ b/test-tool/0311_writeverify10_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0311_writeverify10_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0311_writeverify10_wrprotect:\n"); @@ -44,36 +42,6 @@ int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int da return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,23 +55,22 @@ int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int da if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) { printf("[FAILED]\n"); printf("WRITEVERIFY10 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0314_writeverify10_beyondeol.c b/test-tool/0314_writeverify10_beyondeol.c index d4f352c..3ec795d 100644 --- a/test-tool/0314_writeverify10_beyondeol.c +++ b/test-tool/0314_writeverify10_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0314_writeverify10_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint32_t num_blocks; unsigned char data[4096 * 258]; printf("0314_writeverify10_beyond_eol:\n"); @@ -49,29 +46,6 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -96,8 +70,8 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -111,9 +85,9 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -122,34 +96,33 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da printf("WRITEVERIFY10 failed but ascq was wrong. 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* read 1 - 256 blocks at lba 2^31 */ printf("Writing 1-256 blocks at LBA 2^31 ... "); if (num_blocks > 0x80000000) { printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } for (i = 1; i <= 256; i++) { task = iscsi_writeverify10_sync(iscsi, lun, 0x80000000, data, i * block_size, block_size, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -158,34 +131,33 @@ test2: printf("WRITEVERIFY10 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 1 - 256 blocks at lba -1 */ printf("Writing 1-256 blocks at LBA -1 ... "); if (num_blocks >= 0xffffffff) { printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } for (i = 1; i <= 256; i++) { task = iscsi_writeverify10_sync(iscsi, lun, 0xffffffff, data, i * block_size, block_size, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -194,13 +166,13 @@ test3: printf("WRITEVERIFY10 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: + /* read 2-256 blocks, all but one block beyond the eol */ printf("Writing 1-255 blocks beyond eol starting at last block ... "); for (i=2; i<=256; i++) { @@ -209,14 +181,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -225,15 +197,13 @@ test4: printf("WRITEVERIFY10 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0320_writeverify12_simple.c b/test-tool/0320_writeverify12_simple.c index c97d431..de8d877 100644 --- a/test-tool/0320_writeverify12_simple.c +++ b/test-tool/0320_writeverify12_simple.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0320_writeverify12_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0320_writeverify12_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint32_t num_blocks; unsigned char data[4096 * 256]; printf("0320_writeverify12_simple:\n"); @@ -46,30 +43,6 @@ int T0320_writeverify12_simple(const char *initiator, const char *url, int data_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,22 +60,21 @@ int T0320_writeverify12_simple(const char *initiator, const char *url, int data_ if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* write the last 1 - 256 blocks at the end of the LUN */ printf("Writing last 1-256 blocks ... "); for (i = 1; i <= 256; i++) { @@ -110,23 +82,21 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0321_writeverify12_wrprotect.c b/test-tool/0321_writeverify12_wrprotect.c index 38e2e84..f6ff6e1 100644 --- a/test-tool/0321_writeverify12_wrprotect.c +++ b/test-tool/0321_writeverify12_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0321_writeverify12_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0321_writeverify12_wrprotect:\n"); @@ -44,36 +42,6 @@ int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int da return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,23 +55,22 @@ int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int da if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) { printf("[FAILED]\n"); printf("WRITEVERIFY12 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0324_writeverify12_beyondeol.c b/test-tool/0324_writeverify12_beyondeol.c index 8af040d..086f09d 100644 --- a/test-tool/0324_writeverify12_beyondeol.c +++ b/test-tool/0324_writeverify12_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0324_writeverify12_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint32_t num_blocks; unsigned char data[4096 * 258]; printf("0324_writeverify12_beyond_eol:\n"); @@ -49,29 +46,6 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -96,8 +70,8 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -111,9 +85,9 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -122,34 +96,33 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da printf("WRITEVERIFY12 failed but ascq was wrong. 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* read 1 - 256 blocks at lba 2^31 */ printf("Writing 1-256 blocks at LBA 2^31 ... "); if (num_blocks > 0x80000000) { printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } for (i = 1; i <= 256; i++) { task = iscsi_writeverify12_sync(iscsi, lun, 0x80000000, data, i * block_size, block_size, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -158,34 +131,33 @@ test2: printf("WRITEVERIFY12 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 1 - 256 blocks at lba -1 */ printf("Writing 1-256 blocks at LBA -1 ... "); if (num_blocks >= 0xffffffff) { printf("LUN is too big, skipping test\n"); - goto test3; + goto finished; } for (i = 1; i <= 256; i++) { task = iscsi_writeverify12_sync(iscsi, lun, 0xffffffff, data, i * block_size, block_size, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -194,13 +166,13 @@ test3: printf("WRITEVERIFY12 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: + /* read 2-256 blocks, all but one block beyond the eol */ printf("Writing 1-255 blocks beyond eol starting at last block ... "); for (i=2; i<=256; i++) { @@ -209,14 +181,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -225,15 +197,13 @@ test4: printf("WRITEVERIFY12 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0330_writeverify16_simple.c b/test-tool/0330_writeverify16_simple.c index 6e5501a..0b0c624 100644 --- a/test-tool/0330_writeverify16_simple.c +++ b/test-tool/0330_writeverify16_simple.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0330_writeverify16_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0330_writeverify16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 256]; printf("0330_writeverify16_simple:\n"); @@ -46,30 +43,6 @@ int T0330_writeverify16_simple(const char *initiator, const char *url, int data_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,22 +60,21 @@ int T0330_writeverify16_simple(const char *initiator, const char *url, int data_ if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* write the last 1 - 256 blocks at the end of the LUN */ printf("Writing last 1-256 blocks ... "); for (i = 1; i <= 256; i++) { @@ -110,23 +82,21 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0331_writeverify16_wrprotect.c b/test-tool/0331_writeverify16_wrprotect.c index 7474e89..ab6498a 100644 --- a/test-tool/0331_writeverify16_wrprotect.c +++ b/test-tool/0331_writeverify16_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0331_writeverify16_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0331_writeverify16_wrprotect:\n"); @@ -44,36 +42,6 @@ int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int da return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,23 +55,22 @@ int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int da if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) { printf("[FAILED]\n"); printf("WRITEVERIFY16 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0334_writeverify16_beyondeol.c b/test-tool/0334_writeverify16_beyondeol.c index 3869619..1262806 100644 --- a/test-tool/0334_writeverify16_beyondeol.c +++ b/test-tool/0334_writeverify16_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0334_writeverify16_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 258]; printf("0334_writeverify16_beyond_eol:\n"); @@ -48,29 +45,6 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -88,8 +62,8 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -103,9 +77,9 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -114,13 +88,12 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da printf("WRITEVERIFY16 failed but ascq was wrong. 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* read 1 - 256 blocks at lba 2^63 */ printf("Writing 1-256 blocks at LBA 2^63 ... "); @@ -129,15 +102,15 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -146,13 +119,12 @@ test2: printf("WRITEVERIFY16 failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 1 - 256 blocks at lba -1 */ printf("Writing 1-256 blocks at LBA -1 ... "); @@ -161,15 +133,15 @@ test3: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -178,13 +150,13 @@ test3: printf("WRITEVERIFY16 failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: + /* read 2-256 blocks, all but one block beyond the eol */ printf("Writing 1-255 blocks beyond eol starting at last block ... "); for (i=2; i<=256; i++) { @@ -193,14 +165,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -209,15 +181,13 @@ test4: printf("WRITEVERIFY16 failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0340_compareandwrite_simple.c b/test-tool/0340_compareandwrite_simple.c index c84f45a..535542b 100644 --- a/test-tool/0340_compareandwrite_simple.c +++ b/test-tool/0340_compareandwrite_simple.c @@ -21,14 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0340_compareandwrite_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0340_compareandwrite_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 256]; printf("0340_compareandwrite_simple:\n"); @@ -47,31 +44,6 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -89,23 +61,23 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } memcpy(data, task->datain.data, i * block_size); scsi_free_scsi_task(task); @@ -114,8 +86,8 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -129,16 +101,15 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* write the last 1 - 255 blocks at the end of the LUN */ printf("Compare and write last 1-255 blocks ... "); for (i = 1; i < 256; i++) { @@ -146,23 +117,23 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } memcpy(data, task->datain.data, i * block_size); scsi_free_scsi_task(task); @@ -171,21 +142,20 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0341_compareandwrite_mismatch.c b/test-tool/0341_compareandwrite_mismatch.c index 884e7d9..ca5adc0 100644 --- a/test-tool/0341_compareandwrite_mismatch.c +++ b/test-tool/0341_compareandwrite_mismatch.c @@ -21,14 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int data_loss, int show_info) +int T0341_compareandwrite_mismatch(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 256]; printf("0341_compareandwrite_mismatch:\n"); @@ -47,30 +44,6 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -89,23 +62,23 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } memcpy(data, task->datain.data, i * block_size); scsi_free_scsi_task(task); @@ -117,8 +90,8 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -132,25 +105,24 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE successful. It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_MISCOMPARE || task->sense.ascq != SCSI_SENSE_ASCQ_MISCOMPARE_DURING_VERIFY) { printf("[FAILED]\n"); printf("COMPAREANDWRITE Failed with the wrong sense : %s(0x%02x)/%s(0x%04x). It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n", scsi_sense_key_str(task->sense.key), task->sense.key, scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* write the last 1 - 255 blocks at the end of the LUN */ printf("Compare and write last 1-255 blocks (data is not matching) ... "); for (i = 1; i < 256; i++) { @@ -158,23 +130,23 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } memcpy(data, task->datain.data, i * block_size); scsi_free_scsi_task(task); @@ -186,30 +158,29 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE successful. It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_MISCOMPARE || task->sense.ascq != SCSI_SENSE_ASCQ_MISCOMPARE_DURING_VERIFY) { printf("[FAILED]\n"); printf("COMPAREANDWRITE Failed with the wrong sense : %s(0x%02x)/%s(0x%04x). It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n", scsi_sense_key_str(task->sense.key), task->sense.key, scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0343_compareandwrite_beyondeol.c b/test-tool/0343_compareandwrite_beyondeol.c index 6c0c5e7..9451991 100644 --- a/test-tool/0343_compareandwrite_beyondeol.c +++ b/test-tool/0343_compareandwrite_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0343_compareandwrite_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 258]; printf("0343_compareandwrite_beyond_eol:\n"); @@ -48,30 +45,6 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -88,8 +61,8 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -103,9 +76,9 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -114,13 +87,12 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int printf("COMPAREANDWRITE failed but ascq was wrong. 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* read 1 - 255 blocks at lba 2^63 */ printf("Writing 1-255 blocks at LBA 2^63 ... "); @@ -129,15 +101,15 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -146,13 +118,12 @@ test2: printf("COMPAREANDWRITE failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 1 - 255 blocks at lba -1 */ printf("Writing 1-255 blocks at LBA -1 ... "); @@ -161,15 +132,15 @@ test3: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -178,13 +149,13 @@ test3: printf("COMPAREANDWRITE failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: + /* read 2-255 blocks, all but one block beyond the eol */ printf("Writing 1-255 blocks beyond eol starting at last block ... "); for (i = 2; i < 256; i++) { @@ -193,14 +164,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -209,15 +180,13 @@ test4: printf("COMPAREANDWRITE failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0350_orwrite_simple.c b/test-tool/0350_orwrite_simple.c index f12dea9..a9c6e95 100644 --- a/test-tool/0350_orwrite_simple.c +++ b/test-tool/0350_orwrite_simple.c @@ -21,14 +21,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0350_orwrite_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, j, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char r1data[4096 * 256]; unsigned char r2data[4096 * 256]; unsigned char ordata[4096 * 256]; @@ -49,30 +46,6 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -91,23 +64,23 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } memcpy(r1data, task->datain.data, i * block_size); memset(ordata, 0x5a, i * block_size); @@ -120,15 +93,15 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); @@ -136,31 +109,31 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (memcmp(r2data, task->datain.data, i * block_size)) { printf("[FAILED]\n"); printf("Blocks were not updated as expected.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); @@ -168,7 +141,6 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, printf("[OK]\n"); -test2: /* write the last 1 - 255 blocks at the end of the LUN */ printf("Orwrite last 1-255 blocks ... "); for (i = 1; i < 256; i++) { @@ -176,23 +148,23 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } memcpy(r1data, task->datain.data, i * block_size); memcpy(r1data, task->datain.data, i * block_size); @@ -206,53 +178,52 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); task = iscsi_read16_sync(iscsi, lun, num_blocks + 1 - i, 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++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->datain.data == NULL) { printf("[FAILED]\n"); printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (memcmp(r2data, task->datain.data, i * block_size)) { printf("[FAILED]\n"); printf("Blocks were not updated as expected.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0351_orwrite_wrprotect.c b/test-tool/0351_orwrite_wrprotect.c index 72b92fd..bc003aa 100644 --- a/test-tool/0351_orwrite_wrprotect.c +++ b/test-tool/0351_orwrite_wrprotect.c @@ -20,13 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_loss, int show_info) +int T0351_orwrite_wrprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret = 0, i, lun; - uint32_t block_size; unsigned char data[4096]; printf("0351_orwrite_wrprotect:\n"); @@ -44,36 +42,6 @@ int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - block_size = rc16->block_length; - - if(rc16->prot_en != 0) { - printf("device is formatted with protection information, skipping test\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -87,23 +55,22 @@ int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_los if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) { printf("[FAILED]\n"); printf("ORWRITE with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0354_orwrite_beyondeol.c b/test-tool/0354_orwrite_beyondeol.c index 26b5bd1..9483901 100644 --- a/test-tool/0354_orwrite_beyondeol.c +++ b/test-tool/0354_orwrite_beyondeol.c @@ -20,14 +20,11 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_loss, int show_info) +int T0354_orwrite_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint32_t block_size; - uint64_t num_blocks; unsigned char data[4096 * 258]; printf("0354_orwrite_beyondeol:\n"); @@ -48,30 +45,6 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -88,8 +61,8 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST @@ -103,9 +76,9 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -114,13 +87,12 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los printf("ORWRITE failed but ascq was wrong. 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; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: /* read 1 - 256 blocks at lba 2^63 */ printf("Writing 1-256 blocks at LBA 2^63 ... "); @@ -129,15 +101,15 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -146,13 +118,12 @@ test2: printf("ORWRITE failed but ascq was wrong. 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 test3; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test3: /* read 1 - 256 blocks at lba -1 */ printf("Writing 1-256 blocks at LBA -1 ... "); @@ -161,15 +132,15 @@ test3: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -178,13 +149,13 @@ test3: printf("ORWRITE failed but ascq was wrong. 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 test4; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test4: + /* read 2-256 blocks, all but one block beyond the eol */ printf("Writing 1-255 blocks beyond eol starting at last block ... "); for (i=2; i<=256; i++) { @@ -193,14 +164,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -209,15 +180,13 @@ test4: printf("ORWRITE failed but ascq was wrong. 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 test5; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test5: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0360_startstopunit_simple.c b/test-tool/0360_startstopunit_simple.c index 53d9a09..087755b 100644 --- a/test-tool/0360_startstopunit_simple.c +++ b/test-tool/0360_startstopunit_simple.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0360_startstopunit_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0360_startstopunit_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0361_startstopunit_pwrcnd.c b/test-tool/0361_startstopunit_pwrcnd.c index eb1e027..5b8ba8e 100644 --- a/test-tool/0361_startstopunit_pwrcnd.c +++ b/test-tool/0361_startstopunit_pwrcnd.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_loss, int show_info) +int T0361_startstopunit_pwrcnd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -92,13 +92,13 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_ if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); goto finished; } @@ -119,13 +119,13 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_ if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); goto finished; } diff --git a/test-tool/0362_startstopunit_noloej.c b/test-tool/0362_startstopunit_noloej.c index 695647f..96a45d0 100644 --- a/test-tool/0362_startstopunit_noloej.c +++ b/test-tool/0362_startstopunit_noloej.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_loss, int show_info) +int T0362_startstopunit_noloej(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -101,14 +101,14 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_ printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -120,7 +120,6 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_ } -test2: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -130,14 +129,14 @@ test2: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test3; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -149,7 +148,6 @@ test2: } -test3: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -159,14 +157,14 @@ test3: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test4; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -178,8 +176,6 @@ test3: } - -test4: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -189,14 +185,14 @@ test4: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test5; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -208,7 +204,6 @@ test4: } -test5: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -218,14 +213,14 @@ test5: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test6; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test6; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -237,7 +232,6 @@ test5: } -test6: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -247,14 +241,14 @@ test6: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test7; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -266,7 +260,6 @@ test6: } -test7: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -276,14 +269,14 @@ test7: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test8; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test8; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -295,7 +288,6 @@ test7: } -test8: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); @@ -305,14 +297,14 @@ test8: printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test9; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test9; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -324,7 +316,6 @@ test8: } -test9: /* in case the previous command did eject the media */ iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); diff --git a/test-tool/0370_nomedia.c b/test-tool/0370_nomedia.c index 32d6bf3..3f67ffa 100644 --- a/test-tool/0370_nomedia.c +++ b/test-tool/0370_nomedia.c @@ -21,14 +21,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0370_nomedia(const char *initiator, const char *url, int data_loss, int show_info) +int T0370_nomedia(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; int ret, lun, removable; - uint32_t block_size; int full_size; unsigned char buf[4096]; @@ -75,29 +73,6 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - /* See how big this inquiry data is */ task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); if (task == NULL || task->status != SCSI_STATUS_GOOD) { diff --git a/test-tool/0380_preventallow_simple.c b/test-tool/0380_preventallow_simple.c index 1ba38a1..466d398 100644 --- a/test-tool/0380_preventallow_simple.c +++ b/test-tool/0380_preventallow_simple.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0380_preventallow_simple(const char *initiator, const char *url, int data_loss, int show_info) +int T0380_preventallow_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -91,8 +91,8 @@ int T0380_preventallow_simple(const char *initiator, const char *url, int data_l if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -102,25 +102,22 @@ int T0380_preventallow_simple(const char *initiator, const char *url, int data_l if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -129,19 +126,15 @@ test2: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test3: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0381_preventallow_eject.c b/test-tool/0381_preventallow_eject.c index 30faa10..b4cc647 100644 --- a/test-tool/0381_preventallow_eject.c +++ b/test-tool/0381_preventallow_eject.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0381_preventallow_eject(const char *initiator, const char *url, int data_loss, int show_info) +int T0381_preventallow_eject(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -94,8 +94,8 @@ int T0381_preventallow_eject(const char *initiator, const char *url, int data_lo if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -105,45 +105,43 @@ int T0381_preventallow_eject(const char *initiator, const char *url, int data_lo if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: + printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test3: printf("Load the media again in case it was ejected ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } /* SBC doesnt really say anything about whether we can LOAD media when the prevent * flag is set @@ -151,16 +149,14 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -169,18 +165,14 @@ test4: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test5: - - finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0382_preventallow_itnexus_loss.c b/test-tool/0382_preventallow_itnexus_loss.c index 28957ea..944fbc4 100644 --- a/test-tool/0382_preventallow_itnexus_loss.c +++ b/test-tool/0382_preventallow_itnexus_loss.c @@ -21,8 +21,8 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_standard *inq; @@ -96,8 +96,8 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -107,37 +107,36 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: + printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test3: + printf("Tear down the IT_Nexus and create a new one ... "); iscsi_destroy_context(iscsi); iscsi = iscsi_context_login(initiator, url, &lun); @@ -155,29 +154,27 @@ test3: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have worked but it failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - printf("Load the media again in case it was ejected ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } /* SBC doesnt really say anything about whether we can LOAD media when the prevent * flag is set @@ -185,16 +182,14 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -203,16 +198,14 @@ test6: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0383_preventallow_target_warm_reset.c b/test-tool/0383_preventallow_target_warm_reset.c index 876121b..a4be3bc 100644 --- a/test-tool/0383_preventallow_target_warm_reset.c +++ b/test-tool/0383_preventallow_target_warm_reset.c @@ -37,7 +37,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, } -int T0383_preventallow_target_warm_reset(const char *initiator, const char *url, int data_loss, int show_info) +int T0383_preventallow_target_warm_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0384_preventallow_target_cold_reset.c b/test-tool/0384_preventallow_target_cold_reset.c index 2db377e..0873001 100644 --- a/test-tool/0384_preventallow_target_cold_reset.c +++ b/test-tool/0384_preventallow_target_cold_reset.c @@ -37,7 +37,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, } -int T0384_preventallow_target_cold_reset(const char *initiator, const char *url, int data_loss, int show_info) +int T0384_preventallow_target_cold_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0385_preventallow_lun_reset.c b/test-tool/0385_preventallow_lun_reset.c index 569f046..52f8048 100644 --- a/test-tool/0385_preventallow_lun_reset.c +++ b/test-tool/0385_preventallow_lun_reset.c @@ -37,7 +37,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, } -int T0385_preventallow_lun_reset(const char *initiator, const char *url, int data_loss, int show_info) +int T0385_preventallow_lun_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0386_preventallow_2_it_nexuses.c b/test-tool/0386_preventallow_2_it_nexuses.c index d077926..b1be112 100644 --- a/test-tool/0386_preventallow_2_it_nexuses.c +++ b/test-tool/0386_preventallow_2_it_nexuses.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int data_loss, int show_info) +int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct iscsi_context *iscsi2 = NULL; @@ -98,8 +98,8 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -109,9 +109,9 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); @@ -125,79 +125,74 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi2)); - ret++; - goto test2; + ret = -1; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: + printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test3: + printf("Remove the PREVENT on this IT_Nexus ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } - scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test5: - printf("Load the media again in case it was ejected ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } /* SBC doesnt really say anything about whether we can LOAD media when the prevent * flag is set @@ -205,16 +200,14 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -223,9 +216,9 @@ test6: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } } scsi_free_scsi_task(task); @@ -234,14 +227,12 @@ test6: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi2)); - ret++; - goto test7; + ret = -1; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c index b3e3357..72de152 100644 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ b/test-tool/0390_mandatory_opcodes_sbc.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data_loss, int show_info) +int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; @@ -29,7 +29,6 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data struct scsi_inquiry_standard *inq; int ret = 0, lun, sccs, encserv, lbpme; unsigned char data[4096]; - uint32_t block_size; int full_size; printf("0390_mandatory_opcodes_sbc:\n"); @@ -86,7 +85,6 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data scsi_free_scsi_task(task); goto finished; } - block_size = rc16->block_length; lbpme = rc16->lbpme; scsi_free_scsi_task(task); @@ -133,247 +131,212 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data printf("Test FORMAT UNIT ... "); printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test2; -test2: printf("Test INQUIRY ... "); task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send INQUIRY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("INQUIRY command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto test3; + ret = -1; + } else { + printf("[OK]\n"); } scsi_free_scsi_task(task); - printf("[OK]\n"); -test3: printf("Test MAINTENANCE IN ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test4; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test4; -test4: printf("Test MAINTENANCE OUT ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test5; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test5; -test5: + printf("Test READ CAPACITY10 ... "); task = iscsi_readcapacity10_sync(iscsi, lun,0 ,0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ CAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ CAPACITY10 command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto test6; + ret = -1; + } else { + printf("[OK]\n"); } scsi_free_scsi_task(task); - printf("[OK]\n"); -test6: printf("Test READ CAPACITY16 ... "); task = iscsi_readcapacity16_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ CAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READ CAPACITY16 command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto test7; + ret = -1; + } else { + printf("[OK]\n"); } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: printf("Test RECEIVE DIAGNOSTIC RESULT ... "); if (encserv == 0) { printf("[ENCSERV == 0, SKIPPING TEST]\n"); - goto test8; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test8; -test8: printf("Test REDUNDANCY GROUP IN ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test9; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test9; -test9: printf("Test REDUNDANCY GROUP OUT ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test10; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test10; -test10: + printf("Test REPORT LUNS ... "); task = iscsi_reportluns_sync(iscsi, 0, 64); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send REPORT LUNS command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test11; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("REPORT LUNS command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto test11; + ret = -1; + } else { + printf("[OK]\n"); } scsi_free_scsi_task(task); - printf("[OK]\n"); -test11: printf("Test REQUEST SENSE ... "); printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test12; -test12: printf("Test SEND DIAGNOSTIC ... "); printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test13; -test13: + printf("Test SPARE IN ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test14; + goto finished; } printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test14; -test14: printf("Test SPARE OUT ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test15; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test15; -test15: + printf("Test TEST UNIT READY.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; + if (testunitready(iscsi, lun) == -1) { + ret = -1; } printf("Test UNMAP ... "); if (lbpme == 0) { printf("[LBPME == 0, SKIPPING TEST]\n"); - goto test17; - } - task = iscsi_unmap_sync(iscsi, lun, 0, 0, NULL, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test17; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("UNMAP command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + } else { + task = iscsi_unmap_sync(iscsi, lun, 0, 0, NULL, 0); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi)); + ret = -1; + goto finished; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("UNMAP command: failed with sense %s\n", iscsi_get_error(iscsi)); + ret = -1; + } else { + printf("[OK]\n"); + } scsi_free_scsi_task(task); - goto test17; } - scsi_free_scsi_task(task); - printf("[OK]\n"); -test17: printf("Test VOLUME SET IN ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test18; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test18; -test18: printf("Test VOLUME SET OUT ... "); if (sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); - goto test19; + } else { + printf("[TEST NOT IMPLEMENTED YET]\n"); } - printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test19; -test19: + printf("Test WRITE SAME16 ... "); if (lbpme == 0) { printf("[LBPME == 0, SKIPPING TEST]\n"); - goto test20; - } - task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE SAME16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test20; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE SAME16 command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + } else { + task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send WRITE SAME16 command: %s\n", iscsi_get_error(iscsi)); + ret = -1; + goto finished; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("WRITE SAME16 command: failed with sense %s\n", iscsi_get_error(iscsi)); + ret = -1; + } else { + printf("[OK]\n"); + } scsi_free_scsi_task(task); - goto test20; } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -test20: printf("Test WRITE SAME32 ... "); printf("[TEST NOT IMPLEMENTED YET]\n"); - goto test21; -test21: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0400_inquiry_basic.c b/test-tool/0400_inquiry_basic.c index 9e8cc71..ac9afdb 100644 --- a/test-tool/0400_inquiry_basic.c +++ b/test-tool/0400_inquiry_basic.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss _U_, - int show_info) +int T0400_inquiry_basic(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0401_inquiry_alloclen.c b/test-tool/0401_inquiry_alloclen.c index b38f215..c56c941 100644 --- a/test-tool/0401_inquiry_alloclen.c +++ b/test-tool/0401_inquiry_alloclen.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss _U_, - int show_info) +int T0401_inquiry_alloclen(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0402_inquiry_evpd.c b/test-tool/0402_inquiry_evpd.c index d33cbf5..b77c579 100644 --- a/test-tool/0402_inquiry_evpd.c +++ b/test-tool/0402_inquiry_evpd.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss _U_, - int show_info) +int T0402_inquiry_evpd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0403_inquiry_supported_vpd.c b/test-tool/0403_inquiry_supported_vpd.c index 1660c14..9f0e239 100644 --- a/test-tool/0403_inquiry_supported_vpd.c +++ b/test-tool/0403_inquiry_supported_vpd.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0403_inquiry_supported_vpd(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T0403_inquiry_supported_vpd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0404_inquiry_all_reported_vpd.c b/test-tool/0404_inquiry_all_reported_vpd.c index f37d6db..56d8e03 100644 --- a/test-tool/0404_inquiry_all_reported_vpd.c +++ b/test-tool/0404_inquiry_all_reported_vpd.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/0410_readtoc_basic.c b/test-tool/0410_readtoc_basic.c index 2f84452..82bc84a 100644 --- a/test-tool/0410_readtoc_basic.c +++ b/test-tool/0410_readtoc_basic.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss _U_, - int show_info) +int T0410_readtoc_basic(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task, *task1; diff --git a/test-tool/0420_reserve6_simple.c b/test-tool/0420_reserve6_simple.c index 2a60077..6553141 100644 --- a/test-tool/0420_reserve6_simple.c +++ b/test-tool/0420_reserve6_simple.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss _U_, - int show_info) +int T0420_reserve6_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; diff --git a/test-tool/0421_reserve6_lun_reset.c b/test-tool/0421_reserve6_lun_reset.c index 34839c9..356c460 100644 --- a/test-tool/0421_reserve6_lun_reset.c +++ b/test-tool/0421_reserve6_lun_reset.c @@ -37,8 +37,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, mgmt_task->finished = 1; } -int T0421_reserve6_lun_reset(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T0421_reserve6_lun_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; diff --git a/test-tool/0422_reserve6_logout.c b/test-tool/0422_reserve6_logout.c index bf0d72f..077423a 100644 --- a/test-tool/0422_reserve6_logout.c +++ b/test-tool/0422_reserve6_logout.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss _U_, - int show_info) +int T0422_reserve6_logout(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; diff --git a/test-tool/0423_reserve6_sessionloss.c b/test-tool/0423_reserve6_sessionloss.c index b5f8aa3..0b22690 100644 --- a/test-tool/0423_reserve6_sessionloss.c +++ b/test-tool/0423_reserve6_sessionloss.c @@ -22,8 +22,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0423_reserve6_sessionloss(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T0423_reserve6_sessionloss(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; diff --git a/test-tool/0424_reserve6_target_reset.c b/test-tool/0424_reserve6_target_reset.c index 09f7ee7..8d49276 100644 --- a/test-tool/0424_reserve6_target_reset.c +++ b/test-tool/0424_reserve6_target_reset.c @@ -37,8 +37,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, mgmt_task->finished = 1; } -int T0424_reserve6_target_reset(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T0424_reserve6_target_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; diff --git a/test-tool/0430_report_all_supported_ops.c b/test-tool/0430_report_all_supported_ops.c index 19cd61a..2f688cd 100644 --- a/test-tool/0430_report_all_supported_ops.c +++ b/test-tool/0430_report_all_supported_ops.c @@ -23,8 +23,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0430_report_all_supported_ops(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T0430_report_all_supported_ops(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/1000_cmdsn_invalid.c b/test-tool/1000_cmdsn_invalid.c index ede592d..3c88d2c 100644 --- a/test-tool/1000_cmdsn_invalid.c +++ b/test-tool/1000_cmdsn_invalid.c @@ -56,13 +56,11 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, } -int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, int show_info) +int T1000_cmdsn_invalid(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; - uint32_t block_size; unsigned char data[4096 * 2]; struct iscsi_async_state test_state; @@ -83,30 +81,6 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -133,8 +107,8 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } test_state.task = task; test_state.finished = 0; @@ -143,15 +117,14 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; @@ -170,8 +143,8 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } test_state.task = task; test_state.finished = 0; @@ -180,15 +153,14 @@ test2: if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); diff --git a/test-tool/1010_datasn_invalid.c b/test-tool/1010_datasn_invalid.c index eea52b4..f605354 100644 --- a/test-tool/1010_datasn_invalid.c +++ b/test-tool/1010_datasn_invalid.c @@ -68,13 +68,11 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, } -int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss, int show_info) +int T1010_datasn_invalid(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; - uint32_t block_size; unsigned char data[4096 * 2]; struct iscsi_async_state test_state; @@ -96,30 +94,6 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -145,8 +119,8 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss, if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } clamp_datasn = 1; test_state.task = task; @@ -157,15 +131,14 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss, if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; @@ -183,8 +156,8 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } clamp_datasn = 2; test_state.task = task; @@ -195,15 +168,14 @@ test2: if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; @@ -221,8 +193,8 @@ test3: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } clamp_datasn = 3; test_state.task = task; @@ -233,15 +205,14 @@ test3: if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); @@ -262,8 +233,8 @@ test4: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } clamp_datasn = 4; test_state.task = task; @@ -274,19 +245,20 @@ test4: if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); + finished: + local_iscsi_queue_pdu = NULL; iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/1020_bufferoffset_invalid.c b/test-tool/1020_bufferoffset_invalid.c index 1bc17ea..26e241d 100644 --- a/test-tool/1020_bufferoffset_invalid.c +++ b/test-tool/1020_bufferoffset_invalid.c @@ -24,8 +24,6 @@ static int change_bufferoffset; -uint32_t block_size; - static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu) { uint32_t buffer_offset; @@ -62,11 +60,10 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, } -int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_loss, int show_info) +int T1020_bufferoffset_invalid(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; unsigned char data[4096 * 256]; struct iscsi_async_state test_state; @@ -88,29 +85,6 @@ int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_ return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); @@ -137,8 +111,8 @@ int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_ if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } change_bufferoffset = 1; test_state.task = task; @@ -149,14 +123,14 @@ int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_ if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test2: + /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; @@ -174,8 +148,8 @@ test2: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } change_bufferoffset = 2; test_state.task = task; @@ -186,15 +160,14 @@ test2: if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("WRITE10 command successful. Should have failed with error\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: /* in case the previous test failed the session */ iscsi_set_noautoreconnect(iscsi, 0); iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; diff --git a/test-tool/1030_unsolicited_data_overflow.c b/test-tool/1030_unsolicited_data_overflow.c index 3a2b581..e49dac6 100644 --- a/test-tool/1030_unsolicited_data_overflow.c +++ b/test-tool/1030_unsolicited_data_overflow.c @@ -23,8 +23,6 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -uint32_t block_size; - static void test_cb(struct iscsi_context *iscsi _U_, int status, void *command_data _U_, void *private_data) { @@ -39,12 +37,11 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, } } -int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info) +int T1030_unsolicited_data_overflow(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL; struct iscsi_context *iscsi2 = NULL; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; unsigned char *buf = NULL; struct iscsi_async_state test_state; @@ -65,30 +62,6 @@ int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -118,8 +91,8 @@ int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } test_state.task = task; @@ -129,7 +102,6 @@ int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int printf("[OK]\n"); -test2: printf("Verify the target is still alive ... "); iscsi2 = iscsi_context_login(initiator, url, &lun); if (iscsi2 == NULL) { diff --git a/test-tool/1031_unsolicited_data_out.c b/test-tool/1031_unsolicited_data_out.c index 986276a..fca38c8 100644 --- a/test-tool/1031_unsolicited_data_out.c +++ b/test-tool/1031_unsolicited_data_out.c @@ -24,8 +24,6 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -uint32_t block_size; - static int my_iscsi_add_data(struct iscsi_context *iscsi _U_, struct iscsi_data *data, unsigned char *dptr, int dsize, int pdualignment) @@ -149,13 +147,10 @@ my_iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opc return pdu; } -int T1031_unsolicited_data_out(const char *initiator, const char *url, - int data_loss _U_, int show_info) +int T1031_unsolicited_data_out(const char *initiator, const char *url) { struct iscsi_context *iscsi = NULL; struct iscsi_context *iscsi2 = NULL; - struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int i, ret, lun; unsigned char buf[1024]; @@ -175,29 +170,6 @@ int T1031_unsolicited_data_out(const char *initiator, const char *url, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - scsi_free_scsi_task(task); - ret = 0; diff --git a/test-tool/1040_saturate_maxcmdsn.c b/test-tool/1040_saturate_maxcmdsn.c index a0ef25c..a172f27 100644 --- a/test-tool/1040_saturate_maxcmdsn.c +++ b/test-tool/1040_saturate_maxcmdsn.c @@ -41,14 +41,12 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, #define T1040_NO_OF_WRITES (1024) -int T1040_saturate_maxcmdsn(const char *initiator, const char *url, int data_loss, int show_info) +int T1040_saturate_maxcmdsn(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int i, ret, lun; - uint32_t block_size; - unsigned char *data; + unsigned char *data = NULL; struct iscsi_async_state test_state; printf("1040_saturate_maxcmdsn:\n"); @@ -66,35 +64,11 @@ int T1040_saturate_maxcmdsn(const char *initiator, const char *url, int data_los return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - - if (T1040_NO_OF_WRITES*2*iscsi->first_burst_length > rc16->block_length*(rc16->returned_lba +1)) { + if (T1040_NO_OF_WRITES*2*iscsi->first_burst_length > block_size * num_blocks) { printf("target is too small for this test. at least %u bytes are required\n",T1040_NO_OF_WRITES*2*iscsi->first_burst_length); ret = -1; - scsi_free_scsi_task(task); goto finished; } - scsi_free_scsi_task(task); if (!data_loss) { @@ -136,8 +110,8 @@ int T1040_saturate_maxcmdsn(const char *initiator, const char *url, int data_los if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } } @@ -148,23 +122,21 @@ int T1040_saturate_maxcmdsn(const char *initiator, const char *url, int data_los if (num_cmds_in_flight != 0) { printf("[FAILED]\n"); printf("Did not complete all I/O before deadline.\n"); - ret++; - goto test2; + ret = -1; + goto finished; } else if (test_state.status != 0) { printf("[FAILED]\n"); printf("Not all I/O commands succeeded.\n"); - ret++; - goto test2; + ret = -1; + goto finished; } printf("[OK]\n"); run++; } while (iscsi->use_immediate_data == ISCSI_IMMEDIATE_DATA_YES); -test2: - free(data); - finished: + free(data); iscsi_destroy_context(iscsi); return ret; } diff --git a/test-tool/1041_unsolicited_immediate_data.c b/test-tool/1041_unsolicited_immediate_data.c index db79b50..3bb4d28 100644 --- a/test-tool/1041_unsolicited_immediate_data.c +++ b/test-tool/1041_unsolicited_immediate_data.c @@ -23,7 +23,6 @@ #include "iscsi-test.h" #include -uint32_t block_size; int pdu_was_valid; /* one block sent as immediate data. PDU should have F-bit set @@ -46,11 +45,10 @@ static int my_queue_immediate_data(struct iscsi_context *iscsi _U_, struct iscsi return 1; } -int T1041_unsolicited_immediate_data(const char *initiator, const char *url, int data_loss, int show_info) +int T1041_unsolicited_immediate_data(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; struct iscsi_url *iscsi_url; unsigned char data[4096]; @@ -79,30 +77,6 @@ int T1041_unsolicited_immediate_data(const char *initiator, const char *url, int return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); diff --git a/test-tool/1042_unsolicited_nonimmediate_data.c b/test-tool/1042_unsolicited_nonimmediate_data.c index 09559fd..bb2112b 100644 --- a/test-tool/1042_unsolicited_nonimmediate_data.c +++ b/test-tool/1042_unsolicited_nonimmediate_data.c @@ -23,7 +23,6 @@ #include "iscsi-test.h" #include -static uint32_t block_size; static int pdu_was_valid = 1; /* one block sent as immediate data. PDU should have F-bit set @@ -62,11 +61,10 @@ static int my_queue_immediate_data(struct iscsi_context *iscsi _U_, struct iscsi return 1; } -int T1042_unsolicited_nonimmediate_data(const char *initiator, const char *url, int data_loss, int show_info) +int T1042_unsolicited_nonimmediate_data(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; struct iscsi_url *iscsi_url; unsigned char data[4096]; @@ -97,31 +95,6 @@ int T1042_unsolicited_nonimmediate_data(const char *initiator, const char *url, return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - block_size = rc16->block_length; - - scsi_free_scsi_task(task); - - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/1100_persistent_reserve_in_read_keys_simple.c b/test-tool/1100_persistent_reserve_in_read_keys_simple.c index 1c70ed9..24de2ff 100644 --- a/test-tool/1100_persistent_reserve_in_read_keys_simple.c +++ b/test-tool/1100_persistent_reserve_in_read_keys_simple.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T1100_persistent_reserve_in_read_keys_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T1100_persistent_reserve_in_read_keys_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/1110_persistent_reserve_in_serviceaction_range.c b/test-tool/1110_persistent_reserve_in_serviceaction_range.c index aeb3100..415eb69 100644 --- a/test-tool/1110_persistent_reserve_in_serviceaction_range.c +++ b/test-tool/1110_persistent_reserve_in_serviceaction_range.c @@ -21,7 +21,7 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T1110_persistent_reserve_in_serviceaction_range(const char *initiator, const char *url, int data_loss _U_, int show_info) +int T1110_persistent_reserve_in_serviceaction_range(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; diff --git a/test-tool/1120_persistent_register_simple.c b/test-tool/1120_persistent_register_simple.c index 5d43392..a52a5a6 100644 --- a/test-tool/1120_persistent_register_simple.c +++ b/test-tool/1120_persistent_register_simple.c @@ -25,8 +25,7 @@ -int T1120_persistent_register_simple(const char *initiator, const char *url, - int data_loss, int show_info) +int T1120_persistent_register_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; int ret, lun; diff --git a/test-tool/1130_persistent_reserve_simple.c b/test-tool/1130_persistent_reserve_simple.c index 2d8ec37..3ed76cc 100644 --- a/test-tool/1130_persistent_reserve_simple.c +++ b/test-tool/1130_persistent_reserve_simple.c @@ -34,8 +34,7 @@ static enum scsi_persistent_out_type pr_types_to_test[] = { 0 }; -int T1130_persistent_reserve_simple(const char *initiator, - const char *url, int data_loss, int show_info) +int T1130_persistent_reserve_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; int ret; @@ -43,8 +42,6 @@ int T1130_persistent_reserve_simple(const char *initiator, const unsigned long long key = rand_key(); int i; - - printf("1130_persistent_reserve_simple:\n"); printf("=========================================\n"); if (show_info) { diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 8391fea..c8e4f05 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -42,12 +42,15 @@ const char *initiatorname1 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test"; const char *initiatorname2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2"; -static int data_loss = 0; -static int show_info = 0; +uint32_t block_size; +uint64_t num_blocks; + +int data_loss; +int show_info; struct scsi_test { const char *name; - int (*test)(const char *initiator, const char *url, int data_loss, int show_info); + int (*test)(const char *initiator, const char *url); }; struct scsi_test tests[] = { @@ -776,12 +779,12 @@ int testunitready_conflict(struct iscsi_context *iscsi, int lun) return 0; } -int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group) +int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num, int immed, int group) { struct scsi_task *task; - printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d ... ", lba, num_blocks, immed, group); - task = iscsi_prefetch10_sync(iscsi, lun, lba, num_blocks, immed, group); + printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d ... ", lba, num, immed, group); + task = iscsi_prefetch10_sync(iscsi, lun, lba, num, immed, group); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi)); @@ -806,12 +809,12 @@ int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_block return 0; } -int prefetch10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group) +int prefetch10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, int num, int immed, int group) { struct scsi_task *task; - printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d (expecting ILLEGAL_REQUEST/LBA_OUT_OF_RANGE) ... ", lba, num_blocks, immed, group); - task = iscsi_prefetch10_sync(iscsi, lun, lba, num_blocks, immed, group); + printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d (expecting ILLEGAL_REQUEST/LBA_OUT_OF_RANGE) ... ", lba, num, immed, group); + task = iscsi_prefetch10_sync(iscsi, lun, lba, num, immed, group); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi)); @@ -839,12 +842,12 @@ int prefetch10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, return 0; } -int prefetch10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group) +int prefetch10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int num, int immed, int group) { struct scsi_task *task; - printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, num_blocks, immed, group); - task = iscsi_prefetch10_sync(iscsi, lun, lba, num_blocks, immed, group); + printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, num, immed, group); + task = iscsi_prefetch10_sync(iscsi, lun, lba, num, immed, group); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi)); @@ -874,12 +877,12 @@ int prefetch10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int return 0; } -int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group) +int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num, int immed, int group) { struct scsi_task *task; - printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d ... ", lba, num_blocks, immed, group); - task = iscsi_prefetch16_sync(iscsi, lun, lba, num_blocks, immed, group); + printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d ... ", lba, num, immed, group); + task = iscsi_prefetch16_sync(iscsi, lun, lba, num, immed, group); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi)); @@ -904,12 +907,12 @@ int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_block return 0; } -int prefetch16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group) +int prefetch16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, int num, int immed, int group) { struct scsi_task *task; - printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d (expecting ILLEGAL_REQUEST/LBA_OUT_OF_RANGE) ... ", lba, num_blocks, immed, group); - task = iscsi_prefetch16_sync(iscsi, lun, lba, num_blocks, immed, group); + printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d (expecting ILLEGAL_REQUEST/LBA_OUT_OF_RANGE) ... ", lba, num, immed, group); + task = iscsi_prefetch16_sync(iscsi, lun, lba, num, immed, group); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi)); @@ -937,12 +940,12 @@ int prefetch16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, return 0; } -int prefetch16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group) +int prefetch16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, int num, int immed, int group) { struct scsi_task *task; - printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, num_blocks, immed, group); - task = iscsi_prefetch16_sync(iscsi, lun, lba, num_blocks, immed, group); + printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, num, immed, group); + task = iscsi_prefetch16_sync(iscsi, lun, lba, num, immed, group); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi)); @@ -1409,6 +1412,11 @@ int main(int argc, const char *argv[]) struct scsi_test *test; char *testname = NULL; char *skipname = NULL; + int lun; + struct iscsi_context *iscsi; + struct scsi_task *task; + struct scsi_readcapacity10 *rc10; + struct scsi_readcapacity16 *rc16; struct poptOption popt_options[] = { { "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL }, @@ -1454,7 +1462,7 @@ int main(int argc, const char *argv[]) for (test = &tests[0]; test->name; test++) { printf("%s\n", test->name); if (show_info) { - test->test(initiatorname1, url, data_loss, show_info); + test->test(initiatorname1, url); } } exit(0); @@ -1469,6 +1477,63 @@ int main(int argc, const char *argv[]) exit(10); } + + iscsi = iscsi_context_login(initiatorname1, url, &lun); + if (iscsi == NULL) { + printf("Failed to login to target\n"); + return -1; + } + + /* find the size of the LUN */ + task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); + if (task == NULL) { + printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); + iscsi_destroy_context(iscsi); + return -1; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + iscsi_destroy_context(iscsi); + return -1; + } + rc10 = scsi_datain_unmarshall(task); + if (rc10 == NULL) { + printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + iscsi_destroy_context(iscsi); + return -1; + } + block_size = rc10->block_size; + num_blocks = rc10->lba; + scsi_free_scsi_task(task); + if (num_blocks == 0xffffffff) { + task = iscsi_readcapacity16_sync(iscsi, lun); + if (task == NULL) { + printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); + iscsi_destroy_context(iscsi); + return -1; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + iscsi_destroy_context(iscsi); + return -1; + } + rc16 = scsi_datain_unmarshall(task); + if (rc16 == NULL) { + printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); + scsi_free_scsi_task(task); + iscsi_destroy_context(iscsi); + return -1; + } + block_size = rc16->block_length; + num_blocks = rc16->returned_lba; + scsi_free_scsi_task(task); + } + iscsi_destroy_context(iscsi); + + num_failed = num_skipped = 0; for (test = &tests[0]; test->name; test++) { if (testname != NULL && fnmatch(testname, test->name, 0)) { @@ -1490,7 +1555,7 @@ int main(int argc, const char *argv[]) if (skip) continue; } - res = test->test(initiatorname1, url, data_loss, show_info); + res = test->test(initiatorname1, url); if (res == 0) { printf("TEST %s [OK]\n", test->name); } else if (res == -2) { diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index baf8c68..039ee57 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -28,6 +28,11 @@ extern const char *initiatorname1; extern const char *initiatorname2; +extern uint32_t block_size; +extern uint64_t num_blocks; +extern int data_loss; +extern int show_info; + struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun); struct iscsi_async_state { @@ -40,164 +45,164 @@ void wait_until_test_finished(struct iscsi_context *iscsi, struct iscsi_async_st struct iscsi_pdu; int (*local_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu); -int T0000_testunitready_simple(const char *initiator, const char *url, int data_loss, int show_info); +int T0000_testunitready_simple(const char *initiator, const char *url); -int T0100_read10_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_loss, int show_info); -int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss, int show_info); -int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0104_read10_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0105_read10_invalid(const char *initiator, const char *url, int data_loss, int show_info); +int T0100_read10_simple(const char *initiator, const char *url); +int T0101_read10_beyond_eol(const char *initiator, const char *url); +int T0102_read10_0blocks(const char *initiator, const char *url); +int T0103_read10_rdprotect(const char *initiator, const char *url); +int T0104_read10_flags(const char *initiator, const char *url); +int T0105_read10_invalid(const char *initiator, const char *url); -int T0110_readcapacity10_simple(const char *initiator, const char *url, int data_loss, int show_info); +int T0110_readcapacity10_simple(const char *initiator, const char *url); -int T0120_read6_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss, int show_info); -int T0122_read6_invalid(const char *initiator, const char *url, int data_loss, int show_info); +int T0120_read6_simple(const char *initiator, const char *url); +int T0121_read6_beyond_eol(const char *initiator, const char *url); +int T0122_read6_invalid(const char *initiator, const char *url); -int T0130_verify10_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0131_verify10_mismatch(const char *initiator, const char *url, int data_loss, int show_info); -int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url, int data_loss, int show_info); -int T0133_verify10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0130_verify10_simple(const char *initiator, const char *url); +int T0131_verify10_mismatch(const char *initiator, const char *url); +int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url); +int T0133_verify10_beyondeol(const char *initiator, const char *url); -int T0160_readcapacity16_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int data_loss, int show_info); +int T0160_readcapacity16_simple(const char *initiator, const char *url); +int T0161_readcapacity16_alloclen(const char *initiator, const char *url); -int T0170_unmap_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0171_unmap_zero(const char *initiator, const char *url, int data_loss, int show_info); +int T0170_unmap_simple(const char *initiator, const char *url); +int T0171_unmap_zero(const char *initiator, const char *url); -int T0180_writesame10_unmap(const char *initiator, const char *url, int data_loss, int show_info); -int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, int data_loss, int show_info); -int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); -int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_loss, int show_info); +int T0180_writesame10_unmap(const char *initiator, const char *url); +int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url); +int T0182_writesame10_beyondeol(const char *initiator, const char *url); +int T0183_writesame10_wrprotect(const char *initiator, const char *url); +int T0184_writesame10_0blocks(const char *initiator, const char *url); -int T0190_writesame16_unmap(const char *initiator, const char *url, int data_loss, int show_info); -int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url, int data_loss, int show_info); -int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); -int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_loss, int show_info); +int T0190_writesame16_unmap(const char *initiator, const char *url); +int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url); +int T0192_writesame16_beyondeol(const char *initiator, const char *url); +int T0193_writesame16_wrprotect(const char *initiator, const char *url); +int T0194_writesame16_0blocks(const char *initiator, const char *url); -int T0200_read16_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0201_read16_rdprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0202_read16_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss, int show_info); -int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0200_read16_simple(const char *initiator, const char *url); +int T0201_read16_rdprotect(const char *initiator, const char *url); +int T0202_read16_flags(const char *initiator, const char *url); +int T0203_read16_0blocks(const char *initiator, const char *url); +int T0204_read16_beyondeol(const char *initiator, const char *url); -int T0210_read12_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0212_read12_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss, int show_info); -int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0210_read12_simple(const char *initiator, const char *url); +int T0211_read12_rdprotect(const char *initiator, const char *url); +int T0212_read12_flags(const char *initiator, const char *url); +int T0213_read12_0blocks(const char *initiator, const char *url); +int T0214_read12_beyondeol(const char *initiator, const char *url); -int T0220_write16_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0221_write16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0222_write16_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss, int show_info); -int T0224_write16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0220_write16_simple(const char *initiator, const char *url); +int T0221_write16_wrprotect(const char *initiator, const char *url); +int T0222_write16_flags(const char *initiator, const char *url); +int T0223_write16_0blocks(const char *initiator, const char *url); +int T0224_write16_beyondeol(const char *initiator, const char *url); -int T0230_write12_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0231_write12_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0232_write12_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss, int show_info); -int T0234_write12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0230_write12_simple(const char *initiator, const char *url); +int T0231_write12_wrprotect(const char *initiator, const char *url); +int T0232_write12_flags(const char *initiator, const char *url); +int T0233_write12_0blocks(const char *initiator, const char *url); +int T0234_write12_beyondeol(const char *initiator, const char *url); -int T0240_prefetch10_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0242_prefetch10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); -int T0243_prefetch10_0blocks(const char *initiator, const char *url, int data_loss, int show_info); +int T0240_prefetch10_simple(const char *initiator, const char *url); +int T0241_prefetch10_flags(const char *initiator, const char *url); +int T0242_prefetch10_beyondeol(const char *initiator, const char *url); +int T0243_prefetch10_0blocks(const char *initiator, const char *url); -int T0250_prefetch16_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0252_prefetch16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); -int T0253_prefetch16_0blocks(const char *initiator, const char *url, int data_loss, int show_info); +int T0250_prefetch16_simple(const char *initiator, const char *url); +int T0251_prefetch16_flags(const char *initiator, const char *url); +int T0252_prefetch16_beyondeol(const char *initiator, const char *url); +int T0253_prefetch16_0blocks(const char *initiator, const char *url); -int T0260_get_lba_status_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0264_get_lba_status_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0260_get_lba_status_simple(const char *initiator, const char *url); +int T0264_get_lba_status_beyondeol(const char *initiator, const char *url); -int T0270_verify16_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0271_verify16_mismatch(const char *initiator, const char *url, int data_loss, int show_info); -int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url, int data_loss, int show_info); -int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0270_verify16_simple(const char *initiator, const char *url); +int T0271_verify16_mismatch(const char *initiator, const char *url); +int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url); +int T0273_verify16_beyondeol(const char *initiator, const char *url); -int T0280_verify12_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0281_verify12_mismatch(const char *initiator, const char *url, int data_loss, int show_info); -int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int data_loss, int show_info); -int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0280_verify12_simple(const char *initiator, const char *url); +int T0281_verify12_mismatch(const char *initiator, const char *url); +int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url); +int T0283_verify12_beyondeol(const char *initiator, const char *url); -int T0290_write10_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0291_write10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0292_write10_flags(const char *initiator, const char *url, int data_loss, int show_info); -int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss, int show_info); -int T0294_write10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0290_write10_simple(const char *initiator, const char *url); +int T0291_write10_wrprotect(const char *initiator, const char *url); +int T0292_write10_flags(const char *initiator, const char *url); +int T0293_write10_0blocks(const char *initiator, const char *url); +int T0294_write10_beyondeol(const char *initiator, const char *url); -int T0300_readonly(const char *initiator, const char *url, int data_loss, int show_info); +int T0300_readonly(const char *initiator, const char *url); -int T0310_writeverify10_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0310_writeverify10_simple(const char *initiator, const char *url); +int T0311_writeverify10_wrprotect(const char *initiator, const char *url); +int T0314_writeverify10_beyondeol(const char *initiator, const char *url); -int T0320_writeverify12_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0320_writeverify12_simple(const char *initiator, const char *url); +int T0321_writeverify12_wrprotect(const char *initiator, const char *url); +int T0324_writeverify12_beyondeol(const char *initiator, const char *url); -int T0330_writeverify16_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0330_writeverify16_simple(const char *initiator, const char *url); +int T0331_writeverify16_wrprotect(const char *initiator, const char *url); +int T0334_writeverify16_beyondeol(const char *initiator, const char *url); -int T0340_compareandwrite_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int data_loss, int show_info); -int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0340_compareandwrite_simple(const char *initiator, const char *url); +int T0341_compareandwrite_mismatch(const char *initiator, const char *url); +int T0343_compareandwrite_beyondeol(const char *initiator, const char *url); -int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_loss, int show_info); -int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_loss, int show_info); +int T0350_orwrite_simple(const char *initiator, const char *url); +int T0351_orwrite_wrprotect(const char *initiator, const char *url); +int T0354_orwrite_beyondeol(const char *initiator, const char *url); -int T0360_startstopunit_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_loss, int show_info); -int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_loss, int show_info); +int T0360_startstopunit_simple(const char *initiator, const char *url); +int T0361_startstopunit_pwrcnd(const char *initiator, const char *url); +int T0362_startstopunit_noloej(const char *initiator, const char *url); -int T0370_nomedia(const char *initiator, const char *url, int data_loss, int show_info); +int T0370_nomedia(const char *initiator, const char *url); -int T0380_preventallow_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0381_preventallow_eject(const char *initiator, const char *url, int data_loss, int show_info); -int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int data_loss, int show_info); -int T0383_preventallow_target_warm_reset(const char *initiator, const char *url, int data_loss, int show_info); -int T0384_preventallow_target_cold_reset(const char *initiator, const char *url, int data_loss, int show_info); -int T0385_preventallow_lun_reset(const char *initiator, const char *url, int data_loss, int show_info); -int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int data_loss, int show_info); +int T0380_preventallow_simple(const char *initiator, const char *url); +int T0381_preventallow_eject(const char *initiator, const char *url); +int T0382_preventallow_itnexus_loss(const char *initiator, const char *url); +int T0383_preventallow_target_warm_reset(const char *initiator, const char *url); +int T0384_preventallow_target_cold_reset(const char *initiator, const char *url); +int T0385_preventallow_lun_reset(const char *initiator, const char *url); +int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url); -int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data_loss, int show_info); +int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url); -int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss, int show_info); -int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss, int show_info); -int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, int show_info); -int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data_loss, int show_info); -int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, int data_loss, int show_info); +int T0400_inquiry_basic(const char *initiator, const char *url); +int T0401_inquiry_alloclen(const char *initiator, const char *url); +int T0402_inquiry_evpd(const char *initiator, const char *url); +int T0403_inquiry_supported_vpd(const char *initiator, const char *url); +int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url); -int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss, int show_info); +int T0410_readtoc_basic(const char *initiator, const char *url); -int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_loss, int show_info); -int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, int show_info); -int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_loss, int show_info); -int T0424_reserve6_target_reset(const char *initiator, const char *url, int data_loss, int show_info); +int T0420_reserve6_simple(const char *initiator, const char *url); +int T0421_reserve6_lun_reset(const char *initiator, const char *url); +int T0422_reserve6_logout(const char *initiator, const char *url); +int T0423_reserve6_sessionloss(const char *initiator, const char *url); +int T0424_reserve6_target_reset(const char *initiator, const char *url); -int T0430_report_all_supported_ops(const char *initiator, const char *url, int data_loss, int show_info); +int T0430_report_all_supported_ops(const char *initiator, const char *url); + +int T1000_cmdsn_invalid(const char *initiator, const char *url); +int T1010_datasn_invalid(const char *initiator, const char *url); +int T1020_bufferoffset_invalid(const char *initiator, const char *url); +int T1030_unsolicited_data_overflow(const char *initiator, const char *url); +int T1031_unsolicited_data_out(const char *initiator, const char *url); +int T1040_saturate_maxcmdsn(const char *initiator, const char *url); +int T1041_unsolicited_immediate_data(const char *initiator, const char *url); +int T1042_unsolicited_nonimmediate_data(const char *initiator, const char *url); +int T1100_persistent_reserve_in_read_keys_simple(const char *initiator, const char *url); +int T1110_persistent_reserve_in_serviceaction_range(const char *initiator, const char *url); +int T1120_persistent_register_simple(const char *initiator, const char *url); +int T1130_persistent_reserve_simple(const char *initiator, const char *url); -int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, int show_info); -int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss, int show_info); -int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_loss, int show_info); -int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info); -int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss, int show_info); -int T1040_saturate_maxcmdsn(const char *initiator, const char *url, int data_loss, int show_info); -int T1041_unsolicited_immediate_data(const char *initiator, const char *url, int data_loss, int show_info); -int T1042_unsolicited_nonimmediate_data(const char *initiator, const char *url, int data_loss, int show_info); -int T1100_persistent_reserve_in_read_keys_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T1110_persistent_reserve_in_serviceaction_range(const char *initiator, const char *url, int data_loss, int show_info); -int T1120_persistent_register_simple(const char *initiator, const char *url, int data_loss, int show_info); -int T1130_persistent_reserve_simple(const char *initiator, const char *url, - int data_loss, int show_info); /* From 3a4605d3e5b772ec55b9aaa7ff8006da381744a1 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 27 Dec 2012 07:04:23 -0800 Subject: [PATCH 3/4] TESTS: Remove some READCAPACITY16 we no longer need --- test-tool/0170_unmap_simple.c | 27 +--------------- test-tool/0171_unmap_zero.c | 27 +--------------- test-tool/0180_writesame10_unmap.c | 29 ----------------- test-tool/0181_writesame10_unmap_unaligned.c | 29 +---------------- test-tool/0190_writesame16_unmap.c | 29 ----------------- test-tool/0191_writesame16_unmap_unaligned.c | 30 +----------------- test-tool/0260_get_lba_status_simple.c | 27 +--------------- test-tool/0264_get_lba_status_beyondeol.c | 26 +-------------- test-tool/0300_readonly.c | 23 -------------- test-tool/0390_mandatory_opcodes_sbc.c | 26 +-------------- test-tool/iscsi-test.c | 33 +++++++++++--------- test-tool/iscsi-test.h | 3 ++ 12 files changed, 29 insertions(+), 280 deletions(-) diff --git a/test-tool/0170_unmap_simple.c b/test-tool/0170_unmap_simple.c index 952bd1b..0a5ef11 100644 --- a/test-tool/0170_unmap_simple.c +++ b/test-tool/0170_unmap_simple.c @@ -24,7 +24,6 @@ int T0170_unmap_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; printf("0170_unmap_simple:\n"); @@ -43,36 +42,12 @@ int T0170_unmap_simple(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (rc16->lbpme == 0){ + if (lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; - scsi_free_scsi_task(task); goto finished; } - scsi_free_scsi_task(task); - if (!data_loss) { printf("data_loss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0171_unmap_zero.c b/test-tool/0171_unmap_zero.c index db18278..a8b11a7 100644 --- a/test-tool/0171_unmap_zero.c +++ b/test-tool/0171_unmap_zero.c @@ -24,7 +24,6 @@ int T0171_unmap_zero(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; printf("0171_unmap_zero:\n"); @@ -45,36 +44,12 @@ int T0171_unmap_zero(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (rc16->lbpme == 0){ + if (lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; - scsi_free_scsi_task(task); goto finished; } - scsi_free_scsi_task(task); - if (!data_loss) { printf("data_loss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0180_writesame10_unmap.c b/test-tool/0180_writesame10_unmap.c index c398466..7d87025 100644 --- a/test-tool/0180_writesame10_unmap.c +++ b/test-tool/0180_writesame10_unmap.c @@ -24,12 +24,9 @@ int T0180_writesame10_unmap(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int full_size; struct scsi_inquiry_logical_block_provisioning *inq_lbp; int ret, i, lun; - int lbppb; - int lbpme; int lbpws10 = 0; int anc_sup = 0; @@ -54,34 +51,8 @@ int T0180_writesame10_unmap(const char *initiator, const char *url) ret = 0; - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - lbppb = 1 << rc16->lbppbe; - lbpme = rc16->lbpme; - - scsi_free_scsi_task(task); - if (lbpme == 0){ printf("Logical unit is fully provisioned. All commands should fail with check condition.\n"); - goto finished; } /* Check that id we have logical block provisioning we also have the VPD page for it */ diff --git a/test-tool/0181_writesame10_unmap_unaligned.c b/test-tool/0181_writesame10_unmap_unaligned.c index be5ecc2..9855129 100644 --- a/test-tool/0181_writesame10_unmap_unaligned.c +++ b/test-tool/0181_writesame10_unmap_unaligned.c @@ -24,9 +24,7 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - int lbppb; printf("0181_writesame10_unmap_unaligned:\n"); printf("=================================\n"); @@ -43,37 +41,12 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (rc16->lbpme == 0){ + if (lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; - scsi_free_scsi_task(task); goto finished; } - lbppb = 1 << rc16->lbppbe; - - scsi_free_scsi_task(task); if (lbppb < 2) { printf("LBPPB==%d Can not unmap fractional physical block\n", lbppb); diff --git a/test-tool/0190_writesame16_unmap.c b/test-tool/0190_writesame16_unmap.c index e40c7e2..d95aab9 100644 --- a/test-tool/0190_writesame16_unmap.c +++ b/test-tool/0190_writesame16_unmap.c @@ -24,12 +24,9 @@ int T0190_writesame16_unmap(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int full_size; struct scsi_inquiry_logical_block_provisioning *inq_lbp; int ret, i, lun; - int lbppb; - int lbpme; int lbpws = 0; int anc_sup = 0; @@ -54,32 +51,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url) ret = 0; - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - lbppb = 1 << rc16->lbppbe; - lbpme = rc16->lbpme; - - scsi_free_scsi_task(task); - if (lbpme == 0) { printf("LBPME not set. Skip test for CPD page 0xB2 (logical block provisioning)\n"); goto finished; diff --git a/test-tool/0191_writesame16_unmap_unaligned.c b/test-tool/0191_writesame16_unmap_unaligned.c index 9ae7553..116954b 100644 --- a/test-tool/0191_writesame16_unmap_unaligned.c +++ b/test-tool/0191_writesame16_unmap_unaligned.c @@ -24,9 +24,7 @@ int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, i, lun; - int lbppb; printf("0191_writesame16_unmap_unaligned:\n"); printf("=================================\n"); @@ -43,38 +41,12 @@ int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (rc16->lbpme == 0){ + if (lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; - scsi_free_scsi_task(task); goto finished; } - lbppb = 1 << rc16->lbppbe; - - scsi_free_scsi_task(task); - if (lbppb < 2) { printf("LBPPB==%d Can not unmap fractional physical block\n", lbppb); ret = -2; diff --git a/test-tool/0260_get_lba_status_simple.c b/test-tool/0260_get_lba_status_simple.c index 753a2ca..4144959 100644 --- a/test-tool/0260_get_lba_status_simple.c +++ b/test-tool/0260_get_lba_status_simple.c @@ -24,7 +24,6 @@ int T0260_get_lba_status_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; printf("0260_get_lba_status_simple:\n"); @@ -43,36 +42,12 @@ int T0260_get_lba_status_simple(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (rc16->lbpme == 0){ + if (lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; - scsi_free_scsi_task(task); goto finished; } - scsi_free_scsi_task(task); - ret = 0; /* try reading one descriptor at offset 0 */ diff --git a/test-tool/0264_get_lba_status_beyondeol.c b/test-tool/0264_get_lba_status_beyondeol.c index 0dd6df6..e0c7432 100644 --- a/test-tool/0264_get_lba_status_beyondeol.c +++ b/test-tool/0264_get_lba_status_beyondeol.c @@ -24,7 +24,6 @@ int T0264_get_lba_status_beyondeol(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; int ret, lun; printf("0264_get_lba_status_beyondeol:\n"); @@ -42,34 +41,11 @@ int T0264_get_lba_status_beyondeol(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (rc16->lbpme == 0){ + if (lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; - scsi_free_scsi_task(task); goto finished; } - scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0300_readonly.c b/test-tool/0300_readonly.c index fbb2b7d..5e439e4 100644 --- a/test-tool/0300_readonly.c +++ b/test-tool/0300_readonly.c @@ -24,13 +24,11 @@ int T0300_readonly(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; struct scsi_mode_sense *ms; int ret, lun; unsigned char data[4096]; int full_size; - int lbpme; struct unmap_list list[1]; ret = -1; @@ -62,27 +60,6 @@ int T0300_readonly(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - goto finished; - } - lbpme = rc16->lbpme; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c index 72de152..b8579c7 100644 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ b/test-tool/0390_mandatory_opcodes_sbc.c @@ -25,9 +25,8 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_readcapacity16 *rc16; struct scsi_inquiry_standard *inq; - int ret = 0, lun, sccs, encserv, lbpme; + int ret = 0, lun, sccs, encserv; unsigned char data[4096]; int full_size; @@ -65,29 +64,6 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) return -1; } - /* find the size of the LUN */ - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - lbpme = rc16->lbpme; - scsi_free_scsi_task(task); - /* See how big this inquiry data is */ task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); if (task == NULL || task->status != SCSI_STATUS_GOOD) { diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index c8e4f05..9f13ef2 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -44,6 +44,9 @@ const char *initiatorname2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-tes uint32_t block_size; uint64_t num_blocks; +int lbpme; +int lbppb; +int lbpme; int data_loss; int show_info; @@ -1484,7 +1487,10 @@ int main(int argc, const char *argv[]) return -1; } - /* find the size of the LUN */ + /* find the size of the LUN + All devices support readcapacity10 but only some support + readcapacity16 + */ task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); if (task == NULL) { printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); @@ -1507,19 +1513,14 @@ int main(int argc, const char *argv[]) block_size = rc10->block_size; num_blocks = rc10->lba; scsi_free_scsi_task(task); - if (num_blocks == 0xffffffff) { - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - iscsi_destroy_context(iscsi); - return -1; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - iscsi_destroy_context(iscsi); - return -1; - } + + task = iscsi_readcapacity16_sync(iscsi, lun); + if (task == NULL) { + printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); + iscsi_destroy_context(iscsi); + return -1; + } + if (task->status == SCSI_STATUS_GOOD) { rc16 = scsi_datain_unmarshall(task); if (rc16 == NULL) { printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); @@ -1529,6 +1530,10 @@ int main(int argc, const char *argv[]) } block_size = rc16->block_length; num_blocks = rc16->returned_lba; + lbpme = rc16->lbpme; + lbppb = 1 << rc16->lbppbe; + lbpme = rc16->lbpme; + scsi_free_scsi_task(task); } iscsi_destroy_context(iscsi); diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index 039ee57..74a7b0c 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -30,6 +30,9 @@ extern const char *initiatorname2; extern uint32_t block_size; extern uint64_t num_blocks; +extern int lbpme; +extern int lbppb; +extern int lbpme; extern int data_loss; extern int show_info; From 91155c42e410f7d385411949beb6cd272f094072 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 27 Dec 2012 11:47:34 -0800 Subject: [PATCH 4/4] TESTS: Read standard inq page before we spawn the tests We dont need to call inq so often from the tests if we read the standard page once before the tests begin --- test-tool/0103_read10_rdprotect.c | 37 +---------- test-tool/0104_read10_flags.c | 15 +---- test-tool/0202_read16_flags.c | 15 +---- test-tool/0212_read12_flags.c | 15 +---- test-tool/0222_write16_flags.c | 15 +---- test-tool/0232_write12_flags.c | 15 +---- test-tool/0292_write10_flags.c | 15 +---- test-tool/0300_readonly.c | 19 +----- test-tool/0360_startstopunit_simple.c | 30 +-------- test-tool/0361_startstopunit_pwrcnd.c | 30 +-------- test-tool/0362_startstopunit_noloej.c | 30 +-------- test-tool/0370_nomedia.c | 35 +---------- test-tool/0380_preventallow_simple.c | 30 +-------- test-tool/0381_preventallow_eject.c | 37 ++--------- test-tool/0382_preventallow_itnexus_loss.c | 30 +-------- .../0383_preventallow_target_warm_reset.c | 37 ++--------- .../0384_preventallow_target_cold_reset.c | 37 ++--------- test-tool/0385_preventallow_lun_reset.c | 37 ++--------- test-tool/0386_preventallow_2_it_nexuses.c | 36 +---------- test-tool/0390_mandatory_opcodes_sbc.c | 50 ++------------- test-tool/iscsi-test.c | 61 +++++++++++++++++++ test-tool/iscsi-test.h | 5 ++ 22 files changed, 106 insertions(+), 525 deletions(-) diff --git a/test-tool/0103_read10_rdprotect.c b/test-tool/0103_read10_rdprotect.c index 8646a94..64db44e 100644 --- a/test-tool/0103_read10_rdprotect.c +++ b/test-tool/0103_read10_rdprotect.c @@ -26,8 +26,6 @@ int T0103_read10_rdprotect(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - int full_size; - struct scsi_inquiry_standard *inq; int ret, i, lun; printf("0103_read10_rdprotect:\n"); @@ -45,44 +43,11 @@ int T0103_read10_rdprotect(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } - if (inq->protect) { - printf("LUN is formatted with protection information. Skipping test\n"); - scsi_free_scsi_task(task); - return -2; - } - - scsi_free_scsi_task(task); - ret = 0; diff --git a/test-tool/0104_read10_flags.c b/test-tool/0104_read10_flags.c index bb18fbb..94bc31f 100644 --- a/test-tool/0104_read10_flags.c +++ b/test-tool/0104_read10_flags.c @@ -26,7 +26,6 @@ int T0104_read10_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret, lun; printf("0104_read10_flags:\n"); @@ -49,20 +48,8 @@ int T0104_read10_flags(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } diff --git a/test-tool/0202_read16_flags.c b/test-tool/0202_read16_flags.c index 66e077a..89077d3 100644 --- a/test-tool/0202_read16_flags.c +++ b/test-tool/0202_read16_flags.c @@ -24,7 +24,6 @@ int T0202_read16_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret = 0, lun; printf("0202_read16_flags:\n"); @@ -46,20 +45,8 @@ int T0202_read16_flags(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } diff --git a/test-tool/0212_read12_flags.c b/test-tool/0212_read12_flags.c index a67f129..995fb8f 100644 --- a/test-tool/0212_read12_flags.c +++ b/test-tool/0212_read12_flags.c @@ -24,7 +24,6 @@ int T0212_read12_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret = 0, lun; printf("0212_read12_flags:\n"); @@ -46,20 +45,8 @@ int T0212_read12_flags(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } diff --git a/test-tool/0222_write16_flags.c b/test-tool/0222_write16_flags.c index 1eacb65..c80a549 100644 --- a/test-tool/0222_write16_flags.c +++ b/test-tool/0222_write16_flags.c @@ -24,7 +24,6 @@ int T0222_write16_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret = 0, lun; unsigned char data[4096 * 256]; @@ -47,20 +46,8 @@ int T0222_write16_flags(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } diff --git a/test-tool/0232_write12_flags.c b/test-tool/0232_write12_flags.c index 2b98b20..96541b9 100644 --- a/test-tool/0232_write12_flags.c +++ b/test-tool/0232_write12_flags.c @@ -24,7 +24,6 @@ int T0232_write12_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret = 0, lun; unsigned char data[4096]; @@ -47,20 +46,8 @@ int T0232_write12_flags(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } diff --git a/test-tool/0292_write10_flags.c b/test-tool/0292_write10_flags.c index 31a85ac..3ea948d 100644 --- a/test-tool/0292_write10_flags.c +++ b/test-tool/0292_write10_flags.c @@ -24,7 +24,6 @@ int T0292_write10_flags(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret = 0, lun; unsigned char data[4096]; @@ -47,20 +46,8 @@ int T0292_write10_flags(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); return -2; } diff --git a/test-tool/0300_readonly.c b/test-tool/0300_readonly.c index 5e439e4..23e9685 100644 --- a/test-tool/0300_readonly.c +++ b/test-tool/0300_readonly.c @@ -24,12 +24,11 @@ int T0300_readonly(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; struct scsi_mode_sense *ms; int ret, lun; unsigned char data[4096]; - int full_size; struct unmap_list list[1]; + int full_size; ret = -1; @@ -67,21 +66,9 @@ int T0300_readonly(const char *initiator, const char *url) } /* This test is only valid for SBC devices */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("LUN is not SBC device. Skipping test\n"); - scsi_free_scsi_task(task); - return -1; + return -2; } /* verify the device is readonly */ diff --git a/test-tool/0360_startstopunit_simple.c b/test-tool/0360_startstopunit_simple.c index 087755b..a80a9cf 100644 --- a/test-tool/0360_startstopunit_simple.c +++ b/test-tool/0360_startstopunit_simple.c @@ -25,9 +25,7 @@ int T0360_startstopunit_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; printf("0360_startstopunit_simple:\n"); printf("===================\n"); @@ -47,32 +45,6 @@ int T0360_startstopunit_simple(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0361_startstopunit_pwrcnd.c b/test-tool/0361_startstopunit_pwrcnd.c index 5b8ba8e..ba92b6a 100644 --- a/test-tool/0361_startstopunit_pwrcnd.c +++ b/test-tool/0361_startstopunit_pwrcnd.c @@ -25,9 +25,7 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, i, lun, removable; - int full_size; + int ret, i, lun; printf("0361_startstopunit_pwrcnd:\n"); printf("===================\n"); @@ -45,32 +43,6 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0362_startstopunit_noloej.c b/test-tool/0362_startstopunit_noloej.c index 96a45d0..2d0b056 100644 --- a/test-tool/0362_startstopunit_noloej.c +++ b/test-tool/0362_startstopunit_noloej.c @@ -25,9 +25,7 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; printf("0362_startstopunit_noloej:\n"); printf("===================\n"); @@ -51,32 +49,6 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0370_nomedia.c b/test-tool/0370_nomedia.c index 3f67ffa..9281fee 100644 --- a/test-tool/0370_nomedia.c +++ b/test-tool/0370_nomedia.c @@ -25,9 +25,7 @@ int T0370_nomedia(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; unsigned char buf[4096]; printf("0370_nomedia:\n"); @@ -73,42 +71,13 @@ int T0370_nomedia(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - - ret = 0; - - if (!removable) { printf("Media is not removable. Skipping test.\n"); ret = -2; goto finished; } - + ret = 0; printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); diff --git a/test-tool/0380_preventallow_simple.c b/test-tool/0380_preventallow_simple.c index 466d398..abc8bbc 100644 --- a/test-tool/0380_preventallow_simple.c +++ b/test-tool/0380_preventallow_simple.c @@ -25,9 +25,7 @@ int T0380_preventallow_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; printf("0380_preventallow_simple:\n"); printf("=========================\n"); @@ -45,32 +43,6 @@ int T0380_preventallow_simple(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0381_preventallow_eject.c b/test-tool/0381_preventallow_eject.c index b4cc647..e3aee4b 100644 --- a/test-tool/0381_preventallow_eject.c +++ b/test-tool/0381_preventallow_eject.c @@ -25,9 +25,7 @@ int T0381_preventallow_eject(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; printf("0381_preventallow_eject:\n"); printf("========================\n"); @@ -47,48 +45,21 @@ int T0381_preventallow_eject(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; goto finished; } - - ret = 0; - - if (!removable) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; } + ret = 0; + + printf("Try to set PREVENTALLOW ... "); task = iscsi_preventallow_sync(iscsi, lun, 1); if (task == NULL) { diff --git a/test-tool/0382_preventallow_itnexus_loss.c b/test-tool/0382_preventallow_itnexus_loss.c index 944fbc4..6c57da2 100644 --- a/test-tool/0382_preventallow_itnexus_loss.c +++ b/test-tool/0382_preventallow_itnexus_loss.c @@ -25,9 +25,7 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; printf("0382_preventallow_itnexus_loss:\n"); printf("===============================\n"); @@ -49,32 +47,6 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; diff --git a/test-tool/0383_preventallow_target_warm_reset.c b/test-tool/0383_preventallow_target_warm_reset.c index a4be3bc..5c91591 100644 --- a/test-tool/0383_preventallow_target_warm_reset.c +++ b/test-tool/0383_preventallow_target_warm_reset.c @@ -41,9 +41,7 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; struct mgmt_task mgmt_task = {0, 0}; struct pollfd pfd; @@ -67,48 +65,21 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; goto finished; } - - ret = 0; - - if (!removable) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; } + ret = 0; + + printf("Try to set PREVENTALLOW ... "); task = iscsi_preventallow_sync(iscsi, lun, 1); if (task == NULL) { diff --git a/test-tool/0384_preventallow_target_cold_reset.c b/test-tool/0384_preventallow_target_cold_reset.c index 0873001..00eadbd 100644 --- a/test-tool/0384_preventallow_target_cold_reset.c +++ b/test-tool/0384_preventallow_target_cold_reset.c @@ -41,9 +41,7 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; struct mgmt_task mgmt_task = {0, 0}; struct pollfd pfd; @@ -67,47 +65,20 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; goto finished; } - - - ret = 0; - if (!removable) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; } + + ret = 0; + printf("Try to set PREVENTALLOW ... "); task = iscsi_preventallow_sync(iscsi, lun, 1); diff --git a/test-tool/0385_preventallow_lun_reset.c b/test-tool/0385_preventallow_lun_reset.c index 52f8048..bdb770b 100644 --- a/test-tool/0385_preventallow_lun_reset.c +++ b/test-tool/0385_preventallow_lun_reset.c @@ -41,9 +41,7 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; struct mgmt_task mgmt_task = {0, 0}; struct pollfd pfd; @@ -67,47 +65,20 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; goto finished; } - - - ret = 0; - if (!removable) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; } + + ret = 0; + printf("Try to set PREVENTALLOW ... "); task = iscsi_preventallow_sync(iscsi, lun, 1); diff --git a/test-tool/0386_preventallow_2_it_nexuses.c b/test-tool/0386_preventallow_2_it_nexuses.c index b1be112..bed2b99 100644 --- a/test-tool/0386_preventallow_2_it_nexuses.c +++ b/test-tool/0386_preventallow_2_it_nexuses.c @@ -26,9 +26,7 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) struct iscsi_context *iscsi; struct iscsi_context *iscsi2 = NULL; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret, lun, removable; - int full_size; + int ret, lun; printf("0386_preventallow_2_itl_nexuses:\n"); printf("============================\n"); @@ -50,41 +48,11 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - removable = inq->rmb; - - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; goto finished; } - - - ret = 0; - if (!removable) { printf("Media is not removable. Skipping tests\n"); @@ -92,6 +60,8 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) goto finished; } + ret = 0; + printf("Try to set PREVENTALLOW on 2 different IT_Nexusen ... "); task = iscsi_preventallow_sync(iscsi, lun, 1); diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c index b8579c7..c7474d5 100644 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ b/test-tool/0390_mandatory_opcodes_sbc.c @@ -25,10 +25,8 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; - int ret = 0, lun, sccs, encserv; + int ret = 0, lun; unsigned char data[4096]; - int full_size; printf("0390_mandatory_opcodes_sbc:\n"); printf("===========================\n"); @@ -64,39 +62,12 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) return -1; } - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - - /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - return -1; - } - sccs = inq->sccs; - encserv = inq->encserv; - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { printf("Not a SBC device. Skipping test\n"); - scsi_free_scsi_task(task); ret = -2; goto finished; } - scsi_free_scsi_task(task); - if (!data_loss) { printf("--dataloss flag is not set. Skipping test\n"); ret = -2; @@ -104,27 +75,14 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) } - printf("Test FORMAT UNIT ... "); printf("[TEST NOT IMPLEMENTED YET]\n"); - printf("Test INQUIRY ... "); - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command: %s\n", iscsi_get_error(iscsi)); + printf("Test INQUIRY.\n"); + if (inquiry(iscsi, lun, 0, 0, 64) == -1) { ret = -1; - goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - } else { - printf("[OK]\n"); - } - scsi_free_scsi_task(task); printf("Test MAINTENANCE IN ... "); diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 9f13ef2..1450355 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -47,6 +47,10 @@ uint64_t num_blocks; int lbpme; int lbppb; int lbpme; +int removable; +enum scsi_inquiry_peripheral_device_type device_type; +int sccs; +int encserv; int data_loss; int show_info; @@ -1404,6 +1408,30 @@ int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char * return 0; } +int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize) +{ + struct scsi_task *task; + + printf("Send INQUIRY evpd:%d page_code:%d ... ", evpd, page_code); + task = iscsi_inquiry_sync(iscsi, lun, evpd, page_code, maxsize); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send INQUIRY command: %s\n", iscsi_get_error(iscsi)); + return -1; + } + if (task->status != SCSI_STATUS_GOOD) { + printf("[FAILED]\n"); + printf("INQUIRY 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 main(int argc, const char *argv[]) { poptContext pc; @@ -1420,6 +1448,8 @@ int main(int argc, const char *argv[]) struct scsi_task *task; struct scsi_readcapacity10 *rc10; struct scsi_readcapacity16 *rc16; + struct scsi_inquiry_standard *inq; + int full_size; struct poptOption popt_options[] = { { "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL }, @@ -1536,6 +1566,37 @@ int main(int argc, const char *argv[]) scsi_free_scsi_task(task); } + + + task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); + if (task == NULL || task->status != SCSI_STATUS_GOOD) { + printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); + return -1; + } + full_size = scsi_datain_getfullsize(task); + if (full_size > task->datain.size) { + scsi_free_scsi_task(task); + + /* we need more data for the full list */ + if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { + printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); + return -1; + } + } + inq = scsi_datain_unmarshall(task); + if (inq == NULL) { + printf("failed to unmarshall inquiry datain blob\n"); + scsi_free_scsi_task(task); + return -1; + } + removable = inq->rmb; + device_type = inq->device_type; + sccs = inq->sccs; + encserv = inq->encserv; + scsi_free_scsi_task(task); + + + iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index 74a7b0c..5dd97db 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -35,6 +35,10 @@ extern int lbppb; extern int lbpme; extern int data_loss; extern int show_info; +extern int removable; +extern enum scsi_inquiry_peripheral_device_type device_type; +extern int sccs; +extern int encserv; struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun); @@ -274,5 +278,6 @@ int verify16(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t int verify16_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); int verify16_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize); +int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize); #endif /* _ISCSI_TEST_H_ */