diff --git a/README b/README index e295021..ce8e06a 100644 --- a/README +++ b/README @@ -117,29 +117,6 @@ These results can be converted to JUnit format using this script: http://git.cyrusimap.org/cyrus-imapd/plain/cunit/cunit-to-junit.pl -ISCSI-TEST -========== -iscsi-test is deprecated and is being replaced by iscsi-test-cu. -No new tests will be developed for iscsi-test. - -The test-tool subdirectory contains an iSCSI/SCSI test tool. -This is a tool that is aimed at providing a comprehensive iSCSI and SCSI -emulation test suite. - -Run ./bin/iscsi-test --help and -Run ./bin/iscsi-test --list -for instructions - -Example: -$ ./bin/iscsi-test --initiator-name=iqn.ronnie.test --test=T0105_read10_invalid iscsi://127.0.0.1/iqn.ronnie.test/1 -========= -Running test T0105_read10_invalid -Read10 1 block but with iscsi ExpectedDataTransferLength==0 ... [FAILED] -Read10 of 1 block with iscsi ExpectedDataTransferLength==0 should fail. -TEST T0105_read10_invalid [FAILED] - - - LD_PRELOAD FUN ============== There is a small LD_PRELOAD hack in the src directory that intercepts a handful diff --git a/test-tool/0000_testunitready_simple.c b/test-tool/0000_testunitready_simple.c deleted file mode 100644 index 9bc13d0..0000000 --- a/test-tool/0000_testunitready_simple.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0000_testunitready_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, lun; - - printf("0000_testunitready_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic TESTUNITREADY functionality.\n"); - printf("1, Verify TESTUNITREADY works.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret=0; - - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0100_read10_simple.c b/test-tool/0100_read10_simple.c deleted file mode 100644 index 9591e0c..0000000 --- a/test-tool/0100_read10_simple.c +++ /dev/null @@ -1,97 +0,0 @@ - -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0100_read10_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0100_read10_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic READ10 functionality.\n"); - printf("1, Verify we can read the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can read the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* read the first 1 - 256 blocks at the start of the LUN */ - printf("Reading first 1-256 blocks ... "); - for (i=1; i<=256; i++) { - task = iscsi_read10_sync(iscsi, lun, 0, i * 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; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read the last 1 - 256 blocks at the end of the LUN */ - printf("Reading last 1-256 blocks ... "); - for (i=1; i<=256; i++) { - task = iscsi_read10_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 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; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0101_read10_beyond_eol.c b/test-tool/0101_read10_beyond_eol.c deleted file mode 100644 index 5c9be18..0000000 --- a/test-tool/0101_read10_beyond_eol.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0101_read10_beyond_eol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0101_read10_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that READ10 fails when reading beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Read 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Read 1-256 blocks at LBA 2^31\n"); - printf("3, Read 1-256 blocks at LBA -1\n"); - printf("4, Read 2-256 blocks all but one beyond end-of-lun.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with READ10. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* read 1-256 blocks, one block beyond the end-of-lun */ - printf("Reading last 1-256 blocks one block beyond eol ... "); - for (i=1; i<=256; i++) { - task = iscsi_read10_sync(iscsi, lun, num_blocks + 2 - i, i * 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 beyond end-of-lun did not fail with sense.\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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* Reading 1 - 256 blocks at LBA 2^31 */ - printf("Reaing 1-256 blocks at LBA 2^31 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_read10_sync(iscsi, lun, 0x80000000, i * 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 should fail when reading from LBA 2^31\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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 256 blocks at LBA -1 */ - printf("Read 1-256 blocks at LBA -1 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_read10_sync(iscsi, lun, -1, i * 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 should fail when reading at LBA -1\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { - printf("[FAILED]\n"); - printf("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_read10_sync(iscsi, lun, num_blocks, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0102_read10_0blocks.c b/test-tool/0102_read10_0blocks.c deleted file mode 100644 index 8f86c92..0000000 --- a/test-tool/0102_read10_0blocks.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0102_read10_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0102_read10_0blocks:\n"); - printf("====================\n"); - if (show_info) { - printf("Test that READ10 works correctly when transfer length is 0 blocks.\n"); - printf("1, Read at LBA:0 should work.\n"); - printf("2, Read at one block beyond end-of-lun should fail. (only on LUNs with less than 2^31 blocks)\n"); - printf("3, Read at LBA:2^31 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("4, Read at LBA:-1 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - printf("READ10 0blocks at LBA:0 ... "); - task = iscsi_read10_sync(iscsi, lun, 0, 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 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; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ10 0blocks at one block beyond ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_read10_sync(iscsi, lun, num_blocks + 2, 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ10 0blocks at LBA 2^31 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ10 0blocks at LBA -1 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0103_read10_rdprotect.c b/test-tool/0103_read10_rdprotect.c deleted file mode 100644 index 9932385..0000000 --- a/test-tool/0103_read10_rdprotect.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0103_read10_rdprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0103_read10_rdprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how READ10 handles the rdprotect bits\n"); - printf("1, Any non-zero valued for rdprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - ret = 0; - - /* Try out Different non-zero values for RDPROTECT. They should all fail */ - printf("Read10 with non-zero RDPROTECT ... "); - for (i = 1; i < 8; i++) { - - task = malloc(sizeof(struct scsi_task)); - - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[1] = (i<<5)&0xe0; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read10 command: %s\n", iscsi_get_error(iscsi)); - 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_INVALID_FIELD_IN_CDB) { - printf("[FAILED]\n"); - printf("READ10 with rdprotect should fail with ILLEGAL REQUEST/INVALID_FIELD_IN_CDB\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0104_read10_flags.c b/test-tool/0104_read10_flags.c deleted file mode 100644 index e0a6955..0000000 --- a/test-tool/0104_read10_flags.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0104_read10_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0104_read10_flags:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test how READ10 handles DPO, FUA and FUA_NV flags.\n"); - printf("1, DPO:1 should work\n"); - printf("2, FUA:1 and FUA_NV:0 should work\n"); - printf("3, FUA:1 and FUA_NV:1 should work\n"); - printf("4, FUA:0 and FUA_NV:1 should work\n"); - printf("5, DPO:1 , FUA:1 and FUA_NV:1 should work\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - ret = 0; - - - /* Try out DPO : 1 */ - printf("Read10 with DPO==1 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[1] = 0x10; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 with DPO==1 Failed. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - - /* Try out FUA : 1 FUA_NV : 0 */ - printf("Read10 with FUA==1 FUA_NV==0 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[1] = 0x08; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 with FUA==1 FUA_NV==0 Failed. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try out FUA : 1 FUA_NV : 1 */ - printf("Read10 with FUA==1 FUA_NV==1 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[1] = 0x0a; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 with FUA==1 FUA_NV==1 Failed. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try out FUA : 0 FUA_NV : 1 */ - printf("Read10 with FUA==0 FUA_NV==1 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[1] = 0x02; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 with FUA==0 FUA_NV==1 Failed. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try out DPO : 1 FUA : 1 FUA_NV : 1 */ - printf("Read10 with DPO==1 FUA==1 FUA_NV==1 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[1] = 0x18; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 with DPO==1 FUA==1 FUA_NV==0Failed. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0105_read10_invalid.c b/test-tool/0105_read10_invalid.c deleted file mode 100644 index 1440fbb..0000000 --- a/test-tool/0105_read10_invalid.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -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]; - int ret, lun; - - printf("0105_read10_invalid:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test various protocol violations.\n"); - printf("1, Read 1 block but set xferlength to 0. Should result in residual overflow of 'block_size' bytes.\n"); - printf("2, Read 1 block but set xferlength to 2*'block_size'. Should result in residual underflow of 'block_size' bytes.\n"); - printf("3, Read 1 block but set xferlength to 200. Should result in residual overflow of 'block_size'-200 bytes.\n"); - printf("4, Read 2 blocks but set xferlength to 'block_size'. Should result in residual overflow of 'block_size' bytes.\n"); - printf("5, Read 1 block but send one block as data-out write on the iSCSI level. Should result in both residual overflow and underflow of 'block_size' bytes.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - /* Try a read of 1 block but xferlength == 0 */ - printf("Read10 1 block but with iscsi ExpectedDataTransferLength==0 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = 0; - - /* we don't want autoreconnect since some targets will drop the session - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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_CANCELLED) { - scsi_free_scsi_task(task); - printf("Target dropped the session [OK]\n"); - 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 finished; - } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || - task->residual != block_size) { - printf("[FAILED]\n"); - printf("Read10 returned incorrect residual overflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - - /* Try a read of 1 block but xferlength == 1024 */ - printf("Read10 1 block but with iscsi ExpectedDataTransferLength==1024 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = 1024; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 of 1 block with iscsi ExpectedDataTransferLength==1024 should not fail.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || - task->residual != block_size) { - printf("[FAILED]\n"); - printf("Read10 returned incorrect residual underflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try a read of 1 block but xferlength == 200 */ - printf("Read10 1 block but with iscsi ExpectedDataTransferLength==200 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = 200; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 of 1 block with iscsi ExpectedDataTransferLength==200 should not fail.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || - task->residual != block_size - 200) { - printf("[FAILED]\n"); - printf("Read10 returned incorrect residual overflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try a read of 2 blocks but xferlength == 'block_size' */ - printf("Read10 2 blocks but with iscsi ExpectedDataTransferLength==%zu ... ", block_size); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[8] = 2; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == 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 of 2 blocks with iscsi ExpectedDataTransferLength==%zu should succeed.\n", block_size); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || - task->residual != block_size) { - printf("[FAILED]\n"); - printf("Read10 returned incorrect residual overflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ10; - task->cdb[8] = 1; - task->cdb_size = 10; - task->xfer_dir = SCSI_XFER_WRITE; - task->expxferlen = sizeof(buf); - - data.size = sizeof(buf); - data.data = (unsigned char *)&buf[0]; - - if (iscsi_scsi_command_sync(iscsi, lun, task, &data) == 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 of 1 block but iscsi data-out write should fail.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0110_readcapacity10_simple.c b/test-tool/0110_readcapacity10_simple.c deleted file mode 100644 index 09a62de..0000000 --- a/test-tool/0110_readcapacity10_simple.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0110_readcapacity10_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_readcapacity10 *rc10; - int ret, lun; - - ret = 0; - - printf("0110_readcapacity10_simple:\n"); - printf("===========================\n"); - if (show_info) { - printf("Test that basic READCAPACITY10 works\n"); - printf("1, Readcapacity10 should work.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - printf("Test that Readcapacity10 is supported ... "); - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send readcapacity10 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)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0120_read6_simple.c b/test-tool/0120_read6_simple.c deleted file mode 100644 index af4b362..0000000 --- a/test-tool/0120_read6_simple.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0120_read6_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0120_read6_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic READ6 functionality.\n"); - printf("1, Verify we can read the first 1-256 blocks of the LUN using READ6.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* read the first 1 - 256 blocks at the start of the LUN */ - printf("Reading first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_read6_sync(iscsi, lun, 0, i * block_size, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read6 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0121_read6_beyond_eol.c b/test-tool/0121_read6_beyond_eol.c deleted file mode 100644 index ff1cb68..0000000 --- a/test-tool/0121_read6_beyond_eol.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0121_read6_beyond_eol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0121_read6_beyond_eol:\n"); - printf("======================\n"); - if (show_info) { - printf("Test that READ6 fails if reading beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^20 blocks\n"); - printf("1, Read 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Read 2-256 blocks all but one beyond end-of-lun.\n"); - printf("3, Read 0(==256) blocks 128 blocks beyond end-of-lun.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - if (num_blocks > 0x1fffff) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with READ6. Skipping test.\n"); - ret = -2; - goto finished; - } - - - /* read 1-256 blocks, one block beyond the end-of-lun */ - printf("Reading last 1-256 blocks one block beyond eol ... "); - for (i=1; i<=256; i++) { - task = iscsi_read6_sync(iscsi, lun, num_blocks + 2 - i, i * block_size, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_read6_sync(iscsi, lun, num_blocks, i * block_size, block_size); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0122_read6_invalid.c b/test-tool/0122_read6_invalid.c deleted file mode 100644 index fb4599c..0000000 --- a/test-tool/0122_read6_invalid.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -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]; - int ret, lun; - - printf("0122_read6_invalid:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test various protocol violations.\n"); - printf("1, Read 1 block but set xferlength to 0. Should result in residual overflow of 'block_size' bytes.\n"); - printf("2, Read 1 block but set xferlength to 2*'block_size'. Should result in residual underflow of 'block_size' bytes.\n"); - printf("3, Read 1 block but set xferlength to 200. Should result in residual overflow of 'block_size' - 200 bytes.\n"); - printf("4, Read 2 blocks but set xferlength to 'block_size'. Should result in residual overflow of 'block_size' bytes.\n"); - printf("5, Read 1 block but send one block as data-out write on the iSCSI level. Should result in both residual overflow and underflow of 'block_size' bytes.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* Try a read of 1 block but xferlength == 0 */ - printf("Read6 1 block but with iscsi ExpectedDataTransferLength==0 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ6; - task->cdb[4] = 1; - task->cdb_size = 6; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = 0; - - /* we don't want autoreconnect since some targets will drop the session - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - - goto finished; - } - if (task->status == SCSI_STATUS_CANCELLED) { - scsi_free_scsi_task(task); - printf("Target dropped the session [OK]\n"); - 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 finished; - } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || - task->residual != block_size) { - printf("[FAILED]\n"); - printf("Read6 returned incorrect residual overflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - - /* Try a read of 1 block but xferlength == 1024 */ - printf("Read6 1 block but with iscsi ExpectedDataTransferLength==1024 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ6; - task->cdb[4] = 1; - task->cdb_size = 6; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = 1024; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==1024 should not fail.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || - task->residual != block_size) { - printf("[FAILED]\n"); - printf("Read6 returned incorrect residual underflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try a read of 1 block but xferlength == 200 */ - printf("Read6 1 block but with iscsi ExpectedDataTransferLength==200 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ6; - task->cdb[4] = 1; - task->cdb_size = 6; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = 200; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==200 should not fail.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || - task->residual != block_size - 200) { - printf("[FAILED]\n"); - printf("Read6 returned incorrect residual overflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Try a read of 2 blocks but xferlength == block_size */ - printf("Read6 2 blocks but with iscsi ExpectedDataTransferLength==%zu ... ", block_size); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ6; - task->cdb[4] = 2; - task->cdb_size = 6; - task->xfer_dir = SCSI_XFER_READ; - task->expxferlen = block_size; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read6 of 2 blocks with iscsi ExpectedDataTransferLength==%zu should succeed.\n", block_size); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || - task->residual != block_size) { - printf("[FAILED]\n"); - printf("Read6 returned incorrect residual overflow.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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 ... "); - - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = SCSI_OPCODE_READ6; - task->cdb[4] = 1; - task->cdb_size = 6; - task->xfer_dir = SCSI_XFER_WRITE; - task->expxferlen = sizeof(buf); - - data.size = sizeof(buf); - data.data = (unsigned char *)&buf[0]; - - if (iscsi_scsi_command_sync(iscsi, lun, task, &data) == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read6 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read6 of 1 block but iscsi data-out write should fail.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0130_verify10_simple.c b/test-tool/0130_verify10_simple.c deleted file mode 100644 index 07b9c24..0000000 --- a/test-tool/0130_verify10_simple.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0130_verify10_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0130_verify10_simple:\n"); - printf("=====================\n"); - if (show_info) { - printf("Test basic VERIFY10 functionality.\n"); - printf("1, Read and verify the first 1-256 blocks of the LUN using READ10/VERIFY10.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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; - - - /* 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++) { - ret = verify10(iscsi, lun, 0, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0131_verify10_mismatch.c b/test-tool/0131_verify10_mismatch.c deleted file mode 100644 index c8fdaa9..0000000 --- a/test-tool/0131_verify10_mismatch.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0131_verify10_mismatch(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - - printf("0131_verify10_mismatch:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test basic VERIFY10 functionality.\n"); - printf("1, Verify the first 1-256 blocks with a deliberate error detects the mismatch.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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("Verify first 1-256 blocks with a miscompare.\n"); - for (i = 1; i <= 256; i++) { - int offset = random() % (i * block_size); - - /* flip a random byte in the data */ - buf[offset] ^= 'X'; - - ret = verify10_miscompare(iscsi, lun, 0, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - - /* flip the byte back */ - buf[offset] ^= 'X'; - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0132_verify10_mismatch_no_cmp.c b/test-tool/0132_verify10_mismatch_no_cmp.c deleted file mode 100644 index 244162d..0000000 --- a/test-tool/0132_verify10_mismatch_no_cmp.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0132_verify10_mismatch_no_cmp:\n"); - printf("==============================\n"); - if (show_info) { - printf("Test VERIFY10 BYTCHK:0 only checks medium and should never fail unless the medium is bad.\n"); - printf("1, Read the first 256 blocks and verify the medium is good.\n"); - printf("2, Verify the first 1-256 blocks retruns SUCCESS if BYTCHK is 0\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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("Verify first 1-256 blocks with a miscompare but BYTCHK==0.\n"); - for (i = 1; i <= 256; i++) { - int offset = random() % (i * block_size); - - /* flip a random byte in the data */ - buf[offset] ^= 'X'; - - ret = verify10(iscsi, lun, 0, i * block_size, block_size, 0, 1, 0, buf); - if (ret != 0) { - goto finished; - } - - /* flip the byte back */ - buf[offset] ^= 'X'; - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0133_verify10_beyondeol.c b/test-tool/0133_verify10_beyondeol.c deleted file mode 100644 index 060a29a..0000000 --- a/test-tool/0133_verify10_beyondeol.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0133_verify10_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0133_verify10_beyond_eol:\n"); - printf("========================\n"); - if (show_info) { - printf("Test that VERIFY10 fails if reading beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Verify 2-256 blocks one block beyond end-of-lun.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with VERIFY10. Skipping test.\n"); - ret = -2; - goto finished; - } - - buf = malloc(256 * block_size); - - /* verify 2 - 256 blocks beyond the end of the device */ - printf("Verifying 2-256 blocks beyond end-of-device.\n"); - for (i = 2; i <= 256; i++) { - ret = verify10_lbaoutofrange(iscsi, lun, num_blocks, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0160_readcapacity16_simple.c b/test-tool/0160_readcapacity16_simple.c deleted file mode 100644 index a62e24c..0000000 --- a/test-tool/0160_readcapacity16_simple.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0160_readcapacity16_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_readcapacity16 *rc; - 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("\n"); - return 0; - } - - ret = 0; - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - 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)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - rc = scsi_datain_unmarshall(task); - if (rc == NULL) { - printf("[FAILED]\n"); - 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); - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0161_readcapacity16_alloclen.c b/test-tool/0161_readcapacity16_alloclen.c deleted file mode 100644 index 7fd2102..0000000 --- a/test-tool/0161_readcapacity16_alloclen.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0161_readcapacity16_alloclen(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0161_readcapacity16_alloclen:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test allocation-length for READCAPACITY16\n"); - printf("1, READCAPACITY16 with alloclen==0 is not an error\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - printf("READCAPACITY16 with AllocationLength==0 ... "); - task = malloc(sizeof(struct scsi_task)); - if (task == NULL) { - printf("Failed to allocate task structure\n"); - ret = -1; - goto finished; - } - - memset(task, 0, sizeof(struct scsi_task)); - task->cdb[0] = 0x9e; - task->cdb[1] = 0x10; - task->cdb_size = 16; - task->xfer_dir = SCSI_XFER_NONE; - task->expxferlen = 0; - - if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) { - printf("[FAILED]\n"); - 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("READCAPACITY16 with AllocationLength==0 should not fail. Sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0170_unmap_simple.c b/test-tool/0170_unmap_simple.c deleted file mode 100644 index 830209e..0000000 --- a/test-tool/0170_unmap_simple.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0170_unmap_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0170_unmap_simple:\n"); - printf("==================\n"); - if (show_info) { - printf("Test basic UNMAP functionality.\n"); - printf("1, Test UNMAP the first 1-256 blocks of the LUN.\n"); - printf("2, Test UNMAP the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!data_loss) { - printf("data_loss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* unmap the first 1 - 256 blocks at the start of the LUN */ - printf("Unmapping first 1-256 blocks ... "); - for (i=1; i<=256; i++) { - struct unmap_list list[1]; - - list[0].lba = 0; - list[0].num = i; - task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); - 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; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* unmap the last 1 - 256 blocks at the end of the LUN */ - printf("Unmapping last 1-256 blocks ... "); - for (i=1; i<=256; i++) { - struct unmap_list list[1]; - - list[0].lba = num_blocks + 1 - i; - list[0].num = i; - task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); - 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; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0171_unmap_zero.c b/test-tool/0171_unmap_zero.c deleted file mode 100644 index 8649349..0000000 --- a/test-tool/0171_unmap_zero.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0171_unmap_zero(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0171_unmap_zero:\n"); - printf("================\n"); - if (show_info) { - printf("Test UNMAP of 0 blocks.\n"); - printf("1, Try to UNMAP 0 blocks at LBA 0 to LBA 255\n"); - printf("2, Try to UNMAP 0 blocks at 0 to 255 blocks from end-of-lun\n"); - printf("3, Try to UNMAP 0 blocks at 1 to 256 blocks beyond end-of-lun\n"); - printf("4, Send UNMAP without any block descriptors\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!data_loss) { - printf("data_loss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* unmap no blocks at LBA 0 - 255 */ - printf("Unmapping of no block at lbas 0-255 blocks ... "); - for (i=0; i<=255; i++) { - struct unmap_list list[1]; - - list[0].lba = i; - list[0].num = 0; - task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); - 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; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* unmap no blocks at the last 1 - 256 blocks at the end of the LUN */ - printf("Unmapping last 1-256 blocks ... "); - for (i=0; i<=255; i++) { - struct unmap_list list[1]; - - list[0].lba = num_blocks - i; - list[0].num = 0; - task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); - 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; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - /* unmap no blocks 0-255 blocks beyond the end of the LUN */ - printf("Unmapping no blocks but 0-255 blocks beyong end of LUN... "); - for (i=0; i<=255; i++) { - struct unmap_list list[1]; - - list[0].lba = num_blocks + 1 + i; - list[0].num = 0; - task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); - 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("STATUS==GOOD. UNMAP command should fail with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\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("UNMAP fail but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - /* unmap with no block descriptors at all */ - printf("Unmap without any block descriptors ... "); - 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; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0180_writesame10_unmap.c b/test-tool/0180_writesame10_unmap.c deleted file mode 100644 index c95ab40..0000000 --- a/test-tool/0180_writesame10_unmap.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0180_writesame10_unmap(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int full_size; - struct scsi_inquiry_logical_block_provisioning *lbp; - int ret, i, lun; - - printf("0180_writesame10_unmap:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test basic WRITESAME10-UNMAP functionality.\n"); - printf("1, If LBPME==1 we should have VPD page 0xB2\n"); - printf("2, UNMAP the first 1-256 blocks at the start of the LUN\n"); - printf("3, UNMAP the last 1-256 blocks at the end of the LUN\n"); - printf("4, Verify that UNMAP == 0 and ANCHOR == 1 is invalid\n"); - printf("5, UNMAP == 1 and ANCHOR == 1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned.\n"); - printf("[SKIPPED]\n"); - printf("LUN does not use thin provisioning. LBPME==0.\n"); - ret = -2; - goto finished; - } - - /* Check that if we have logical block provisioning we also have the VPD page for it */ - printf("Logical Block Provisioning is available. Check that VPD page 0xB2 exists ... "); - - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - 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, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, full_size)) == NULL) { - printf("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - - lbp = scsi_datain_unmarshall(task); - if (lbp == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - if (lbp->lbpws10 == 0) { - printf("Device does not support WRITE_SAME10 for UNMAP. All WRITE_SAME10 commands to unmap should fail.\n"); - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* unmap the first 1 - 256 blocks at the start of the LUN */ - printf("Unmapping first 1-256 blocks ... "); - if (lbp->lbpws10 == 0) { - printf("(Should all fail since LBPWS10 is 0) "); - } - for (i=1; i<=256; i++) { - /* only try unmapping whole physical blocks, of if unmap using ws10 is not supported - we test for all and they should all fail */ - if (lbp->lbpws10 == 1 && i % lbppb) { - continue; - } - task = iscsi_writesame10_sync(iscsi, lun, 0, - NULL, 0, - i, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - if (lbp->lbpws10) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } else { - 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("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 finished; - } - } - - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* unmap the last 1 - 256 blocks at the end of the LUN */ - printf("Unmapping last 1-256 blocks ... "); - if (lbp->lbpws10 == 0) { - printf("(Should all fail since LBPWS10 is 0) "); - } - for (i=1; i<=256; i++) { - /* only try unmapping whole physical blocks, of if unmap using ws10 is not supported - we test for all and they should all fail */ - if (lbp->lbpws10 == 1 && i % lbppb) { - continue; - } - - task = iscsi_writesame10_sync(iscsi, lun, num_blocks + 1 - i, - NULL, 0, - i, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (lbp->lbpws10) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } else { - 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("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 finished; - } - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* Test that UNMAP=0 and ANCHOR==1 fails with check condition */ - printf("Try UNMAP==0 and ANCHOR==1 ... "); - task = iscsi_writesame10_sync(iscsi, lun, 0, - NULL, 0, - 64, - 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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("WRITESAME10 with UNMAP=0 ANCHOR=1 failed with wrong sense code %d %s(%d) %s(0x%04x) should be CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n", - task->status, - scsi_sense_key_str(task->sense.key), task->sense.key, - scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Test UNMAP=1 and ANCHOR==1 */ - printf("Try UNMAP==1 and ANCHOR==1 ... "); - if (lbp->anc_sup == 0) { - printf("(ANC_SUP==0 so check condition expected) "); - } - task = iscsi_writesame10_sync(iscsi, lun, 0, - NULL, 0, - 64, - 1, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (lbp->anc_sup == 0) { - 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("WRITESAME10 with UNMAP=1 ANCHOR=1 failed with wrong sense code %d %s(%d) %s(0x%04x) should be CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n", - task->status, - scsi_sense_key_str(task->sense.key), task->sense.key, - scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } else { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0181_writesame10_unmap_unaligned.c b/test-tool/0181_writesame10_unmap_unaligned.c deleted file mode 100644 index 692a076..0000000 --- a/test-tool/0181_writesame10_unmap_unaligned.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0181_writesame10_unmap_unaligned:\n"); - printf("=================================\n"); - if (show_info) { - printf("Test unaligned WRITESAME10-UNMAP functionality.\n"); - printf("1, UNMAP the first 1-lbppb blocks at the start of the LUN\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned. Skipping test\n"); - ret = -2; - goto finished; - } - - - if (lbppb < 2) { - printf("LBPPB==%d Can not unmap fractional physical block\n", lbppb); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* unmap the first 1 - lbppb blocks at the start of the LUN */ - printf("Unmapping first 1 - (LBPPB-1) blocks ... "); - for (i=1; i < lbppb; i++) { - task = iscsi_writesame10_sync(iscsi, lun, 0, - NULL, 0, - i, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME10 command to unmap a fractional physical block should fail\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0182_writesame10_beyondeol.c b/test-tool/0182_writesame10_beyondeol.c deleted file mode 100644 index 2b2a020..0000000 --- a/test-tool/0182_writesame10_beyondeol.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0182_writesame10_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char buf[4096]; - - printf("0182_writesame10_beyondeol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITESAME10 fails if writing beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Write 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Write 1-256 blocks at LBA 2^31\n"); - printf("3, Write 1-256 blocks at LBA -1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with WRITESAME10. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* write 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_writesame10_sync(iscsi, lun, num_blocks, - buf, block_size, - i, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME10 command should fail when writing 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* writing 1 - 256 blocks at LBA 2^31 */ - printf("Writing 1-256 blocks at LBA 2^31 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writesame10_sync(iscsi, lun, 0x80000000, - buf, block_size, - i, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write 1 - 256 blocks at LBA -1 */ - printf("Writing 1-256 blocks at LBA -1 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writesame10_sync(iscsi, lun, -1, - buf, block_size, - i, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0183_writesame10_wrprotect.c b/test-tool/0183_writesame10_wrprotect.c deleted file mode 100644 index 3ac228b..0000000 --- a/test-tool/0183_writesame10_wrprotect.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0183_writesame10_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char buf[4096]; - - printf("0183_writesame10_wrptotect:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITESAME10 wrprotect\n"); - printf("1, Write using WRPROTECT as non-zero\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* Writesame10 with wrprotect */ - printf("WRITESAME10 with WRPROTECT ... "); - for (i = 1; i <= 7; i++) { - task = iscsi_writesame10_sync(iscsi, lun, 0, - buf, block_size, - 1, - 0, 0, i, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME10 command should fail when WRPROTECT is set\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_INVALID_FIELD_IN_CDB) { - printf("[FAILED]\n"); - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0184_writesame10_0blocks.c b/test-tool/0184_writesame10_0blocks.c deleted file mode 100644 index e8d2c23..0000000 --- a/test-tool/0184_writesame10_0blocks.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0184_writesame10_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - unsigned char buf[4096]; - - printf("0184_writesame10_0blocks:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITESAME10 works correctly when transfer length is 0 blocks.\n"); - printf("1, Writesame at LBA:0 should work.\n"); - printf("2, Writesame at one block beyond end-of-lun should fail. (only on LUNs with less than 2^31 blocks)\n"); - printf("3, Writesame at LBA:2^31 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("4, Writesame at LBA:-1 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - printf("Writesame10 0blocks at LBA:0 ... "); - task = iscsi_writesame10_sync(iscsi, lun, 0, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - if (inq_bl == NULL) { - printf("[SKIPPED]\n"); - printf("Target does not support block limits VPD\n"); - ret = -2; - goto finished; - } - if ((!inq_bl->wsnz && task->status != SCSI_STATUS_GOOD) || - (inq_bl->wsnz && task->status != SCSI_STATUS_CHECK_CONDITION)) { - printf("[FAILED]\n"); - printf("WRITESAME10 command: failed with sense and WSNZ = %d. " - "%s\n", inq_bl->wsnz, iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Writesame10 0blocks at one block beyond ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_writesame10_sync(iscsi, lun, num_blocks + 2, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Writesame10 0blocks at LBA 2^31 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_writesame10_sync(iscsi, lun, 0x80000000, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Writesame10 0blocks at LBA -1 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_writesame10_sync(iscsi, lun, -1, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0190_writesame16_unmap.c b/test-tool/0190_writesame16_unmap.c deleted file mode 100644 index 73fb49d..0000000 --- a/test-tool/0190_writesame16_unmap.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0190_writesame16_unmap(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int full_size; - struct scsi_inquiry_logical_block_provisioning *lbp; - int ret, i, lun; - - printf("0190_writesame16_unmap:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test basic WRITESAME16-UNMAP functionality.\n"); - printf("1, If LBPME==1 we should have VPD page 0xB2\n"); - printf("2, UNMAP the first 1-256 blocks at the start of the LUN\n"); - printf("3, UNMAP the last 1-256 blocks at the end of the LUN\n"); - printf("4, Verify that UNMAP == 0 and ANCHOR == 1 is invalid\n"); - printf("5, UNMAP == 1 and ANCHOR == 1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("LBPME not set. Skip test for CPD page 0xB2 (logical block provisioning)\n"); - goto finished; - } - - /* Check that id we have logical block provisioning we also have the VPD page for it */ - printf("Logical Block Provisioning is available. Check that VPD page 0xB2 exists ... "); - - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - 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, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, full_size)) == NULL) { - printf("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - - lbp = scsi_datain_unmarshall(task); - if (lbp == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - if (lbp->lbpws == 0) { - printf("Device does not support WRITE_SAME16 for UNMAP. All WRITE_SAME16 commands to unmap should fail.\n"); - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* unmap the first 1 - 256 blocks at the start of the LUN */ - printf("Unmapping first 1-256 blocks ... "); - if (lbp->lbpws == 0) { - printf("(Should all fail since LBPWS is 0) "); - } - for (i=1; i<=256; i++) { - /* only try unmapping whole physical blocks, of if unmap using ws16 is not supported - we test for all and they should all fail */ - if (lbp->lbpws == 1 && i % lbppb) { - continue; - } - task = iscsi_writesame16_sync(iscsi, lun, 0, - NULL, 0, - i, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("Opcode is not implemented on target\n"); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - if (lbp->lbpws) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } else { - 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("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 finished; - } - } - - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* unmap the last 1 - 256 blocks at the end of the LUN */ - printf("Unmapping last 1-256 blocks ... "); - if (lbp->lbpws == 0) { - printf("(Should all fail since LBPWS is 0) "); - } - for (i=1; i<=256; i++) { - /* only try unmapping whole physical blocks, of if unmap using ws16 is not supported - we test for all and they should all fail */ - if (lbp->lbpws == 1 && i % lbppb) { - continue; - } - - task = iscsi_writesame16_sync(iscsi, lun, num_blocks + 1 - i, - NULL, 0, - i, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (lbp->lbpws) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } else { - 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("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 finished; - } - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* Test that UNMAP=0 and ANCHOR==1 fails with check condition */ - printf("Try UNMAP==0 and ANCHOR==1 ... "); - task = iscsi_writesame16_sync(iscsi, lun, 0, - NULL, 0, - 64, - 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Test UNMAP=1 and ANCHOR==1 */ - printf("Try UNMAP==1 and ANCHOR==1 ... "); - if (lbp->anc_sup == 0) { - printf("(ANC_SUP==0 so check condition expected) "); - } - task = iscsi_writesame16_sync(iscsi, lun, 0, - NULL, 0, - 64, - 1, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (lbp->anc_sup == 0) { - 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("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 finished; - } - } else { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0191_writesame16_unmap_unaligned.c b/test-tool/0191_writesame16_unmap_unaligned.c deleted file mode 100644 index bcb8bdd..0000000 --- a/test-tool/0191_writesame16_unmap_unaligned.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0191_writesame16_unmap_unaligned:\n"); - printf("=================================\n"); - if (show_info) { - printf("Test unaligned WRITESAME16-UNMAP functionality.\n"); - printf("1, UNMAP the first 1-lbppb blocks at the start of the LUN\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned. Skipping test\n"); - ret = -2; - goto finished; - } - - if (lbppb < 2) { - printf("LBPPB==%d Can not unmap fractional physical block\n", lbppb); - ret = -2; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* unmap the first 1 - lbppb blocks at the start of the LUN */ - printf("Unmapping first 1 - (LBPPB-1) blocks ... "); - for (i=1; i < lbppb; i++) { - task = iscsi_writesame16_sync(iscsi, lun, 0, - NULL, 0, - i, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME16 command to unmap a fractional physical block should fail\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0192_writesame16_beyondeol.c b/test-tool/0192_writesame16_beyondeol.c deleted file mode 100644 index 9ea47be..0000000 --- a/test-tool/0192_writesame16_beyondeol.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0192_writesame16_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char buf[4096]; - - printf("0192_writesame16_beyondeol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITESAME16 fails if writing beyond end-of-lun.\n"); - printf("1, Write 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Write 1-256 blocks at LBA 2^63\n"); - printf("3, Write 1-256 blocks at LBA -1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_writesame16_sync(iscsi, lun, num_blocks, - buf, block_size, - i, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME16 command should fail when writing 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* writing 1 - 256 blocks at LBA 2^63 */ - printf("Writing 1-256 blocks at LBA 2^63 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writesame16_sync(iscsi, lun, 0x8000000000000000ULL, - buf, block_size, - i, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write 1 - 256 blocks at LBA -1 */ - printf("Writing 1-256 blocks at LBA -1 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writesame16_sync(iscsi, lun, -1, - buf, block_size, - i, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0193_writesame16_wrprotect.c b/test-tool/0193_writesame16_wrprotect.c deleted file mode 100644 index 5717a3b..0000000 --- a/test-tool/0193_writesame16_wrprotect.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0193_writesame16_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char buf[4096]; - - printf("0193_writesame16_wrptotect:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITESAME16 wrprotect\n"); - printf("1, Write using WRPROTECT as non-zero\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* Writesame16 with wrprotect */ - printf("WRITESAME16 with WRPROTECT ... "); - for (i = 1; i <= 7; i++) { - task = iscsi_writesame16_sync(iscsi, lun, 0, - buf, block_size, - 1, - 0, 0, i, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME16 command should fail when WRPROTECT is set\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_INVALID_FIELD_IN_CDB) { - printf("[FAILED]\n"); - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0194_writesame16_0blocks.c b/test-tool/0194_writesame16_0blocks.c deleted file mode 100644 index 944ba4e..0000000 --- a/test-tool/0194_writesame16_0blocks.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0194_writesame16_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - unsigned char buf[4096]; - - printf("0194_writesame16_0blocks:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITESAME16 works correctly when transfer length is 0 blocks.\n"); - printf("1, Writesame at LBA:0 should work.\n"); - printf("2, Writesame at one block beyond end-of-lun should fail.\n"); - printf("3, Writesame at LBA 2^63 should fail.\n"); - printf("4, Writesame at LBA -1 should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - printf("Writesame16 0blocks at LBA:0 ... "); - task = iscsi_writesame16_sync(iscsi, lun, 0, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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_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("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Writesame16 0blocks at one block beyond ... "); - task = iscsi_writesame16_sync(iscsi, lun, num_blocks + 2, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Writesame16 0blocks at LBA 2^63 ... "); - task = iscsi_writesame16_sync(iscsi, lun, 0x8000000000000000, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Writesame16 0blocks at LBA -1 ... "); - task = iscsi_writesame16_sync(iscsi, lun, -1, - buf, block_size, - 0, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0200_read16_simple.c b/test-tool/0200_read16_simple.c deleted file mode 100644 index 486c516..0000000 --- a/test-tool/0200_read16_simple.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0200_read16_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0200_read16_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic READ16 functionality.\n"); - printf("1, Verify we can read the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can read the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* read the first 1 - 256 blocks at the start of the LUN */ - printf("Reading first 1-256 blocks ... "); - for (i=1; i<=256; i++) { - 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 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read the last 1 - 256 blocks at the end of the LUN */ - printf("Reading last 1-256 blocks ... "); - for (i=1; i<=256; i++) { - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0201_read16_rdprotect.c b/test-tool/0201_read16_rdprotect.c deleted file mode 100644 index 707ba44..0000000 --- a/test-tool/0201_read16_rdprotect.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0201_read16_rdprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - - printf("0201_read16_rdprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how READ16 handles the rdprotect bits\n"); - printf("1, Any non-zero valued for rdprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - printf("Read16 with RDPROTECT "); - for (i = 1; i <= 7; i++) { - task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, i, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) { - printf("[FAILED]\n"); - printf("Read16 with RDPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0202_read16_flags.c b/test-tool/0202_read16_flags.c deleted file mode 100644 index ed2c3af..0000000 --- a/test-tool/0202_read16_flags.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0202_read16_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0202_read16_flags:\n"); - printf("==================\n"); - if (show_info) { - printf("Test how READ16 handles the flag bits\n"); - printf("1, Reading with DPO should work\n"); - printf("2, Reading with FUA should work\n"); - printf("3, Reading with FUA_NV should work\n"); - printf("4, Reading with FUA+FUA_NV should work\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - printf("Read16 with DPO "); - task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - printf("[OK]\n"); - - printf("Read16 with FUA "); - task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - printf("[OK]\n"); - - - printf("Read16 with FUA_NV "); - task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - printf("[OK]\n"); - - printf("Read16 with FUA+FUA_NV "); - task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0203_read16_0blocks.c b/test-tool/0203_read16_0blocks.c deleted file mode 100644 index 8d21c49..0000000 --- a/test-tool/0203_read16_0blocks.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0203_read16_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0203_read16_0blocks:\n"); - printf("====================\n"); - if (show_info) { - printf("Test that READ16 works correctly when transfer length is 0 blocks.\n"); - printf("1, Read at 0 should work.\n"); - printf("2, Read at one block beyond end-of-lun should fail.\n"); - printf("3, Read at LBA:2^63 should fail.\n"); - printf("4, Read at LBA:-1 should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - printf("READ16 0blocks at LBA:0 ... "); - task = iscsi_read16_sync(iscsi, lun, 0, 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ16 0blocks at LBA: ... "); - task = iscsi_read16_sync(iscsi, lun, num_blocks + 2, 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 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 finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { - printf("[FAILED]\n"); - printf("READ16 failed but 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 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 finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { - printf("[FAILED]\n"); - printf("READ16 failed but 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 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 finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { - printf("[FAILED]\n"); - printf("READ16 failed but 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0204_read16_beyondeol.c b/test-tool/0204_read16_beyondeol.c deleted file mode 100644 index 675029c..0000000 --- a/test-tool/0204_read16_beyondeol.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0204_read16_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0204_read16_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that READ16 fails if reading beyond end-of-lun.\n"); - printf("1, Read 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Read 1-256 blocks at LBA 2^63\n"); - printf("3, Read 1-256 blocks at LBA -1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Reading 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_read16_sync(iscsi, lun, num_blocks, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command should fail when reading 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("READ16 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"); - - /* read 1 - 256 blocks at LBA 2^63 */ - printf("Reading 1-256 blocks at LBA 2^63 ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_read16_sync(iscsi, lun, 0x8000000000000000ULL, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command should fail when reading at LBA 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("READ16 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"); - - /* read 1 - 256 blocks at LBA -1 */ - printf("Reading 1-256 blocks at LBA -1 ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_read16_sync(iscsi, lun, -1, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Read16 command should fail when reading at LBA -1\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { - printf("[FAILED]\n"); - printf("READ16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0210_read12_simple.c b/test-tool/0210_read12_simple.c deleted file mode 100644 index 63b0650..0000000 --- a/test-tool/0210_read12_simple.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0210_read12_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0210_read12_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic READ12 functionality.\n"); - printf("1, Verify we can read the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can read the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* read the first 1 - 256 blocks at the start of the LUN */ - printf("Reading first 1-256 blocks ... "); - for (i=1; i<=256; i++) { - task = iscsi_read12_sync(iscsi, lun, 0, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read the last 1 - 256 blocks at the end of the LUN */ - printf("Reading last 1-256 blocks ... "); - for (i=1; i<=256; i++) { - task = iscsi_read12_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 read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0211_read12_rdprotect.c b/test-tool/0211_read12_rdprotect.c deleted file mode 100644 index 600ec7e..0000000 --- a/test-tool/0211_read12_rdprotect.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0211_read12_rdprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - - printf("0211_read12_rdprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how READ12 handles the rdprotect bits\n"); - printf("1, Any non-zero valued for rdprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - printf("Read12 with RDPROTECT "); - for (i = 1; i <= 7; i++) { - task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, i, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - 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("Read12 with RDPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0212_read12_flags.c b/test-tool/0212_read12_flags.c deleted file mode 100644 index da26717..0000000 --- a/test-tool/0212_read12_flags.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0212_read12_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0212_read12_flags:\n"); - printf("==================\n"); - if (show_info) { - printf("Test how READ12 handles the flag bits\n"); - printf("1, Reading with DPO should work\n"); - printf("2, Reading with FUA should work\n"); - printf("3, Reading with FUA_NV should work\n"); - printf("4, Reading with FUA+FUA_NV should work\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - printf("Read12 with DPO "); - task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - 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 finished; - } - printf("[OK]\n"); - - printf("Read12 with FUA "); - task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - - printf("Read12 with FUA_NV "); - task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - printf("Read12 with FUA+FUA_NV "); - task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0213_read12_0blocks.c b/test-tool/0213_read12_0blocks.c deleted file mode 100644 index 529b7c5..0000000 --- a/test-tool/0213_read12_0blocks.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0213_read12_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0213_read12_0blocks:\n"); - printf("====================\n"); - if (show_info) { - printf("Test that READ12 works correctly when transfer length is 0 blocks.\n"); - printf("1, Read at LBA:0 should work.\n"); - printf("2, Read at one block beyond end-of-lun should fail. (only on LUNs with less than 2^31 blocks)\n"); - printf("3, Read at LBA:2^31 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("4, Read at LBA:-1 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - printf("READ12 0blocks at LBA:0 ... "); - task = iscsi_read12_sync(iscsi, lun, 0, 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ12 0blocks at one block beyond ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_read12_sync(iscsi, lun, num_blocks + 2, 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 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 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ12 0blocks at LBA 2^31 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("READ12 0blocks at LBA -1 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0214_read12_beyondeol.c b/test-tool/0214_read12_beyondeol.c deleted file mode 100644 index 49bc0b1..0000000 --- a/test-tool/0214_read12_beyondeol.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0214_read12_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0214_read12_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that READ12 fails if reading beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Read 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Read 1-256 blocks at LBA 2^31\n"); - printf("2, Read 1-256 blocks at LBA -1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with READ12. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Reading 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_read12_sync(iscsi, lun, num_blocks, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READ12 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("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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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 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 = -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 = -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("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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 256 blocks at LBA -1 */ - printf("Reading 1-256 blocks at LBA -1 ... "); - if (num_blocks > 0x80000000) { - printf("LUN is too big, skipping test\n"); - 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READ12 command should fail when reading from LBA -1\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) { - printf("[FAILED]\n"); - printf("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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0220_write16_simple.c b/test-tool/0220_write16_simple.c deleted file mode 100644 index 41fb2e7..0000000 --- a/test-tool/0220_write16_simple.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0220_write16_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0220_write16_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic WRITE16 functionality.\n"); - printf("1, Verify we can write the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write the first 1 - 256 blocks at the start of the LUN */ - printf("Writing first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_write16_sync(iscsi, lun, 0, data, i * 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 = -1; - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 256 blocks at the end of the LUN */ - printf("Writing last 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_write16_sync(iscsi, lun, num_blocks +1 - i, data, i * 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 = -1; - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0221_write16_wrprotect.c b/test-tool/0221_write16_wrprotect.c deleted file mode 100644 index fe54d1c..0000000 --- a/test-tool/0221_write16_wrprotect.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0221_write16_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0221_write16_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how WRITE16 handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Write16 with WRPROTECT "); - for (i = 1; i <= 7; i++) { - task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, i, 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 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("Write16 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0222_write16_flags.c b/test-tool/0222_write16_flags.c deleted file mode 100644 index f5a7b48..0000000 --- a/test-tool/0222_write16_flags.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0222_write16_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - unsigned char data[4096 * 256]; - - printf("0222_write16_flags:\n"); - printf("===================\n"); - if (show_info) { - printf("Test how WRITE16 handles the flags\n"); - printf("1, Write with DPU should work.\n"); - printf("2, Write with FUA should work.\n"); - printf("3, Write with FUA_NV should work.\n"); - printf("4, Write with FUA+FUA_NV should work.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - printf("Write16 with DPO "); - task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - printf("Write16 with FUA "); - task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - - printf("Write16 with FUA_NV "); - task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - printf("Write16 with FUA+FUA_NV "); - task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0223_write16_0blocks.c b/test-tool/0223_write16_0blocks.c deleted file mode 100644 index 8a59d46..0000000 --- a/test-tool/0223_write16_0blocks.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0223_write16_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0223_write16_0blocks:\n"); - printf("====================\n"); - if (show_info) { - printf("Test that WRITE16 works correctly when transfer length is 0 blocks.\n"); - printf("1, Write at LBA:0 should work.\n"); - printf("2, Write at one block beyond end-of-lun should fail.\n"); - printf("3, Write at LBA:2^63 should fail.\n"); - printf("4, Write at LBA:-1 should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - printf("WRITE16 0blocks at LBA:0 ... "); - task = iscsi_write16_sync(iscsi, lun, 0, 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0224_write16_beyondeol.c b/test-tool/0224_write16_beyondeol.c deleted file mode 100644 index a4cd8b9..0000000 --- a/test-tool/0224_write16_beyondeol.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0224_write16_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0224_write16_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITE16 fails if writing beyond end-of-lun.\n"); - printf("1, Writing 1-256 blocks beyond end-of-lun should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_write16_sync(iscsi, lun, num_blocks, data, i * 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Write16 command should fail when writing beyond end of device\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0230_write12_simple.c b/test-tool/0230_write12_simple.c deleted file mode 100644 index 4244f39..0000000 --- a/test-tool/0230_write12_simple.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0230_write12_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0230_write12_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic WRITE12 functionality.\n"); - printf("1, Verify we can write the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write the first 1 - 256 blocks at the start of the LUN */ - printf("Writing first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_write12_sync(iscsi, lun, 0, data, i * 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 = -1; - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 256 blocks at the end of the LUN */ - printf("Writing last 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_write12_sync(iscsi, lun, num_blocks +1 - i, data, i * 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 = -1; - 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0231_write12_wrprotect.c b/test-tool/0231_write12_wrprotect.c deleted file mode 100644 index 1503c47..0000000 --- a/test-tool/0231_write12_wrprotect.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0231_write12_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0231_write12_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how WRITE12 handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Write12 with RDPROTECT "); - for (i = 1; i <= 7; i++) { - task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, i, 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 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("Write12 with RDPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0232_write12_flags.c b/test-tool/0232_write12_flags.c deleted file mode 100644 index b40368a..0000000 --- a/test-tool/0232_write12_flags.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0232_write12_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - unsigned char data[4096]; - - printf("0232_write12_flags:\n"); - printf("===================\n"); - if (show_info) { - printf("Test how WRITE12 handles the flags\n"); - printf("1, Write with DPU should work.\n"); - printf("2, Write with FUA should work.\n"); - printf("3, Write with FUA_NV should work.\n"); - printf("4, Write with FUA+FUA_NV should work.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - printf("Write12 with DPO "); - task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - printf("Write12 with FUA "); - task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - - printf("Write12 with FUA_NV "); - task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - printf("Write12 with FUA+FUA_NV "); - task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0233_write12_0blocks.c b/test-tool/0233_write12_0blocks.c deleted file mode 100644 index 8bf4c5a..0000000 --- a/test-tool/0233_write12_0blocks.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0233_write12_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0233_write12_0blocks:\n"); - printf("====================\n"); - if (show_info) { - printf("Test that WRITE12 works correctly when transfer length is 0 blocks.\n"); - printf("1, Write at LBA:0 should work.\n"); - printf("2, Write at one block beyond end-of-lun should fail. (only on LUNs with less than 2^31 blocks)\n"); - printf("3, Write at LBA:2^31 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("4, Write at LBA:-1 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - printf("WRITE12 0blocks at LBA:0 ... "); - task = iscsi_write12_sync(iscsi, lun, 0, 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("WRITE12 0blocks at one block beyond ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_write12_sync(iscsi, lun, num_blocks + 2, 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("WRITE12 0blocks at LBA 2^31 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("WRITE12 0blocks at LBA -1 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0234_write12_beyondeol.c b/test-tool/0234_write12_beyondeol.c deleted file mode 100644 index 955f00c..0000000 --- a/test-tool/0234_write12_beyondeol.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0234_write12_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0234_write12_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITE12 fails if writing beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Writing 1-256 blocks beyond end-of-lun should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with WRITE12. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_write12_sync(iscsi, lun, num_blocks, data, i * 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Write12 command should fail when writing beyond end of device\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0240_prefetch10_simple.c b/test-tool/0240_prefetch10_simple.c deleted file mode 100644 index 352d378..0000000 --- a/test-tool/0240_prefetch10_simple.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0240_prefetch10_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - - printf("0240_prefetch10_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic PREFETCH10 functionality.\n"); - printf("1, Verify we can prefetch the first 0-256 blocks of the LUN.\n"); - printf("2, Verify we can prefetch the last 0-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - /* prefetch the first 0 - 256 blocks at the start of the LUN */ - printf("Prefetching first 0-256 blocks.\n"); - for (i = 0; i <= 256; i++) { - ret = prefetch10(iscsi, lun, 0, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* Prefetch the last 0 - 256 blocks at the end of the LUN */ - printf("Prefetching last 0-256 blocks.\n"); - for (i = 0; i <= 256; i++) { - ret = prefetch10(iscsi, lun, num_blocks - i, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0241_prefetch10_flags.c b/test-tool/0241_prefetch10_flags.c deleted file mode 100644 index a3ec6b2..0000000 --- a/test-tool/0241_prefetch10_flags.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0241_prefetch10_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - - printf("0241_prefetch10_flags:\n"); - printf("===================\n"); - if (show_info) { - printf("Test PREFETCH10 flags.\n"); - printf("1, Test the IMMED flag.\n"); - printf("2, Test different GROUPNUMBERS.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* prefetch with IMMED==1 */ - printf("Check PREFETCH10 with IMMED==1.\n"); - ret = prefetch10(iscsi, lun, 0, 1, 1, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch with GROUPNUMBER==0..31 */ - printf("Check PREFETCH10 with GROUPNEMBER 0-31.\n"); - for (i = 0; i < 32; i++) { - ret = prefetch10(iscsi, lun, 0, 1, 0, i); - if (ret != 0) { - goto finished; - } - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0242_prefetch10_beyondeol.c b/test-tool/0242_prefetch10_beyondeol.c deleted file mode 100644 index 7928834..0000000 --- a/test-tool/0242_prefetch10_beyondeol.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0242_prefetch10_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - - printf("0242_prefetch10_beyondeol:\n"); - printf("===================\n"); - if (show_info) { - printf("Test PREFETCH10 for blocks beyond the EOL.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Prefetch 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Prefetch 1-256 blocks at LBA 2^31 (only on LUNs < 1TB)\n"); - printf("3, Prefetch 1-256 blocks at LBA -1 (only on LUN < 2TB)\n"); - printf("4, Prefetch 2-256 blocks all but one beyond end-of-lun.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with PREFETCH10. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* prefetch 1-256 blocks, one block beyond the end-of-lun */ - printf("Prefetch last 1-256 blocks one block beyond eol.\n"); - for (i = 1; i <= 256; i++) { - ret = prefetch10_lbaoutofrange(iscsi, lun, num_blocks + 2 - i, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* Prefetch 1 - 256 blocks at LBA 2^31 */ - printf("Prefetch 1-256 blocks at LBA 2^31.\n"); - for (i = 1; i <= 256; i++) { - ret = prefetch10_lbaoutofrange(iscsi, lun, 0x80000000, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* prefetch 1 - 256 blocks at LBA -1 */ - printf("Prefetch 1-256 blocks at LBA -1.\n"); - for (i = 1; i <= 256; i++) { - ret = prefetch10_lbaoutofrange(iscsi, lun, -1, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* prefetch 2-256 blocks, all but one block beyond the eol */ - printf("Prefetch 1-255 blocks beyond eol starting at last block.\n"); - for (i=2; i<=256; i++) { - ret = prefetch10_lbaoutofrange(iscsi, lun, num_blocks, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0243_prefetch10_0blocks.c b/test-tool/0243_prefetch10_0blocks.c deleted file mode 100644 index 3811716..0000000 --- a/test-tool/0243_prefetch10_0blocks.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0243_prefetch10_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, lun; - - printf("0243_prefetch10_0blocks:\n"); - printf("===================\n"); - if (show_info) { - printf("Test that PREFETCH10 works correctly when transfer length is 0 blocks.\n"); - printf("Transfer Length == 0 means to PREFETCH until the end of the LUN.\n"); - printf("1, Prefetch at LBA:0 should work.\n"); - printf("2, Prefetch at one block beyond end-of-lun should fail. (only on LUNs with less than 2^31 blocks)\n"); - printf("3, Prefetch at LBA:2^31 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("4, Prefetch at LBA:-1 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - /* prefetch 0blocks at the start of the LUN */ - printf("PREFETCH10 0blocks at LBA==0.\n"); - ret = prefetch10(iscsi, lun, 0, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch 0 blocks beyond end of the LUN */ - printf("PREFETCH10 0blocks at one block beyond .\n"); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - ret = prefetch10_lbaoutofrange(iscsi, lun, num_blocks + 2, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch 0blocks at LBA:2^31 */ - printf("PREFETCH10 0blocks at LBA:2^31.\n"); - ret = prefetch10_lbaoutofrange(iscsi, lun, 0x80000000, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch 0blocks at LBA:-1 */ - printf("PREFETCH10 0blocks at LBA:-1.\n"); - ret = prefetch10_lbaoutofrange(iscsi, lun, 0xffffffff, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0250_prefetch16_simple.c b/test-tool/0250_prefetch16_simple.c deleted file mode 100644 index db2b071..0000000 --- a/test-tool/0250_prefetch16_simple.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0250_prefetch16_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - - printf("0250_prefetch16_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic PREFETCH16 functionality.\n"); - printf("1, Verify we can prefetch the first 0-256 blocks of the LUN.\n"); - printf("2, Verify we can prefetch the last 0-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - /* prefetch the first 0 - 256 blocks at the start of the LUN */ - printf("Prefetching first 0-256 blocks.\n"); - for (i = 0; i <= 256; i++) { - ret = prefetch16(iscsi, lun, 0, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* Prefetch the last 0 - 255 blocks at the end of the LUN */ - printf("Prefetching last 0-255 blocks.\n"); - for (i = 1; i < 256; i++) { - ret = prefetch16(iscsi, lun, num_blocks - i, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0251_prefetch16_flags.c b/test-tool/0251_prefetch16_flags.c deleted file mode 100644 index f9fcb93..0000000 --- a/test-tool/0251_prefetch16_flags.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0251_prefetch16_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - - printf("0251_prefetch16_flags:\n"); - printf("===================\n"); - if (show_info) { - printf("Test PREFETCH16 flags.\n"); - printf("1, Test the IMMED flag.\n"); - printf("2, Test different GROUPNUMBERS.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - /* prefetch with IMMED==1 */ - printf("Check PREFETCH16 with IMMED==1.\n"); - ret = prefetch16(iscsi, lun, 0, 1, 1, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch with GROUPNUMBER==0..31 */ - printf("Check PREFETCH16 with GROUPNEMBER 0-31.\n"); - for (i = 0; i < 32; i++) { - ret = prefetch16(iscsi, lun, 0, 1, 0, i); - if (ret != 0) { - goto finished; - } - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0252_prefetch16_beyondeol.c b/test-tool/0252_prefetch16_beyondeol.c deleted file mode 100644 index d218e7c..0000000 --- a/test-tool/0252_prefetch16_beyondeol.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0252_prefetch16_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - - printf("0252_prefetch16_beyondeol:\n"); - printf("===================\n"); - if (show_info) { - printf("Test PREFETCH16 for blocks beyond the EOL.\n"); - printf("1, Prefetch 1-256 blocks one block beyond end-of-lun.\n"); - printf("2, Prefetch 1-256 blocks at LBA 2^63 should fail.\n"); - printf("3, Prefetch 1-256 blocks at LBA -1 should fail.\n"); - printf("4, Prefetch 1-256 blocks all but one block beyond eol\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - /* prefetch 1-256 blocks, one block beyond the end-of-lun */ - printf("Prefetch last 1-256 blocks one block beyond eol.\n"); - for (i = 1; i <= 256; i++) { - ret = prefetch16_lbaoutofrange(iscsi, lun, num_blocks + 2 - i, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* Prefetch 1 - 256 blocks at LBA 2^63 */ - printf("Prefetch 1-256 blocks at LBA 2^63.\n"); - for (i = 1; i <= 256; i++) { - ret = prefetch16_lbaoutofrange(iscsi, lun, 0x8000000000000000, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* prefetch 1 - 256 blocks at LBA -1 */ - printf("Prefetch 1-256 blocks at LBA -1.\n"); - for (i = 1; i <= 256; i++) { - ret = prefetch16_lbaoutofrange(iscsi, lun, -1, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - - /* prefetch 2-256 blocks, all but one block beyond the eol */ - printf("Prefetch 1-255 blocks beyond eol starting at last block.\n"); - for (i=2; i<=256; i++) { - ret = prefetch16_lbaoutofrange(iscsi, lun, num_blocks, i, 0, 0); - if (ret != 0) { - goto finished; - } - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0253_prefetch16_0blocks.c b/test-tool/0253_prefetch16_0blocks.c deleted file mode 100644 index 1feeb8b..0000000 --- a/test-tool/0253_prefetch16_0blocks.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0253_prefetch16_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, lun; - - printf("0253_prefetch16_0blocks:\n"); - printf("===================\n"); - if (show_info) { - printf("Test that PREFETCH16 works correctly when transfer length is 0 blocks.\n"); - printf("1, Prefetch at LBA:0 should work.\n"); - printf("2, Prefetch at one block beyond end-of-lun should fail.\n"); - printf("3, Prefetch at LBA:2^63 should fail.\n"); - printf("4, Prefetch at LBA:-1 should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - /* prefetch 0blocks at the start of the LUN */ - printf("PREFETCH16 0blocks at LBA==0.\n"); - ret = prefetch16(iscsi, lun, 0, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch 0 blocks beyond end of the LUN */ - printf("PREFETCH16 0blocks at one block beyond .\n"); - ret = prefetch16_lbaoutofrange(iscsi, lun, num_blocks + 2, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch 0blocks at LBA:2^63 */ - printf("PREFETCH16 0blocks at LBA:2^63.\n"); - ret = prefetch16_lbaoutofrange(iscsi, lun, 0x8000000000000000, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - - /* Prefetch 0blocks at LBA:-1 */ - printf("PREFETCH16 0blocks at LBA:-1.\n"); - ret = prefetch16_lbaoutofrange(iscsi, lun, 0xffffffffffffffff, 0, 0, 0); - if (ret != 0) { - goto finished; - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0260_get_lba_status_simple.c b/test-tool/0260_get_lba_status_simple.c deleted file mode 100644 index 8606cb7..0000000 --- a/test-tool/0260_get_lba_status_simple.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0260_get_lba_status_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0260_get_lba_status_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic GET_LBA_STATUS functionality.\n"); - printf("1, Verify we can read a descriptor at the start of the lun.\n"); - printf("2, Verify we can read a descriptor at the end of the lun.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* try reading one descriptor at offset 0 */ - printf("Read one descriptor at LBA 0 ... "); - task = iscsi_get_lba_status_sync(iscsi, lun, 0, 8 + 16); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send GET_LBA_STATUS command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("GET_LBA_STATUS command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* try reading one descriptor at end-of-device */ - printf("Read one descriptor at end-of-device ... "); - task = iscsi_get_lba_status_sync(iscsi, lun, num_blocks, 8 + 16); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send GET_LBA_STATUS command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("GET_LBA_STATUS command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0264_get_lba_status_beyondeol.c b/test-tool/0264_get_lba_status_beyondeol.c deleted file mode 100644 index 9fe74ed..0000000 --- a/test-tool/0264_get_lba_status_beyondeol.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0264_get_lba_status_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0264_get_lba_status_beyondeol:\n"); - printf("==============================\n"); - if (show_info) { - printf("Test GET_LBA_STATUS functionality for beyond end-of-lun requests\n"); - printf("1, Reading a descriptor beyond the end of the lun should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (rc16 == NULL || rc16->lbpme == 0){ - printf("Logical unit is fully provisioned. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* try reading one descriptor beyond end-of-device */ - printf("Read one descriptor beyond end-of-device ... "); - task = iscsi_get_lba_status_sync(iscsi, lun, num_blocks + 1, 8 + 16); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send GET_LBA_STATUS command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("GET_LBA_STATUS beyond eol should fail with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE\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("GET_LBA_STATUS 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"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0270_verify16_simple.c b/test-tool/0270_verify16_simple.c deleted file mode 100644 index 670119b..0000000 --- a/test-tool/0270_verify16_simple.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0270_verify16_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0270_verify16_simple:\n"); - printf("=====================\n"); - if (show_info) { - printf("Test basic VERIFY16 functionality.\n"); - printf("1, Read and verify the first 1-256 blocks of the LUN using READ16/VERIFY16.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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; - - - /* 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++) { - ret = verify16(iscsi, lun, 0, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - -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 deleted file mode 100644 index 851114a..0000000 --- a/test-tool/0271_verify16_mismatch.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0271_verify16_mismatch(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0271_verify16_mismatch:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test basic VERIFY16 functionality.\n"); - printf("1, Verify the first 1-256 blocks with a deliberate error detects the mismatch.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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("Verify first 1-256 blocks with a miscompare.\n"); - for (i = 1; i <= 256; i++) { - int offset = random() % (i * block_size); - - /* flip a random byte in the data */ - buf[offset] ^= 'X'; - - ret = verify16_miscompare(iscsi, lun, 0, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - - /* flip the byte back */ - buf[offset] ^= 'X'; - } - - -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 deleted file mode 100644 index 24d0762..0000000 --- a/test-tool/0272_verify16_mismatch_no_cmp.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0272_verify16_mismatch_no_cmp:\n"); - printf("==============================\n"); - if (show_info) { - printf("Test VERIFY16 BYTCHK:0 only checks medium and should never fail unless the medium is bad.\n"); - printf("1, Read the first 256 blocks and verify the medium is good.\n"); - printf("2, Verify the first 1-256 blocks retruns SUCCESS if BYTCHK is 0\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - 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("Verify first 1-256 blocks with a miscompare but BYTCHK==0.\n"); - for (i = 1; i <= 256; i++) { - int offset = random() % (i * block_size); - - /* flip a random byte in the data */ - buf[offset] ^= 'X'; - - ret = verify16(iscsi, lun, 0, i * block_size, block_size, 0, 1, 0, buf); - if (ret != 0) { - goto finished; - } - - /* flip the byte back */ - buf[offset] ^= 'X'; - } - - -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 deleted file mode 100644 index f124ac2..0000000 --- a/test-tool/0273_verify16_beyondeol.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0273_verify16_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0273_verify16_beyond_eol:\n"); - printf("========================\n"); - if (show_info) { - printf("Test that VERIFY16 fails if reading beyond end-of-lun.\n"); - printf("1, Verify 2-256 blocks one block beyond end-of-lun.\n"); - printf("2, Verify 1-256 blocks at LBA 2^63\n"); - printf("3, Verify 1-256 blocks at LBA -1\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - buf = malloc(256 * block_size); - - /* verify 2 - 256 blocks beyond the end of the device */ - printf("Verifying 2-256 blocks beyond end-of-device.\n"); - for (i = 2; i <= 256; i++) { - ret = verify16_lbaoutofrange(iscsi, lun, num_blocks, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - /* verify 1 - 256 blocks at LBA 2^63 */ - printf("Verifying 1-256 blocks at LBA 2^63.\n"); - for (i = 1; i <= 256; i++) { - ret = verify16_lbaoutofrange(iscsi, lun, 0x8000000000000000, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - /* verify 1 - 256 blocks at LBA -1 */ - printf("Verifying 1-256 blocks at LBA -1.\n"); - for (i = 1; i <= 256; i++) { - ret = verify16_lbaoutofrange(iscsi, lun, 0xffffffffffffffff, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0280_verify12_simple.c b/test-tool/0280_verify12_simple.c deleted file mode 100644 index fd7faa9..0000000 --- a/test-tool/0280_verify12_simple.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0280_verify12_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0280_verify12_simple:\n"); - printf("=====================\n"); - if (show_info) { - printf("Test basic VERIFY12 functionality.\n"); - printf("1, Read and verify the first 1-256 blocks of the LUN using READ12/VERIFY12.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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; - - - /* 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++) { - ret = verify12(iscsi, lun, 0, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0281_verify12_mismatch.c b/test-tool/0281_verify12_mismatch.c deleted file mode 100644 index 672b3dc..0000000 --- a/test-tool/0281_verify12_mismatch.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0281_verify12_mismatch(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0281_verify12_mismatch:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test basic VERIFY12 functionality.\n"); - printf("1, Verify the first 1-256 blocks with a deliberate error detects the mismatch.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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("Verify first 1-256 blocks with a miscompare.\n"); - for (i = 1; i <= 256; i++) { - int offset = random() % (i * block_size); - - /* flip a random byte in the data */ - buf[offset] ^= 'X'; - - ret = verify12_miscompare(iscsi, lun, 0, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - - /* flip the byte back */ - buf[offset] ^= 'X'; - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0282_verify12_mismatch_no_cmp.c b/test-tool/0282_verify12_mismatch_no_cmp.c deleted file mode 100644 index 0ae2595..0000000 --- a/test-tool/0282_verify12_mismatch_no_cmp.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0282_verify12_mismatch_no_cmp:\n"); - printf("==============================\n"); - if (show_info) { - printf("Test VERIFY12 BYTCHK:0 only checks medium and should never fail unless the medium is bad.\n"); - printf("1, Read the first 256 blocks and verify the medium is good.\n"); - printf("2, Verify the first 1-256 blocks retruns SUCCESS if BYTCHK is 0\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - 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("Verify first 1-256 blocks with a miscompare but BYTCHK==0.\n"); - for (i = 1; i <= 256; i++) { - int offset = random() % (i * block_size); - - /* flip a random byte in the data */ - buf[offset] ^= 'X'; - - ret = verify12(iscsi, lun, 0, i * block_size, block_size, 0, 1, 0, buf); - if (ret != 0) { - goto finished; - } - - /* flip the byte back */ - buf[offset] ^= 'X'; - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0283_verify12_beyondeol.c b/test-tool/0283_verify12_beyondeol.c deleted file mode 100644 index 4206037..0000000 --- a/test-tool/0283_verify12_beyondeol.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0283_verify12_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, i, lun; - unsigned char *buf = NULL; - - printf("0283_verify12_beyond_eol:\n"); - printf("========================\n"); - if (show_info) { - printf("Test that VERIFY12 fails if reading beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Verify 2-256 blocks one block beyond end-of-lun.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with VERIFY12. Skipping test.\n"); - ret = -2; - goto finished; - } - - buf = malloc(256 * block_size); - - /* verify 2 - 256 blocks beyond the end of the device */ - printf("Verifying 2-256 blocks beyond end-of-device.\n"); - for (i = 2; i <= 256; i++) { - ret = verify12_lbaoutofrange(iscsi, lun, num_blocks, i * block_size, block_size, 0, 1, 1, buf); - if (ret != 0) { - goto finished; - } - } - - -finished: - free(buf); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0290_write10_simple.c b/test-tool/0290_write10_simple.c deleted file mode 100644 index b5824be..0000000 --- a/test-tool/0290_write10_simple.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0290_write10_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0290_write10_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic WRITE10 functionality.\n"); - printf("1, Verify we can write the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write the first 1 - 256 blocks at the start of the LUN */ - printf("Writing first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_write10_sync(iscsi, lun, 0, data, i * block_size, 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 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 256 blocks at the end of the LUN */ - printf("Writing last 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_write10_sync(iscsi, lun, num_blocks +1 - i, data, i * block_size, 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 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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0291_write10_wrprotect.c b/test-tool/0291_write10_wrprotect.c deleted file mode 100644 index 411317f..0000000 --- a/test-tool/0291_write10_wrprotect.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0291_write10_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0291_write10_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how WRITE10 handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Write10 with WRPROTECT "); - for (i = 1; i <= 7; i++) { - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, i, 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 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("Write10 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0292_write10_flags.c b/test-tool/0292_write10_flags.c deleted file mode 100644 index e725ced..0000000 --- a/test-tool/0292_write10_flags.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0292_write10_flags(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - unsigned char data[4096]; - - printf("0292_write10_flags:\n"); - printf("===================\n"); - if (show_info) { - printf("Test how WRITE10 handles the flags\n"); - printf("1, Write with DPU should work.\n"); - printf("2, Write with FUA should work.\n"); - printf("3, Write with FUA_NV should work.\n"); - printf("4, Write with FUA+FUA_NV should work.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - - printf("Write10 with DPO "); - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - printf("Write10 with FUA "); - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - - printf("Write10 with FUA_NV "); - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - - printf("Write10 with FUA+FUA_NV "); - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0293_write10_0blocks.c b/test-tool/0293_write10_0blocks.c deleted file mode 100644 index 9f32ef1..0000000 --- a/test-tool/0293_write10_0blocks.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0293_write10_0blocks(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - - printf("0293_write10_0blocks:\n"); - printf("====================\n"); - if (show_info) { - printf("Test that WRITE10 works correctly when transfer length is 0 blocks.\n"); - printf("1, Write at LBA:0 should work.\n"); - printf("2, Write at one block beyond end-of-lun should fail. (only on LUNs with less than 2^31 blocks)\n"); - printf("3, Write at LBA:2^31 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("4, Write at LBA:-1 should fail (only on LUNs with less than 2^31 blocks).\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - printf("WRITE10 0blocks at LBA:0 ... "); - task = iscsi_write10_sync(iscsi, lun, 0, 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 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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("WRITE10 0blocks at one block beyond ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - goto finished; - } - task = iscsi_write10_sync(iscsi, lun, num_blocks + 2, 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("WRITE10 0blocks at LBA:2^31 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("WRITE10 0blocks at LBA:-1 ... "); - if (num_blocks > 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big, skipping test\n"); - 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 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 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("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 finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0294_write10_beyondeol.c b/test-tool/0294_write10_beyondeol.c deleted file mode 100644 index 209acc9..0000000 --- a/test-tool/0294_write10_beyondeol.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0294_write10_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0294_write10_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITE10 fails if writing beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Writing 1-256 blocks beyond end-of-lun should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with WRITE10. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* write 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks beyond end-of-device ... "); - for (i = 2; i <= 257; i++) { - task = iscsi_write10_sync(iscsi, lun, num_blocks, data, i * block_size, 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 finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command should fail when writing beyond end of device\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0300_readonly.c b/test-tool/0300_readonly.c deleted file mode 100644 index f21f001..0000000 --- a/test-tool/0300_readonly.c +++ /dev/null @@ -1,508 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0300_readonly(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_mode_sense *ms; - int ret, lun; - unsigned char data[4096]; - struct unmap_list list[1]; - int full_size; - - ret = -1; - - printf("0300_readonly:\n"); - printf("==============\n"); - if (show_info) { - printf("Test that all commands that modify the medium fail for readonly devices\n"); - printf("1, WRITE10 at LUN 0 should fail.\n"); - printf("2, WRITE12 at LUN 0 should fail.\n"); - printf("3, WRITE16 at LUN 0 should fail.\n"); - printf("4, WRITESAME10 at LUN 0 should fail.\n"); - printf("5, WRITESAME16 at LUN 0 should fail.\n"); - printf("6, WRITESAME10 with UNMAP at LUN 0 should fail (skipped if not thin-provisioned).\n"); - printf("7, WRITESAME16 with UNMAP at LUN 0 should fail (skipped if not thin-provisioned).\n"); - printf("8, UNMAP at LUN 0 should fail (skipped if not thin-provisioned).\n"); - printf("9, WRITEVERIFY10 at LUN 0 should fail.\n"); - printf("10, WRITEVERIFY12 at LUN 0 should fail.\n"); - printf("11, WRITEVERIFY16 at LUN 0 should fail.\n"); - printf("12, COMPAREANDWRITE at LUN 0 should fail.\n"); - printf("13, ORWRITE at LUN 0 should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - if (!data_loss) { - logging(LOG_VERBOSE, "[SKIPPED] --dataloss flag not set." - " Skipping test"); - return -2; - } - - /* verify the device is readonly */ - task = iscsi_modesense6_sync(iscsi, lun, 0, SCSI_MODESENSE_PC_CURRENT, - SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, - 4); - if (task == NULL) { - printf("Failed to send modesense6 command: %s\n", iscsi_get_error(iscsi)); - goto finished; - } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); - task = iscsi_modesense6_sync(iscsi, lun, 0, SCSI_MODESENSE_PC_CURRENT, - SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, - full_size); - if (task == NULL) { - printf("Failed to send modesense6 command: %s\n", iscsi_get_error(iscsi)); - goto finished; - } - } - ms = scsi_datain_unmarshall(task); - if (ms == NULL) { - printf("failed to unmarshall mode sense datain blob\n"); - scsi_free_scsi_task(task); - goto finished; - } - if (!(ms->device_specific_parameter & 0x80)) { - printf("Device is not read-only. Skipping test\n"); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); - - - ret = 0; - - - /* Write one block at lba 0 */ - printf("WRITE10 to LUN 0 ... "); - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, 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 finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE12 command should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE16 command should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Write one block at lba 0 */ - printf("WRITESAME10 to LUN 0 ... "); - task = iscsi_writesame10_sync(iscsi, lun, 0, - data, block_size, - 1, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Write one block at lba 0 */ - printf("WRITESAME16 to LUN 0 ... "); - task = iscsi_writesame16_sync(iscsi, lun, 0, - data, block_size, - 1, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* UNMAP one block at lba 0 */ - printf("WRITESAME10 to UNMAP LUN 0 ... "); - if (rc16 == NULL || rc16->lbpme == 0){ - printf("LUN is not thin-provisioned. [SKIPPED]\n"); - goto finished; - } - task = iscsi_writesame10_sync(iscsi, lun, 0, - data, block_size, - 1, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* UNMAP one block at lba 0 */ - printf("WRITESAME16 to UNMAP LUN 0 ... "); - task = iscsi_writesame16_sync(iscsi, lun, 0, - data, block_size, - 1, - 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* UNMAP one block at lba 0 */ - printf("UNMAP LUN 0 ... "); - list[0].lba = 0; - list[0].num = 1; - task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); - 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 should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITEVERIFY10 command should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Write one block at lba 0 */ - printf("WRITEVERIFY12 to LUN 0 ... "); - task = iscsi_writeverify12_sync(iscsi, lun, 0, data, 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITEVERIFY12 command should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Write one block at lba 0 */ - printf("WRITEVERIFY16 to LUN 0 ... "); - task = iscsi_writeverify16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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 = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("COMPAREANDWRITE command should fail when writing to readonly devices\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* Write one block at lba 0 */ - printf("ORWRITE to LUN 0 ... "); - task = iscsi_orwrite_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0310_writeverify10_simple.c b/test-tool/0310_writeverify10_simple.c deleted file mode 100644 index 865bca7..0000000 --- a/test-tool/0310_writeverify10_simple.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0310_writeverify10_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0310_writeverify10_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic WRITEVERIFY10 functionality.\n"); - printf("1, Verify we can write the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write the first 1 - 256 blocks at the start of the LUN */ - printf("Writing first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify10_sync(iscsi, lun, 0, 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 256 blocks at the end of the LUN */ - printf("Writing last 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify10_sync(iscsi, lun, num_blocks +1 - i, 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0311_writeverify10_wrprotect.c b/test-tool/0311_writeverify10_wrprotect.c deleted file mode 100644 index 5f4fbfb..0000000 --- a/test-tool/0311_writeverify10_wrprotect.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0311_writeverify10_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0311_writeverify10_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how WRITEVERIFY10 handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Test WRITEVERIFY10 with WRPROTECT != 0 ... "); - for (i = 1; i <= 7; i++) { - task = iscsi_writeverify10_sync(iscsi, lun, 0, data, block_size, block_size, i, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0314_writeverify10_beyondeol.c b/test-tool/0314_writeverify10_beyondeol.c deleted file mode 100644 index 3ec795d..0000000 --- a/test-tool/0314_writeverify10_beyondeol.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0314_writeverify10_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0314_writeverify10_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITEVERIFY10 fails if writing beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Writing 1-256 blocks with one block beyond end-of-lun should fail.\n"); - printf("2, Writing 1-256 blocks at LBA 2^31 should fail.\n"); - printf("3, Writing 1-256 blocks at LBA -1 should fail.\n"); - printf("4, Writing 1-256 blocks all but one block beyond eol\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with WRITEVERIFY10. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* write+verify 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks with one block beyond end-of-device ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify10_sync(iscsi, lun, num_blocks + 2 - i, 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 = -1; - 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("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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_writeverify10_sync(iscsi, lun, num_blocks, 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0320_writeverify12_simple.c b/test-tool/0320_writeverify12_simple.c deleted file mode 100644 index de8d877..0000000 --- a/test-tool/0320_writeverify12_simple.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0320_writeverify12_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0320_writeverify12_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic WRITEVERIFY12 functionality.\n"); - printf("1, Verify we can write the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write the first 1 - 256 blocks at the start of the LUN */ - printf("Writing first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify12_sync(iscsi, lun, 0, 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 256 blocks at the end of the LUN */ - printf("Writing last 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify12_sync(iscsi, lun, num_blocks +1 - i, 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0321_writeverify12_wrprotect.c b/test-tool/0321_writeverify12_wrprotect.c deleted file mode 100644 index f6ff6e1..0000000 --- a/test-tool/0321_writeverify12_wrprotect.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0321_writeverify12_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0321_writeverify12_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how WRITEVERIFY12 handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Test WRITEVERIFY12 with WRPROTECT != 0 ... "); - for (i = 1; i <= 7; i++) { - task = iscsi_writeverify12_sync(iscsi, lun, 0, data, block_size, block_size, i, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0324_writeverify12_beyondeol.c b/test-tool/0324_writeverify12_beyondeol.c deleted file mode 100644 index 086f09d..0000000 --- a/test-tool/0324_writeverify12_beyondeol.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0324_writeverify12_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0324_writeverify12_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITEVERIFY12 fails if writing beyond end-of-lun.\n"); - printf("This test is skipped for LUNs with more than 2^31 blocks\n"); - printf("1, Writing 1-256 blocks with one block beyond end-of-lun should fail.\n"); - printf("2, Writing 1-256 blocks at LBA 2^31 should fail.\n"); - printf("3, Writing 1-256 blocks at LBA -1 should fail.\n"); - printf("4, Writing 1-256 blocks all but one block beyond eol\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - if (num_blocks >= 0x80000000) { - printf("[SKIPPED]\n"); - printf("LUN is too big for read-beyond-eol tests with WRITEVERIFY12. Skipping test.\n"); - ret = -2; - goto finished; - } - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks with one block beyond end-of-device ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify12_sync(iscsi, lun, num_blocks + 2 - i, 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 = -1; - 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("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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_writeverify12_sync(iscsi, lun, num_blocks, 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0330_writeverify16_simple.c b/test-tool/0330_writeverify16_simple.c deleted file mode 100644 index 0b0c624..0000000 --- a/test-tool/0330_writeverify16_simple.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0330_writeverify16_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0330_writeverify16_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic WRITEVERIFY16 functionality.\n"); - printf("1, Verify we can write the first 1-256 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-256 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* write the first 1 - 256 blocks at the start of the LUN */ - printf("Writing first 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify16_sync(iscsi, lun, 0, data, i * block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 256 blocks at the end of the LUN */ - printf("Writing last 1-256 blocks ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify16_sync(iscsi, lun, num_blocks +1 - i, data, i * block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0331_writeverify16_wrprotect.c b/test-tool/0331_writeverify16_wrprotect.c deleted file mode 100644 index ab6498a..0000000 --- a/test-tool/0331_writeverify16_wrprotect.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0331_writeverify16_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0331_writeverify16_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how WRITEVERIFY16 handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Test WRITEVERIFY16 with WRPROTECT != 0 ... "); - for (i = 1; i <= 7; i++) { - task = iscsi_writeverify16_sync(iscsi, lun, 0, data, block_size, block_size, i, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0334_writeverify16_beyondeol.c b/test-tool/0334_writeverify16_beyondeol.c deleted file mode 100644 index 1262806..0000000 --- a/test-tool/0334_writeverify16_beyondeol.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0334_writeverify16_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0334_writeverify16_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that WRITEVERIFY16 fails if writing beyond end-of-lun.\n"); - printf("1, Writing 1-256 blocks with one block beyond end-of-lun should fail.\n"); - printf("2, Writing 1-256 blocks at LBA 2^63 should fail.\n"); - printf("3, Writing 1-256 blocks at LBA -1 should fail.\n"); - printf("4, Writing 1-256 blocks all but one block beyond eol\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks with one block beyond end-of-device ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify16_sync(iscsi, lun, num_blocks + 2 - i, data, i * block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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_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("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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 256 blocks at lba 2^63 */ - printf("Writing 1-256 blocks at LBA 2^63 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify16_sync(iscsi, lun, 0x8000000000000000, data, i * block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 256 blocks at lba -1 */ - printf("Writing 1-256 blocks at LBA -1 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_writeverify16_sync(iscsi, lun, 0xffffffffffffffff, data, i * block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_writeverify16_sync(iscsi, lun, num_blocks, data, i * block_size, block_size, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - 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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0340_compareandwrite_simple.c b/test-tool/0340_compareandwrite_simple.c deleted file mode 100644 index 3567205..0000000 --- a/test-tool/0340_compareandwrite_simple.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -static void bitwise_invert(unsigned char data[], int len) { - int j; - - for (j = 0; j < len; j++) { - data[j] = ~data[j]; - } -} - -int T0340_compareandwrite_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0340_compareandwrite_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic COMPAREANDWRITE functionality.\n"); - printf("1, Verify we can write the first 1-255 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-255 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* write the first 1 - 255 blocks at the start of the LUN */ - printf("Compare and write first 1-255 blocks ... "); - for (i = 1; i < 256; i++) { - 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 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 finished; - } - - if (task->datain.data == 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 finished; - } - memcpy(data, task->datain.data, i * block_size); - memcpy(data + (i * block_size), task->datain.data, i * block_size); - bitwise_invert(data + (i * block_size), i * block_size); - scsi_free_scsi_task(task); - - task = iscsi_compareandwrite_sync(iscsi, lun, 0, data, i * 2 * 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 = -1; - 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("COMPAREANDWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (task->datain.data == 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 finished; - } - memcpy(data, task->datain.data, i * block_size); - memcpy(data + (i * block_size), task->datain.data, i * block_size); - bitwise_invert(data + (i * block_size), i * block_size); - scsi_free_scsi_task(task); - - task = iscsi_compareandwrite_sync(iscsi, lun, num_blocks + 1 - i, data, i * 2 * 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0341_compareandwrite_mismatch.c b/test-tool/0341_compareandwrite_mismatch.c deleted file mode 100644 index 645daa8..0000000 --- a/test-tool/0341_compareandwrite_mismatch.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0341_compareandwrite_mismatch(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 256]; - - printf("0341_compareandwrite_mismatch:\n"); - printf("===================\n"); - if (show_info) { - printf("Test COMPAREANDWRITE can detect a data mismatch.\n"); - printf("1, Verify we detect a mismatch in the first 1-255 blocks of the LUN.\n"); - printf("2, Verify we detect a mismatch in the last 1-255 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* write the first 1 - 255 blocks at the start of the LUN */ - printf("Compare and write first 1-255 blocks (data is not matching) ... "); - for (i = 1; i < 256; i++) { - task = iscsi_read16_sync(iscsi, lun, 0, i * 2 * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (task->datain.data == 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 finished; - } - memcpy(data, task->datain.data, i * block_size); - scsi_free_scsi_task(task); - - /* flip some bits */ - data[ (i - 1) * block_size] ^= 0xa5; - /* set the write part of the data-out buffer to 1s */ - memset(data + (i * block_size), 0xff, (i * block_size)); - - task = iscsi_compareandwrite_sync(iscsi, lun, 0, data, i * 2 * 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 = -1; - 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("COMPAREANDWRITE successful. It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n"); - ret = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (task->datain.data == 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 finished; - } - memcpy(data, task->datain.data, i * block_size); - scsi_free_scsi_task(task); - - /* flip some bits */ - data[ (i - 1) * block_size] ^= 0xa5; - /* set the write part of the data-out buffer to 1s */ - memset(data + (i * block_size), 0xff, (i * block_size)); - - task = iscsi_compareandwrite_sync(iscsi, lun, num_blocks + 1 - i, data, i * 2 * 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 = -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 = -1; - scsi_free_scsi_task(task); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0343_compareandwrite_beyondeol.c b/test-tool/0343_compareandwrite_beyondeol.c deleted file mode 100644 index b416a1e..0000000 --- a/test-tool/0343_compareandwrite_beyondeol.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0343_compareandwrite_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0343_compareandwrite_beyond_eol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that COMPAREANDWRITE fails if writing beyond end-of-lun.\n"); - printf("1, Writing 1-255 blocks with one block beyond end-of-lun should fail.\n"); - printf("2, Writing 1-255 blocks at LBA 2^63 should fail.\n"); - printf("3, Writing 1-255 blocks at LBA -1 should fail.\n"); - printf("4, Writing 1-255 blocks all but one block beyond eol\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* read 1 - 255 blocks beyond the end of the device */ - printf("Writing 1-255 blocks with one block beyond end-of-device ... "); - for (i = 1; i <= 255; i++) { - task = iscsi_compareandwrite_sync(iscsi, lun, num_blocks + 2 - i, data, i * 2 * 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 = -1; - 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("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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 255 blocks at lba 2^63 */ - printf("Writing 1-255 blocks at LBA 2^63 ... "); - for (i = 1; i < 256; i++) { - task = iscsi_compareandwrite_sync(iscsi, lun, 0x8000000000000000, data, i * 2 * 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 255 blocks at lba -1 */ - printf("Writing 1-255 blocks at LBA -1 ... "); - for (i = 1; i < 256; i++) { - task = iscsi_compareandwrite_sync(iscsi, lun, 0xffffffffffffffff, data, i * 2 * 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_compareandwrite_sync(iscsi, lun, num_blocks, data, i * 2 * 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 = -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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0350_orwrite_simple.c b/test-tool/0350_orwrite_simple.c deleted file mode 100644 index 8df50a5..0000000 --- a/test-tool/0350_orwrite_simple.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0350_orwrite_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned int j; - unsigned char r1data[4096 * 256]; - unsigned char r2data[4096 * 256]; - unsigned char ordata[4096 * 256]; - - printf("0350_orwrite_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic ORWRITE functionality.\n"); - printf("1, Verify we can write the first 1-255 blocks of the LUN.\n"); - printf("2, Verify we can write the last 1-255 blocks of the LUN.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* write the first 1 - 255 blocks at the start of the LUN */ - printf("Orwrite first 1-255 blocks ... "); - for (i = 1; i < 256; i++) { - 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 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 finished; - } - - if (task->datain.data == 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 finished; - } - memcpy(r1data, task->datain.data, i * block_size); - memset(ordata, 0x5a, i * block_size); - for (j = 0; j < i * block_size; j++) { - r2data[j] = r1data[j] | ordata[j]; - } - scsi_free_scsi_task(task); - - task = iscsi_orwrite_sync(iscsi, lun, 0, ordata, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - - 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 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 finished; - } - - if (task->datain.data == 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 finished; - } - - if (memcmp(r2data, task->datain.data, i * block_size)) { - printf("[FAILED]\n"); - printf("Blocks were not updated as expected.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* write the last 1 - 255 blocks at the end of the LUN */ - printf("Orwrite last 1-255 blocks ... "); - for (i = 1; i < 256; i++) { - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (task->datain.data == 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 finished; - } - memcpy(r1data, task->datain.data, i * block_size); - memcpy(r1data, task->datain.data, i * block_size); - memset(ordata, 0xa5, i * block_size); - for (j = 0; j < i * block_size; j++) { - r2data[j] = r1data[j] | ordata[j]; - } - scsi_free_scsi_task(task); - - task = iscsi_orwrite_sync(iscsi, lun, num_blocks + 1 - i, ordata, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - - if (task->datain.data == 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 finished; - } - - if (memcmp(r2data, task->datain.data, i * block_size)) { - printf("[FAILED]\n"); - printf("Blocks were not updated as expected.\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0351_orwrite_wrprotect.c b/test-tool/0351_orwrite_wrprotect.c deleted file mode 100644 index bc003aa..0000000 --- a/test-tool/0351_orwrite_wrprotect.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0351_orwrite_wrprotect(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, i, lun; - unsigned char data[4096]; - - printf("0351_orwrite_wrprotect:\n"); - printf("======================\n"); - if (show_info) { - printf("Test how ORWRITE handles the wrprotect bits\n"); - printf("1, Any non-zero valued for wrprotect should fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - printf("Test ORWRITE with WRPROTECT != 0 ... "); - for (i = 1; i <= 7; i++) { - task = iscsi_orwrite_sync(iscsi, lun, 0, data, block_size, block_size, i, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0354_orwrite_beyondeol.c b/test-tool/0354_orwrite_beyondeol.c deleted file mode 100644 index 9483901..0000000 --- a/test-tool/0354_orwrite_beyondeol.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0354_orwrite_beyondeol(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - unsigned char data[4096 * 258]; - - printf("0354_orwrite_beyondeol:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test that ORWRITE fails if writing beyond end-of-lun.\n"); - printf("1, Writing 1-256 blocks with one block beyond end-of-lun should fail.\n"); - printf("2, Writing 1-256 blocks at LBA 2^63 should fail.\n"); - printf("3, Writing 1-256 blocks at LBA -1 should fail.\n"); - printf("4, Writing 1-256 blocks all but one block beyond eol\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* read 1 - 256 blocks beyond the end of the device */ - printf("Writing 1-256 blocks with one block beyond end-of-device ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_orwrite_sync(iscsi, lun, num_blocks + 2 - i, data, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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_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("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 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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 256 blocks at lba 2^63 */ - printf("Writing 1-256 blocks at LBA 2^63 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_orwrite_sync(iscsi, lun, 0x8000000000000000, data, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* read 1 - 256 blocks at lba -1 */ - printf("Writing 1-256 blocks at LBA -1 ... "); - for (i = 1; i <= 256; i++) { - task = iscsi_orwrite_sync(iscsi, lun, 0xffffffffffffffff, data, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - /* 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++) { - task = iscsi_orwrite_sync(iscsi, lun, num_blocks, data, i * block_size, block_size, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - 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 = -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("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 finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0360_startstopunit_simple.c b/test-tool/0360_startstopunit_simple.c deleted file mode 100644 index 826ab4f..0000000 --- a/test-tool/0360_startstopunit_simple.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0360_startstopunit_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0360_startstopunit_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test basic STARTSTOPUNIT functionality.\n"); - printf("1, Verify we can eject removable the media with IMMED==1\n"); - printf("2, Verify we can load the media back again with IMMED==1\n"); - printf("3, Verify we can eject removable the media with IMMED==0\n"); - printf("4, Verify we can load the media back again with IMMED==0\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - if (inq->rmb) { - printf("Media is removable. STARTSTOPUNIT should work\n"); - } else { - printf("Media is not removable. STARTSTOPUNIT should fail\n"); - } - - - printf("STARTSTOPUNIT try to eject the media with IMMED==1 ... "); - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - if (inq->rmb) { - printf("Medium is removable. Check with TESTUNITREADY that was removed.\n"); - ret = testunitready_nomedium(iscsi, lun); - if (ret != 0) { - goto finished; - } - } else { - printf("Medium is not removable. Check with TESTUNITREADY that medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - } - - - printf("STARTSTOPUNIT try to mount the media again with IMMED==1 ... "); - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("STARTSTOPUNIT try to eject the media with IMMED==0 ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - if (inq->rmb) { - printf("Medium is removable. Check with TESTUNITREADY that was removed.\n"); - ret = testunitready_nomedium(iscsi, lun); - if (ret != 0) { - goto finished; - } - } else { - printf("Medium is not removable. Check with TESTUNITREADY that medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - } - - - printf("STARTSTOPUNIT try to mount the media again with IMMED==0 ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 0, 1, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Check with TESTUNITREADY that the medium is present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0361_startstopunit_pwrcnd.c b/test-tool/0361_startstopunit_pwrcnd.c deleted file mode 100644 index 03d17c2..0000000 --- a/test-tool/0361_startstopunit_pwrcnd.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0361_startstopunit_pwrcnd(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, i, lun; - - printf("0361_startstopunit_pwrcnd:\n"); - printf("===================\n"); - if (show_info) { - printf("Test STARTSTOPUNIT POWERCONDITION functionality.\n"); - printf("1, If PC != 0 we can not eject the media\n"); - printf("2, Try to remount the media\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - if (inq->rmb) { - printf("Media is removable. STARTSTOPUNIT should work\n"); - } else { - printf("Media is not removable. STARTSTOPUNIT should fail\n"); - } - for (i = 1; i < 16; i++) { - printf("Try to eject media with PC == %d ... ", i); - task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, i, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - } - - - - printf("Try to mount the media again ... "); - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0362_startstopunit_noloej.c b/test-tool/0362_startstopunit_noloej.c deleted file mode 100644 index 5bb8ce4..0000000 --- a/test-tool/0362_startstopunit_noloej.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0362_startstopunit_noloej(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0362_startstopunit_noloej:\n"); - printf("===================\n"); - if (show_info) { - printf("Test STARTSTOPUNIT and LOEJ==0 will never eject/load media.\n"); - printf("1, LOEJ==0 IMMED==0 NO_FLUSH==0 START==0 will not eject the media\n"); - printf("2, LOEJ==0 IMMED==0 NO_FLUSH==0 START==1 will not eject the media\n"); - printf("3, LOEJ==0 IMMED==1 NO_FLUSH==0 START==0 will not eject the media\n"); - printf("4, LOEJ==0 IMMED==1 NO_FLUSH==0 START==1 will not eject the media\n"); - printf("5, LOEJ==0 IMMED==0 NO_FLUSH==1 START==0 will not eject the media\n"); - printf("6, LOEJ==0 IMMED==0 NO_FLUSH==1 START==1 will not eject the media\n"); - printf("7, LOEJ==0 IMMED==1 NO_FLUSH==1 START==0 will not eject the media\n"); - printf("8, LOEJ==0 IMMED==1 NO_FLUSH==1 START==1 will not eject the media\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - if (!inq->rmb) { - printf("Media is not removable. SKIPPING tests\n"); - ret = -2; - goto finished; - } - - - - printf("STARTSTOP LOEJ==0 IMMED==0 NO_FLUSH==0 START==0 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==0 NO_FLUSH==0 START==1 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 0, 0, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==1 NO_FLUSH==0 START==0 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==1 NO_FLUSH==0 START==1 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 0, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==0 NO_FLUSH==1 START==0 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==0 NO_FLUSH==1 START==1 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 1, 0, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==1 NO_FLUSH==1 START==0 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 1, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - - printf("STARTSTOP LOEJ==0 IMMED==1 NO_FLUSH==1 START==1 does not eject media ... "); - task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 1, 0, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is still present.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - /* in case the previous command did eject the media */ - iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0370_nomedia.c b/test-tool/0370_nomedia.c deleted file mode 100644 index 60273ae..0000000 --- a/test-tool/0370_nomedia.c +++ /dev/null @@ -1,641 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0370_nomedia(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - unsigned char buf[4096]; - - printf("0370_nomedia:\n"); - printf("============\n"); - if (show_info) { - printf("Test that media access commands fail correctly if media is ejected\n"); - printf("1, Verify we can eject the media\n"); - printf("2, Verify TESTUNITREADY\n"); - printf("3, Verify SYNCHRONIZECACHE10\n"); - printf("4, Verify SYNCHRONIZECACHE16\n"); - printf("5, Verify READ10\n"); - printf("6, Verify READ12\n"); - printf("7, Verify READ16\n"); - printf("8, Verify READCAPACITY10\n"); - printf("9, Verify READCAPACITY16\n"); - printf("10, Verify GETLBASTATUS\n"); - printf("11, Verify PREFETCH10\n"); - printf("12, Verify PREFETCH16\n"); - printf("13, Verify VERIFY10\n"); - printf("14, Verify VERIFY12\n"); - printf("15, Verify VERIFY16\n"); - printf("Write commands (only if --dataloss is specified)\n"); - printf("16, Verify WRITE10\n"); - printf("17, Verify WRITE12\n"); - printf("18, Verify WRITE16\n"); - printf("19, Verify WRITEVERIFY10\n"); - printf("20, Verify WRITEVERIFY12\n"); - printf("21, Verify WRITEVERIFY16\n"); - printf("22, Verify ORWRITE\n"); - printf("23, Verify COMPAREWRITE\n"); - printf("24, Verify WRITESAME10\n"); - printf("25, Verify WRITESAME16\n"); - printf("26, Verify UNMAP\n"); - - printf("Verify we can load the media back again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!inq->rmb) { - 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); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - 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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - -/* - * TESTS THAT READ FROM THE MEDIUM - */ - printf("Test TESTUNITREADY.\n"); - ret = testunitready_nomedium(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("Test SYNCHRONIZECACHE10 ... "); - task = iscsi_synchronizecache10_sync(iscsi, lun, 0, 1, 1, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send SYNCHRONIZECACHE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("SYNCHRONIZECACHE10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test SYNCHRONIZECACHE16 ... "); - task = iscsi_synchronizecache16_sync(iscsi, lun, 0, 1, 1, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send SYNCHRONIZECACHE16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("SYNCHRONIZECACHE16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test READ10 ... "); - task = iscsi_read10_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 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_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("READ10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test READ12 ... "); - task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("READ12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test READ16 ... "); - task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_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("READ16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test READCAPACITY10 ... "); - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("READCAPACITY10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test READCAPACITY16 ... "); - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("READCAPACITY16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test GETLBASTATUS ... "); - task = iscsi_get_lba_status_sync(iscsi, lun, 0, 64); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send GETLBASTATUS command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("GETLBASTATUS after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test PREFETCH10.\n"); - ret = prefetch10_nomedium(iscsi, lun, 0, 1, 1, 0); - if (ret != 0) { - goto finished; - } - - - printf("Test PREFETCH16.\n"); - ret = prefetch16_nomedium(iscsi, lun, 0, 1, 1, 0); - if (ret != 0) { - goto finished; - } - - - printf("Test VERIFY10.\n"); - ret = verify10_nomedium(iscsi, lun, 0, block_size, block_size, 0, 0, 1, buf); - if (ret != 0) { - goto finished; - } - - - printf("Test VERIFY12.\n"); - ret = verify12_nomedium(iscsi, lun, 0, block_size, block_size, 0, 0, 1, buf); - if (ret != 0) { - goto finished; - } - - printf("Test VERIFY16.\n"); - ret = verify16_nomedium(iscsi, lun, 0, block_size, block_size, 0, 0, 1, buf); - if (ret != 0) { - goto finished; - } - - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping all WRITE tests\n"); - ret = -2; - goto finished; - } - - -/* - * TESTS THAT WRITE TO THE MEDIUM - */ - - printf("Test WRITE10 ... "); - task = iscsi_write10_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITE10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITE12 ... "); - task = iscsi_write12_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITE12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITE16 ... "); - task = iscsi_write16_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITE16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITEVERIFY10 ... "); - task = iscsi_writeverify10_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITEVERIFY10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITEVERIFY12 ... "); - task = iscsi_writeverify12_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITEVERIFY12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITEVERIFY16 ... "); - task = iscsi_writeverify16_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITEVERIFY16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test ORWRITE ... "); - task = iscsi_orwrite_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("ORWRITE after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test COMPAREWRITE ... "); - task = iscsi_compareandwrite_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send COMPAREWRITE command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("COMPAREWRITE after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITESAME10 ... "); - task = iscsi_writesame10_sync(iscsi, lun, 0, - buf, block_size, - 1, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITESAME10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test WRITESAME16 ... "); - task = iscsi_writesame16_sync(iscsi, lun, 0, - buf, block_size, - 1, - 0, 0, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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("WRITESAME16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Test UNMAP ... "); - 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_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("UNMAP after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - - printf("Try to mount the media again ... "); - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Check with TESTUNITREADY that the medium is present again.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - -finished: - printf("Make sure the media is mounted again before the next test ... "); - 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)); - return -1; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0380_preventallow_simple.c b/test-tool/0380_preventallow_simple.c deleted file mode 100644 index aa16b5b..0000000 --- a/test-tool/0380_preventallow_simple.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0380_preventallow_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0380_preventallow_simple:\n"); - printf("=========================\n"); - if (show_info) { - printf("Test basic PREVENTALLOW functionality.\n"); - printf("1, Verify we can set PREVENTALLOW (if the medium is removable)\n"); - printf("2, Verify we can clear it again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - if (inq->rmb) { - printf("Media is removable. PREVENTALLOW should work\n"); - } else { - printf("Media is not removable. PREVENTALLOW should fail\n"); - } - printf("Try to set PREVENTALLOW ... "); - task = iscsi_preventallow_sync(iscsi, lun, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0381_preventallow_eject.c b/test-tool/0381_preventallow_eject.c deleted file mode 100644 index d67cdaa..0000000 --- a/test-tool/0381_preventallow_eject.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0381_preventallow_eject(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0381_preventallow_eject:\n"); - printf("========================\n"); - if (show_info) { - printf("Test we can not eject media when PREVENTALLOW is active.\n"); - printf("1, Verify we can set PREVENTALLOW (if the medium is removable)\n"); - printf("2, Verify we can no longer eject the media\n"); - printf("3, Load the media again in case it was ejected\n"); - printf("4, Clear PREVENTALLOW again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!inq->rmb) { - 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) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - 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 = -1; - goto finished; - } - /* SBC doesnt really say anything about whether we can LOAD media when the prevent - * flag is set - */ - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0382_preventallow_itnexus_loss.c b/test-tool/0382_preventallow_itnexus_loss.c deleted file mode 100644 index 3eaf167..0000000 --- a/test-tool/0382_preventallow_itnexus_loss.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - - printf("0382_preventallow_itnexus_loss:\n"); - printf("===============================\n"); - if (show_info) { - printf("Test that an I_T_Nexus loss clears PREVENTALLOW.\n"); - printf("1, Verify we can set PREVENTALLOW (if the medium is removable)\n"); - printf("2, Verify we can no longer eject the media\n"); - printf("3, Tear down the I_T_Nexus and re-login on a new nexus\n"); - printf("4, Verify we can eject the media\n"); - printf("5, Load the media again in case it was ejected\n"); - printf("6, Clear PREVENTALLOW again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - if (!inq->rmb) { - printf("Media is not removable. Skipping tests\n"); - ret = -2; - goto finished; - } - - printf("Try to set PREVENTALLOW ... "); - task = iscsi_preventallow_sync(iscsi, lun, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - printf("Tear down the IT_Nexus and create a new one ... "); - iscsi_destroy_context(iscsi); - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - goto finished; - } - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SBC doesnt really say anything about whether we can LOAD media when the prevent - * flag is set - */ - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0383_preventallow_target_warm_reset.c b/test-tool/0383_preventallow_target_warm_reset.c deleted file mode 100644 index 6b4f970..0000000 --- a/test-tool/0383_preventallow_target_warm_reset.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -struct mgmt_task { - uint32_t status; - uint32_t finished; -}; - -static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, - void *command_data, void *private_data) -{ - struct mgmt_task *mgmt_task = (struct mgmt_task *)private_data; - - mgmt_task->status = *(uint32_t *)command_data; - mgmt_task->finished = 1; -} - - -int T0383_preventallow_target_warm_reset(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - struct mgmt_task mgmt_task = {0, 0}; - struct pollfd pfd; - - printf("0383_preventallow_target_warm_reset:\n"); - printf("====================================\n"); - if (show_info) { - printf("Test that a target reset clears PREVENTALLOW.\n"); - printf("1, Verify we can set PREVENTALLOW (if the medium is removable)\n"); - printf("2, Verify we can no longer eject the media\n"); - printf("3, Send a Warm Reset to the target\n"); - printf("4, Verify we can eject the media\n"); - printf("5, Load the media again in case it was ejected\n"); - printf("6, Clear PREVENTALLOW again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!inq->rmb) { - 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) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - printf("Send a Warm Reset to the target ... "); - iscsi_task_mgmt_target_warm_reset_async(iscsi, mgmt_cb, &mgmt_task); - while (mgmt_task.finished == 0) { - pfd.fd = iscsi_get_fd(iscsi); - pfd.events = iscsi_which_events(iscsi); - - if (poll(&pfd, 1, -1) < 0) { - printf("Poll failed"); - goto finished; - } - if (iscsi_service(iscsi, pfd.revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); - break; - } - } - if (mgmt_task.status != 0) { - printf("[FAILED]\n"); - printf("Failed to reset the target\n"); - goto finished; - } - printf("[OK]\n"); - -again: - printf("Use TESTUNITREADY and clear any unit attentions.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto again; - } - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SBC doesnt really say anything about whether we can LOAD media when the prevent - * flag is set - */ - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0384_preventallow_target_cold_reset.c b/test-tool/0384_preventallow_target_cold_reset.c deleted file mode 100644 index 2f7ae27..0000000 --- a/test-tool/0384_preventallow_target_cold_reset.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -struct mgmt_task { - uint32_t status; - uint32_t finished; -}; - -static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, - void *command_data, void *private_data) -{ - struct mgmt_task *mgmt_task = (struct mgmt_task *)private_data; - - mgmt_task->status = *(uint32_t *)command_data; - mgmt_task->finished = 1; -} - - -int T0384_preventallow_target_cold_reset(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - struct mgmt_task mgmt_task = {0, 0}; - struct pollfd pfd; - - printf("0384_preventallow_target_cold_reset:\n"); - printf("====================================\n"); - if (show_info) { - printf("Test that a target reset clears PREVENTALLOW.\n"); - printf("1, Verify we can set PREVENTALLOW (if the medium is removable)\n"); - printf("2, Verify we can no longer eject the media\n"); - printf("3, Send a Cold Reset to the target\n"); - printf("4, Verify we can eject the media\n"); - printf("5, Load the media again in case it was ejected\n"); - printf("6, Clear PREVENTALLOW again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!inq->rmb) { - 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) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - printf("Send a Cold Reset to the target ... "); - iscsi_task_mgmt_target_cold_reset_async(iscsi, mgmt_cb, &mgmt_task); - while (mgmt_task.finished == 0) { - pfd.fd = iscsi_get_fd(iscsi); - pfd.events = iscsi_which_events(iscsi); - - if (poll(&pfd, 1, -1) < 0) { - printf("Poll failed"); - goto finished; - } - if (iscsi_service(iscsi, pfd.revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); - break; - } - } - if (mgmt_task.status != 0) { - printf("[FAILED]\n"); - printf("Failed to reset the target\n"); - goto finished; - } - printf("[OK]\n"); - -again: - printf("Use TESTUNITREADY and clear any unit attentions.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto again; - } - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SBC doesnt really say anything about whether we can LOAD media when the prevent - * flag is set - */ - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0385_preventallow_lun_reset.c b/test-tool/0385_preventallow_lun_reset.c deleted file mode 100644 index 77b9a76..0000000 --- a/test-tool/0385_preventallow_lun_reset.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -struct mgmt_task { - uint32_t status; - uint32_t finished; -}; - -static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, - void *command_data, void *private_data) -{ - struct mgmt_task *mgmt_task = (struct mgmt_task *)private_data; - - mgmt_task->status = *(uint32_t *)command_data; - mgmt_task->finished = 1; -} - - -int T0385_preventallow_lun_reset(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - struct mgmt_task mgmt_task = {0, 0}; - struct pollfd pfd; - - printf("0385_preventallow_lun_reset:\n"); - printf("============================\n"); - if (show_info) { - printf("Test that a target reset clears PREVENTALLOW.\n"); - printf("1, Verify we can set PREVENTALLOW (if the medium is removable)\n"); - printf("2, Verify we can no longer eject the media\n"); - printf("3, Send a LUN Reset to the target\n"); - printf("4, Verify we can eject the media\n"); - printf("5, Load the media again in case it was ejected\n"); - printf("6, Clear PREVENTALLOW again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!inq->rmb) { - 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) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - printf("Send a LUN Reset to the target ... "); - iscsi_task_mgmt_lun_reset_async(iscsi, lun, mgmt_cb, &mgmt_task); - while (mgmt_task.finished == 0) { - pfd.fd = iscsi_get_fd(iscsi); - pfd.events = iscsi_which_events(iscsi); - - if (poll(&pfd, 1, -1) < 0) { - printf("Poll failed"); - goto finished; - } - if (iscsi_service(iscsi, pfd.revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); - break; - } - } - if (mgmt_task.status != 0) { - printf("[FAILED]\n"); - printf("Failed to reset the LUN\n"); - goto finished; - } - printf("[OK]\n"); - -again: - printf("Use TESTUNITREADY and clear any unit attentions.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto again; - } - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SBC doesnt really say anything about whether we can LOAD media when the prevent - * flag is set - */ - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0386_preventallow_2_it_nexuses.c b/test-tool/0386_preventallow_2_it_nexuses.c deleted file mode 100644 index 37cb161..0000000 --- a/test-tool/0386_preventallow_2_it_nexuses.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -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; - int ret, lun; - - printf("0386_preventallow_2_itl_nexuses:\n"); - printf("============================\n"); - if (show_info) { - printf("Test that each IT nexus has its own PREVENT setting\n"); - printf("1, Verify we can set PREVENTALLOW on two IT_Nexusen (if the medium is removable)\n"); - printf("2, Verify we can no longer eject the media\n"); - printf("3, Remove the PREVENT on this IT_Nexus\n"); - printf("4, Verify we can still not eject the media\n"); - printf("5, Load the media again in case it was ejected\n"); - printf("6, Clear PREVENTALLOW again\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - if (!inq->rmb) { - printf("Media is not removable. Skipping tests\n"); - ret = -2; - goto finished; - } - - ret = 0; - - - printf("Try to set PREVENTALLOW on 2 different IT_Nexusen ... "); - task = iscsi_preventallow_sync(iscsi, lun, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - 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. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - - iscsi2 = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - task = iscsi_preventallow_sync(iscsi2, lun, 1); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi2)); - ret = -1; - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - 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 = -1; - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -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 = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("Eject failed. [OK]\n"); - - - 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 = -1; - goto finished; - } - /* SBC doesnt really say anything about whether we can LOAD media when the prevent - * flag is set - */ - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - 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 = -1; - goto finished; - } - /* SPC doesnt really say anything about what should happen if using PREVENTALLOW - * on a device that does not support medium removals. - */ - if (inq->rmb) { - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - - task = iscsi_preventallow_sync(iscsi2, lun, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi2)); - ret = -1; - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - if (iscsi2 != NULL) { - iscsi_destroy_context(iscsi2); - } - return ret; -} diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c deleted file mode 100644 index 14798d5..0000000 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret = 0, lun; - unsigned char data[4096]; - - printf("0390_mandatory_opcodes_sbc:\n"); - printf("===========================\n"); - if (show_info) { - printf("Test support for all mandatory opcodes for SBC devices\n"); - printf("1, Verify FORMAT UNIT is available\n"); - printf("2, Verify INQUIRY is available\n"); - printf("3, Verify MAINTENANCE IN is available (if SCCS bit is set)\n"); - printf("4, Verify MAINTENANCE OUT is available (if SCCS bit is set)\n"); - printf("5, Verify READ CAPACITY10 is available\n"); - printf("6, Verify READ CAPACITY16 is available\n"); - printf("7, Verify RECEIVE DIAGNOSTIC RESULT is available (if ENCSERV bit is set)\n"); - printf("8, Verify REDUNDANCY GROUP IN is available (if SCCS bit is set)\n"); - printf("9, Verify REDUNDANCY GROUP OUT is available (if SCCS bit is set)\n"); - printf("10, Verify REPORT LUNS is available\n"); - printf("11, Verify REQUEST SENSE is available\n"); - printf("12, Verify SEND DIAGNOSTIC is available\n"); - printf("13, Verify SPARE IN is available (if SCCS bit is set)\n"); - printf("14, Verify SPARE OUT is available (if SCCS bit is set)\n"); - printf("15, Verify TEST UNIT READY is available\n"); - printf("16, Verify UNAMP is available (if LBPME bit is set)\n"); - printf("17, Verify VOLUME SET IN is available (if SCCS bit is set)\n"); - printf("18, Verify VOLUME SET OUT is available (if SCCS bit is set)\n"); - printf("19, Verify WRITE SAME16 is available (if LBPME bit is set)\n"); - printf("20, Verify WRITE SAME32 is available (if LBPME bit is set)\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." - " Skipping test"); - return -2; - } - if (!data_loss) { - logging(LOG_VERBOSE, "[SKIPPED] --dataloss flag not set." - " Skipping test"); - return -2; - } - - printf("Test FORMAT UNIT ... "); - printf("[TEST NOT IMPLEMENTED YET]\n"); - - - printf("Test INQUIRY.\n"); - if (inquiry(iscsi, lun, 0, 0, 64, NULL) == -1) { - ret = -1; - } - - - printf("Test MAINTENANCE IN ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - printf("Test MAINTENANCE OUT ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - 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 = -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 = -1; - } else { - printf("[OK]\n"); - } - scsi_free_scsi_task(task); - - - 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 = -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 = -1; - } else { - printf("[OK]\n"); - } - scsi_free_scsi_task(task); - - - printf("Test RECEIVE DIAGNOSTIC RESULT ... "); - if (inq->encserv == 0) { - printf("[ENCSERV == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - printf("Test REDUNDANCY GROUP IN ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - printf("Test REDUNDANCY GROUP OUT ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - 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 = -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 = -1; - } else { - printf("[OK]\n"); - } - scsi_free_scsi_task(task); - - - printf("Test REQUEST SENSE ... "); - printf("[TEST NOT IMPLEMENTED YET]\n"); - - - printf("Test SEND DIAGNOSTIC ... "); - printf("[TEST NOT IMPLEMENTED YET]\n"); - - - printf("Test SPARE IN ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - goto finished; - } - printf("[TEST NOT IMPLEMENTED YET]\n"); - - - printf("Test SPARE OUT ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - printf("Test TEST UNIT READY.\n"); - if (testunitready(iscsi, lun) == -1) { - ret = -1; - } - - - printf("Test UNMAP ... "); - if (rc16 == NULL || rc16->lbpme == 0){ - printf("[LBPME == 0, SKIPPING TEST]\n"); - } 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); - } - - - printf("Test VOLUME SET IN ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - printf("Test VOLUME SET OUT ... "); - if (inq->sccs == 0) { - printf("[SCCS == 0, SKIPPING TEST]\n"); - } else { - printf("[TEST NOT IMPLEMENTED YET]\n"); - } - - - printf("Test WRITE SAME16 ... "); - if (rc16 == NULL || rc16->lbpme == 0){ - printf("[LBPME == 0, SKIPPING TEST]\n"); - } else { - task = iscsi_writesame16_sync(iscsi, lun, 0, - data, block_size, - 1, - 0, 1, 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); - } - - printf("Test WRITE SAME32 ... "); - printf("[TEST NOT IMPLEMENTED YET]\n"); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0400_inquiry_basic.c b/test-tool/0400_inquiry_basic.c deleted file mode 100644 index 73c48e8..0000000 --- a/test-tool/0400_inquiry_basic.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0400_inquiry_basic(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_inquiry_standard *std_inq; - int ret, lun, i; - int full_size; - - printf("0400_inquiry_basic:\n"); - printf("===================\n"); - if (show_info) { - printf("Test the standard INQUIRY data format.\n"); - printf("1, Check we can read the standard INQUIRY data.\n"); - printf("2, Standard data must be at least 36 bytes in size.\n"); - printf("3, Device-type must be either of DISK/TAPE/CDROM.\n"); - printf("4, Check that peripheral-qualifier field is 0.\n"); - printf("5, Check that the version field is valid.\n"); - printf("6, Check that response-data-format is valid.\n"); - printf("7, Check that additional-length is valid.\n"); - printf("8, Verify HiSup flag is set.\n"); - printf("9, Verify vendor-identification is in ASCII.\n"); - printf("10, Verify product-identification is in ASCII.\n"); - printf("11, Verify product-revision-level is in ASCII.\n"); - printf("12, Verify AERC is clear in SPC-3 and later.\n"); - printf("13, Verify TrmTsk is clear in SPC-2 and later.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - - printf("Read standard INQUIRY data ... "); - /* See how big this inquiry data is */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 255); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY command failed : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - 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("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - std_inq = scsi_datain_unmarshall(task); - if (std_inq == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Check that standard data is >= 36 bytes in size ... "); - if (full_size < 36) { - printf("[FAILED]\n"); - printf("Standard INQUIRY data is less than 36 bytes.\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Check device-type is either of DISK, TAPE or CD/DVD ... "); - switch (std_inq->device_type) { - case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS: - case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SEQUENTIAL_ACCESS: - case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_MMC: - break; - default: - printf("[FAILED]\n"); - printf("Device-type is not DISK, TAPE or CD/DVD. Device reported:%s\n", scsi_devtype_to_str(std_inq->device_type)); - ret = -1; - goto test4; - } - printf("[OK]\n"); - - -test4: - printf("Check PREIPHERAL QUALIFIER FIELD is 0 ... "); - if (std_inq->qualifier != 0) { - printf("[FAILED]\n"); - printf("QUALIFIER was not 0, it was %d\n", std_inq->qualifier); - ret = -1; - goto test5; - } - printf("[OK]\n"); - -test5: - printf("Check VERSION field is either 0x4, 0x5 or 0x6 ... "); - switch (std_inq->version) { - case 0x4: /* SPC-2 */ - case 0x5: /* SPC-3 */ - case 0x6: /* SPC-4 */ - break; - default: - printf("[FAILED]\n"); - printf("Invalid VERSION:%d. Should be 0x4, 0x5 or 0x6\n", std_inq->version); - ret = -1; - goto test6; - } - printf("[OK]\n"); - -test6: - printf("Check RESPONSE DATA FORMAT is 2 ... "); - if (std_inq->response_data_format != 2) { - printf("[FAILED]\n"); - printf("Invalid RESPONSE_DATA_FORMAT:%d. Should be 2\n", std_inq->response_data_format); - ret = -1; - goto test7; - } - printf("[OK]\n"); - -test7: - printf("Verify Additional-Length ... "); - if (std_inq->additional_length + 5 != full_size) { - printf("[FAILED]\n"); - printf("Invalid additional-length. Was %d but should be %d\n", std_inq->additional_length, full_size-5); - ret = -1; - goto test8; - } - printf("[OK]\n"); - -test8: - printf("Verify HiSup is set ... "); - if (!std_inq->hisup) { - printf("[FAILED]\n"); - printf("HiSup flag is not set.\n"); - ret = -1; - goto test9; - } - printf("[OK]\n"); - -test9: - printf("Verify VENDOR_IDENTIFICATION is in ASCII ... "); - for (i = 8; i < 16; i++) { - /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */ - if (task->datain.data[i] == 0) { - continue; - } - if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { - continue; - } - - printf("[FAILED]\n"); - printf("VENDOR_IDENTIFICATION contains non-ASCII characters\n"); - ret = -1; - goto test10; - } - printf("[OK]\n"); - -test10: - printf("Verify PRODUCT_IDENTIFICATION is in ASCII ... "); - for (i = 16; i < 32; i++) { - /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */ - if (task->datain.data[i] == 0) { - continue; - } - if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { - continue; - } - - printf("[FAILED]\n"); - printf("PRODUCT_IDENTIFICATION contains non-ASCII characters\n"); - ret = -1; - goto test11; - } - printf("[OK]\n"); - -test11: - printf("Verify PRODUCT_REVISION_LEVEL is in ASCII ... "); - for (i = 32; i < 36; i++) { - /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */ - if (task->datain.data[i] == 0) { - continue; - } - if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { - continue; - } - - printf("[FAILED]\n"); - printf("PRODUCT_REVISION_LEVEL contains non-ASCII characters\n"); - ret = -1; - goto test12; - } - printf("[OK]\n"); - -test12: - printf("Verify AERC is clear in SPC-3 and later ... "); - if (task->datain.data[3] & 0x80 && std_inq->version >= 5) { - printf("[FAILED]\n"); - printf("AERC is set but this device reports SPC-3 or later\n"); - ret = -1; - goto test13; - } - printf("[OK]\n"); - -test13: - printf("Verify TrmTsk is clear in SPC-2 and later ... "); - if (task->datain.data[3] & 0x40 && std_inq->version >= 4) { - printf("[FAILED]\n"); - printf("TrmTsk is set but this device reports SPC-2 or later\n"); - ret = -1; - goto test14; - } - printf("[OK]\n"); - -test14: - - - - scsi_free_scsi_task(task); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0401_inquiry_alloclen.c b/test-tool/0401_inquiry_alloclen.c deleted file mode 100644 index c56c941..0000000 --- a/test-tool/0401_inquiry_alloclen.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0401_inquiry_alloclen(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun, i; - - printf("0401_inquiry_alloclen:\n"); - printf("===================\n"); - if (show_info) { - printf("Test INQUIRY with alloclen 0-255.\n"); - printf("1, Test standard inquiry with alloclen 0-255 is successful\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - - printf("Test INQUIRY with alloclen 0-255 ... "); - for (i = 0; i < 256; i++) { - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, i); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY command with alloclen:%d failed : %s\n", i, iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0402_inquiry_evpd.c b/test-tool/0402_inquiry_evpd.c deleted file mode 100644 index b77c579..0000000 --- a/test-tool/0402_inquiry_evpd.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0402_inquiry_evpd(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun, i; - - printf("0402_inquiry_evpd:\n"); - printf("===================\n"); - if (show_info) { - printf("Test the EVPD flag.\n"); - printf("1, Test that EVPD==0 and PC!=0 is an error\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - - printf("Test INQUIRY with EVPD==0 and PC!=0 ... "); - for (i = 1; i < 256; i++) { - task = iscsi_inquiry_sync(iscsi, lun, 0, i, 255); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - 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("INQUIRY should have failed with wrong sense code. It failed with %s but should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0403_inquiry_supported_vpd.c b/test-tool/0403_inquiry_supported_vpd.c deleted file mode 100644 index b3ea50f..0000000 --- a/test-tool/0403_inquiry_supported_vpd.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0403_inquiry_supported_vpd(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_inquiry_supported_pages *std_inq; - size_t i; - int ret, lun, j; - int full_size; - int page_code; - enum scsi_inquiry_pagecode required_spc_pages[] = { - SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, - SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION - }; - - printf("0403_inquiry_supported_vpd:\n"); - printf("==========================\n"); - if (show_info) { - printf("Check the INQUIRY SUPPORTED VPD page.\n"); - printf("1, Check we can read the SUPPORTED VPD page.\n"); - printf("2, Verify we have all mandatory SPC VPD pages\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - printf("Read SUPPORTED VPD data ... "); - /* See how big this inquiry data is */ - page_code = SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES; - task = iscsi_inquiry_sync(iscsi, lun, 1, page_code, 255); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY command failed : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - 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, 1, page_code, full_size)) == NULL) { - printf("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - std_inq = scsi_datain_unmarshall(task); - if (std_inq == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Verify we have all mandatory SPC VPD pages:\n"); - for (i = 0; i < sizeof(required_spc_pages) / sizeof(enum scsi_inquiry_pagecode); i++) { - printf("Verify the target supports page 0x%02x ... ", required_spc_pages[i]); - for (j = 0; j < std_inq->num_pages; j++) { - if (required_spc_pages[i] == std_inq->pages[j]) { - break; - } - } - if (j == std_inq->num_pages) { - printf("[FAILED]\n"); - printf("Target did not report page 0x%02x. This page is mandatory in SPC.\n", required_spc_pages[i]); - ret = -1; - } else { - printf("[OK]\n"); - } - } - - scsi_free_scsi_task(task); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0404_inquiry_all_reported_vpd.c b/test-tool/0404_inquiry_all_reported_vpd.c deleted file mode 100644 index f990eaf..0000000 --- a/test-tool/0404_inquiry_all_reported_vpd.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_inquiry_supported_pages *sup_inq; - int ret, lun, i; - int full_size; - enum scsi_inquiry_pagecode page_code; - - printf("0404_inquiry_all_reported_vpd:\n"); - printf("==========================\n"); - if (show_info) { - printf("Check the INQUIRY SUPPORTED VPD page.\n"); - printf("1, Check we can read the SUPPORTED VPD page.\n"); - printf("2, Verify we can read each reported page and check the qualifier,device-type and page code on the returned data\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - - printf("Read SUPPORTED VPD data ... "); - /* See how big this inquiry data is */ - page_code = SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES; - task = iscsi_inquiry_sync(iscsi, lun, 1, page_code, 255); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY command failed : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - 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, 1, page_code, full_size)) == NULL) { - printf("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - sup_inq = scsi_datain_unmarshall(task); - if (sup_inq == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Read each page and verify qualifier, type and page code:\n"); - for (i = 0; i < sup_inq->num_pages; i++) { - struct scsi_task *pc_task; - - printf("Verify page 0x%02x can be read ... ", sup_inq->pages[i]); - pc_task = iscsi_inquiry_sync(iscsi, lun, 1, sup_inq->pages[i], 255); - if (pc_task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - continue; - } - if (pc_task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Failed to read VPD page : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(pc_task); - ret = -1; - continue; - } - printf("[OK]\n"); - - printf("Verify page 0x%02x qualifier ... ", sup_inq->pages[i]); - if ((pc_task->datain.data[0] & 0xe0) >> 5 != sup_inq->qualifier) { - printf("[FAILED]\n"); - printf("Qualifier differs between VPD pages: %x != %x\n", - pc_task->datain.data[0] & 0xe0, sup_inq->qualifier); - ret = -1; - scsi_free_scsi_task(pc_task); - continue; - } else { - printf("[OK]\n"); - } - - printf("Verify page 0x%02x device type ... ", sup_inq->pages[i]); - if ((pc_task->datain.data[0] & 0x1f) != sup_inq->device_type) { - printf("[FAILED]\n"); - printf("Device Type differs between VPD pages: %x != %x\n", - pc_task->datain.data[0] & 0x1f, sup_inq->device_type); - ret = -1; - scsi_free_scsi_task(pc_task); - continue; - } else { - printf("[OK]\n"); - } - - printf("Verify page 0x%02x page code ... ", sup_inq->pages[i]); - if (pc_task->datain.data[1] != sup_inq->pages[i]) { - printf("[FAILED]\n"); - printf("Page code is wrong: %x != %x\n", - pc_task->datain.data[1], sup_inq->pages[i]); - ret = -1; - scsi_free_scsi_task(pc_task); - continue; - } else { - printf("[OK]\n"); - } - - scsi_free_scsi_task(pc_task); - } - - scsi_free_scsi_task(task); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0410_readtoc_basic.c b/test-tool/0410_readtoc_basic.c deleted file mode 100644 index cdf5f93..0000000 --- a/test-tool/0410_readtoc_basic.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - Copyright (C) 2012 by Jon Grimm - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0410_readtoc_basic(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task, *task1; - struct scsi_inquiry_standard *std_inq; - struct scsi_readcapacity10 *rc10; - struct scsi_readtoc_list *list, *list1; - int ret, lun, i, toc_device, full_size; - int is_blank = 0; - int no_medium = 0; - - printf("0410_readtoc_basic:\n"); - printf("===================\n"); - if (show_info) { - printf("Test Read TOC command.\n"); - printf(" If device does not support, just verify appropriate error returned\n"); - printf("1, Verify we can read the TOC: track 0, non-MSF. (non-MMC devices should return sense)\n"); - printf("2, Make sure at least 4 bytes returned as header.\n"); - printf("3, Verify we can read the TOC: track 1, non-MSF.\n"); - printf("4, Make sure at least 4 bytes returned as header.\n"); - printf("5, Verify track 0 and 1 both returned the same data.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - - printf("Read standard INQUIRY data ... "); - /* Submit INQUIRY so we can find out the device type */ - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 255); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("INQUIRY command failed : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - 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("[FAILED]\n"); - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - std_inq = scsi_datain_unmarshall(task); - if (std_inq == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Check device-type is either of DISK, TAPE or CD/DVD ... "); - switch (std_inq->device_type) { - case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_MMC: - toc_device = 1; - break; - case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS: - case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SEQUENTIAL_ACCESS: - toc_device = 0; - break; - default: - /* Unknown device type */ - printf("[SKIPPED]\n"); - printf("This test is only available on SBC/SBC/SSC devices\n"); - ret = -2; - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("CD/DVD Device. Check if medium present ... "); - task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - rc10 = scsi_datain_unmarshall(task); - if (rc10 == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - /* LBA will return 0, if the medium is blank. */ - is_blank = rc10->lba ? 0 : 1; - } - /* If we get 'medium not present' there is no medium in the drive */ - 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)) { - no_medium = 1; - printf("[OK]\n"); - printf("No medium in drive. Medium access commands should fail\n"); - goto test1; - } else if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - - scsi_free_scsi_task(task); - - printf("[OK]\n"); - if (is_blank) { - printf("Blank disk loaded. ReadTOC should fail.\n"); - } else { - printf("There is a disk in the drive. ReadTOC should work.\n"); - } - - - -test1: - printf("Verify we can READTOC format 0000b (TOC) track 0 (%s) ... ", - toc_device ? "On MMC Device" : "On non-MMC Device" - ); - - task = iscsi_readtoc_sync(iscsi, lun, 0, 0, 0, 255); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READTOC command : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - - - /* If no medium, just check if we have appropriate error and bail. */ - if (no_medium) { - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READTOC Should have failed since no medium is loaded.\n"); - scsi_free_scsi_task(task); - ret = -1; - 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("READTOC failed but ascq was wrong. Should " - "have failed with MEDIUM_NOT_PRESENT. " - "Sense:%s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - - printf("[OK]\n"); - printf("No disk, we got the correct sense code that medium is not present. Skipping the remainder of the test\n"); - scsi_free_scsi_task(task); - goto finished; - } - - - /* If this is a non-MMC device, just verify that that comand failed - as expected and then bail */ - if (!toc_device) { - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READTOC Should have failed\n"); - ret = -1; - } else if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - printf("[FAILED]\n"); - printf("READTOC failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/INVALID OPERATION_CODE. Sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; - } else { - printf("[OK]\n"); - printf("Not an MMC device so READTOC failed as it should. Skipping rest of test\n"); - } - scsi_free_scsi_task(task); - goto finished; - } - - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READTOC command failed : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - /* If we get here, there is a disk loaded and it contains data */ - printf("Verify we got at least 4 bytes of data for track 0 ... "); - full_size = scsi_datain_getfullsize(task); - if (full_size < 4) { - printf("[FAILED]\n"); - printf("TOC Data Length %d < 4\n", full_size); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - list = scsi_datain_unmarshall(task); - if (list == NULL) { - printf("[FAILED]\n"); - printf("Read TOC Unmarshall failed\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Verify we can READTOC format 0000b (TOC) track 1 ... "); - task1 = iscsi_readtoc_sync(iscsi, lun, 0, 1, 0, 255); - if (task1 == NULL) { - printf("[FAILED]\n"); - printf("Failed to send READTOC command : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - - if (task1->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("READTOC command failed : %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - scsi_free_scsi_task(task1); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Verify we got at least 4 bytes of data for track 1 ... "); - full_size = scsi_datain_getfullsize(task1); - if (full_size < 4) { - printf("[FAILED]\n"); - printf("TOC Data Length %d < 4\n", full_size); - scsi_free_scsi_task(task); - scsi_free_scsi_task(task1); - ret = -1; - goto finished; - } - list1 = scsi_datain_unmarshall(task1); - if (list1 == NULL) { - printf("[FAILED]\n"); - printf("Read TOC Unmarshall failed\n"); - scsi_free_scsi_task(task); - scsi_free_scsi_task(task1); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - printf("Verify track 0 and 1 both returned the same data ... "); - if (list->num != list1->num || - list->first != list1->first || - list->last != list1->last) { - printf("[FAILED]\n"); - printf("Read TOC header of lba 0 != TOC of lba 1.\n"); - ret = -1; - scsi_free_scsi_task(task); - scsi_free_scsi_task(task1); - goto finished; - } - - for (i=0; inum; i++) { - if (list->desc[i].desc.toc.adr != list1->desc[i].desc.toc.adr || - list->desc[i].desc.toc.control != list1->desc[i].desc.toc.control || - list->desc[i].desc.toc.track != list1->desc[i].desc.toc.track || - list->desc[i].desc.toc.lba != list1->desc[i].desc.toc.lba) { - printf("[FAILED]\n"); - printf("Read TOC descriptors of lba 0 != TOC of lba 1.\n"); - ret = -1; - scsi_free_scsi_task(task); - scsi_free_scsi_task(task1); - goto finished; - } - } - printf("[OK]\n"); - scsi_free_scsi_task(task); - scsi_free_scsi_task(task1); - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/0420_reserve6_simple.c b/test-tool/0420_reserve6_simple.c deleted file mode 100644 index 6553141..0000000 --- a/test-tool/0420_reserve6_simple.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - Copyright (C) 2012 by Jon Grimm - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0420_reserve6_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - struct scsi_task *task; - int ret, lun; - - printf("0420_reserve6_simple:\n"); - printf("===================\n"); - if (show_info) { - printf("Test RESERVE6/RELEASE6 commands if supported.\n"); - printf(" If device does not support, just verify appropriate error returned\n"); - printf("1. Test simple RESERVE6 followed by RELEASE6\n"); - printf("2. Test Initator 1 can reserve if already reserved by Intiator 1.\n"); - printf("3. Test Initiator 2 can't reserve if already reserved by Initiator 1.\n"); - printf("3a. Test Initiator 2 release when reserved by Initiator 1 returns success, but without releasing.\n"); - printf("4. Test Initiator 1 can testunitready if reserved by Initiator 1.\n"); - printf("5. Test Initiator 2 can't testunitready if reserved by Initiator 1.\n"); - printf("6. Test Initiator 2 can get reservation once Intiator 1 releases reservation.\n"); - - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi2 = iscsi_context_login(initiatorname2, url, &lun); - if (iscsi2 == NULL) { - printf("Failed to login to target\n"); - ret = 1; - goto finished; - } - - ret = 0; - - printf("Send RESERVE6 ... "); - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - printf("[OK]\n"); - printf("RESERVE6 Not Supported\n"); - scsi_free_scsi_task(task); - goto finished; - } else { - printf("[FAILED]\n"); - printf("RESERVE6 failed but ascq was wrong. Should " - "have failed with ILLEGAL_REQUEST/" - "INVALID OPERATOR. Sense:%s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Send RELEASE6 ... "); - task = iscsi_release6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Test that reservation works.\n"); - printf("Send RESERVE6 from Initiator 1. ... "); - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 command failed : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Send RESERVE6 from Initiator 2. Expect conflict. ... "); - task = iscsi_reserve6_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - /* We expect this command to fail for the test to pass. */ - if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { - printf("[FAILED]\n"); - printf("Expected RESERVATION CONFLICT\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Send RELEASE6 from Initiator 2..Expect NO-OP. ... "); - task = iscsi_release6_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - /* We expect this command to pass. */ - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RELEASE6 command: failed with sense %s\n", - iscsi_get_error(iscsi)); - ret = -1; - /* Treat as non-fatal failure for now. STGT is broken.*/ - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Send TESTUNITREADY from Initiator 1\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - printf("Send TESTUNITREADY from Initiator 2. Expect conflict.\n"); - ret = testunitready_conflict(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - printf("Test that release actually works\n"); - printf("Send RELEASE6 from Initiator 1 ... "); - task = iscsi_release6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Send RESERVE6 Initiator 2 ... "); - task = iscsi_reserve6_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 command failed : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - printf("Send RELEASE6 Initiator 2 ... "); - task = iscsi_reserve6_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - goto finished; - - -finished: - if (iscsi2 != NULL) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (iscsi != NULL) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - return ret; -} diff --git a/test-tool/0421_reserve6_lun_reset.c b/test-tool/0421_reserve6_lun_reset.c deleted file mode 100644 index 356c460..0000000 --- a/test-tool/0421_reserve6_lun_reset.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -struct mgmt_task { - uint32_t status; - uint32_t finished; -}; - -static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, - void *command_data, void *private_data) -{ - struct mgmt_task *mgmt_task = (struct mgmt_task *)private_data; - - mgmt_task->status = *(uint32_t *)command_data; - mgmt_task->finished = 1; -} - -int T0421_reserve6_lun_reset(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - struct scsi_task *task; - int ret, lun; - struct mgmt_task mgmt_task = {0, 0}; - struct pollfd pfd; - - printf("0421_reserve6_lun_reset:\n"); - printf("========================\n"); - if (show_info) { - printf("Test that a RESERVE6 is dropped by a LUN-reset\n"); - printf(" If device does not support RESERVE6, just skip the test.\n"); - printf("1, Reserve the device from the first initiator.\n"); - printf("2, Verify we can access the LUN from the first initiator\n"); - printf("3, Verify we can NOT access the LUN from the second initiator\n"); - printf("4, Send a LUN-reset to the target\n"); - printf("5, Verify we can access the LUN from the second initiator\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi2 = iscsi_context_login(initiatorname2, url, &lun); - if (iscsi2 == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - - - printf("Send RESERVE6 from the first initiator ... "); - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("RESERVE6 Not Supported\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Verify we can access the LUN from the first initiator.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("Verify we can NOT access the LUN from the second initiator.\n"); - ret = testunitready_conflict(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - printf("Send a LUN Reset to the target ... "); - iscsi_task_mgmt_lun_reset_async(iscsi, lun, mgmt_cb, &mgmt_task); - while (mgmt_task.finished == 0) { - pfd.fd = iscsi_get_fd(iscsi); - pfd.events = iscsi_which_events(iscsi); - - if (poll(&pfd, 1, -1) < 0) { - printf("Poll failed"); - goto finished; - } - if (iscsi_service(iscsi, pfd.revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); - break; - } - } - if (mgmt_task.status != 0) { - printf("[FAILED]\n"); - printf("Failed to reset the LUN\n"); - goto finished; - } - printf("[OK]\n"); - - - /* We might be getting UNIT_ATTENTION/BUS_RESET after the lun-reset above. - If so just loop and try the TESTUNITREADY again until it clears - */ - printf("Use TESTUNITREADY and clear any unit attentions on the second initiator.\n"); -again: - ret = testunitready(iscsi2, lun); - if (ret != 0) { - goto again; - } - - - printf("Verify we can access the LUN from the second initiator.\n"); - ret = testunitready(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - -finished: - if (iscsi2 != NULL) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (iscsi != NULL) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - return ret; -} diff --git a/test-tool/0422_reserve6_logout.c b/test-tool/0422_reserve6_logout.c deleted file mode 100644 index 077423a..0000000 --- a/test-tool/0422_reserve6_logout.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0422_reserve6_logout(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - struct scsi_task *task; - int ret, lun; - - printf("0422_reserve6_logout:\n"); - printf("=====================\n"); - if (show_info) { - printf("Test that a RESERVE6 is dropped when the session is logged out\n"); - printf(" If device does not support RESERVE6, just skip the test.\n"); - printf("1, Reserve the device from the first initiator.\n"); - printf("2, Verify we can access the LUN from the first initiator.\n"); - printf("3, Verify we can NOT access the LUN from the second initiator.\n"); - printf("4, Logout the first initiator.\n"); - printf("5, Verify we can access the LUN from the second initiator.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi2 = iscsi_context_login(initiatorname2, url, &lun); - if (iscsi2 == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - - - printf("Send RESERVE6 from the first initiator ... "); - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("RESERVE6 Not Supported\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Verify we can access the LUN from the first initiator.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("Verify we can NOT access the LUN from the second initiator.\n"); - ret = testunitready_conflict(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - printf("Logout the first initiator ... "); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - iscsi = NULL; - printf("[OK]\n"); - - printf("Verify we can access the LUN from the second initiator.\n"); - ret = testunitready(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - -finished: - if (iscsi2 != NULL) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (iscsi != NULL) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - return ret; -} diff --git a/test-tool/0423_reserve6_sessionloss.c b/test-tool/0423_reserve6_sessionloss.c deleted file mode 100644 index 0b22690..0000000 --- a/test-tool/0423_reserve6_sessionloss.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0423_reserve6_sessionloss(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - struct scsi_task *task; - int ret, lun; - - printf("0423_reserve6_sessionloss:\n"); - printf("=====================\n"); - if (show_info) { - printf("Test that a RESERVE6 is dropped when the session is dropped\n"); - printf(" If device does not support RESERVE6, just skip the test.\n"); - printf("1, Reserve the device from the first initiator.\n"); - printf("2, Verify we can access the LUN from the first initiator.\n"); - printf("3, Verify we can NOT access the LUN from the second initiator.\n"); - printf("4, Drop session for the first initiator.\n"); - printf("5, Verify we can access the LUN from the second initiator.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi2 = iscsi_context_login(initiatorname2, url, &lun); - if (iscsi2 == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - - - - printf("Send RESERVE6 from the first initiator ... "); - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("RESERVE6 Not Supported\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Verify we can access the LUN from the first initiator.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("Verify we can NOT access the LUN from the second initiator.\n"); - ret = testunitready_conflict(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - - printf("Drop the session to the first initiator ... "); - iscsi_destroy_context(iscsi); - iscsi = NULL; - printf("[OK]\n"); - - printf("Verify we can access the LUN from the second initiator.\n"); - ret = testunitready(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - -finished: - if (iscsi2 != NULL) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (iscsi != NULL) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - return ret; -} diff --git a/test-tool/0424_reserve6_target_reset.c b/test-tool/0424_reserve6_target_reset.c deleted file mode 100644 index 8d49276..0000000 --- a/test-tool/0424_reserve6_target_reset.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -struct mgmt_task { - uint32_t status; - uint32_t finished; -}; - -static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, - void *command_data, void *private_data) -{ - struct mgmt_task *mgmt_task = (struct mgmt_task *)private_data; - - mgmt_task->status = *(uint32_t *)command_data; - mgmt_task->finished = 1; -} - -int T0424_reserve6_target_reset(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - struct scsi_task *task; - int ret, lun; - struct mgmt_task mgmt_task = {0, 0}; - struct pollfd pfd; - - printf("0424_reserve6_target_reset:\n"); - printf("========================\n"); - if (show_info) { - printf("Test that a RESERVE6 is dropped by a Target-reset\n"); - printf(" If device does not support RESERVE6, just skip the test.\n"); - printf("1, Reserve the device from the first initiator.\n"); - printf("2, Verify we can access the LUN from the first initiator\n"); - printf("3, Verify we can NOT access the LUN from the second initiator\n"); - printf("4, Send a Target-reset\n"); - printf("5, Verify we can access the LUN from the second initiator\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi2 = iscsi_context_login(initiatorname2, url, &lun); - if (iscsi2 == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - printf("Send RESERVE6 from the first initiator ... "); - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("RESERVE6 Not Supported\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - printf("Verify we can access the LUN from the first initiator.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("Verify we can NOT access the LUN from the second initiator.\n"); - ret = testunitready_conflict(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - printf("Send a Target Cold-Reset ... "); - iscsi_task_mgmt_target_cold_reset_async(iscsi, mgmt_cb, &mgmt_task); - while (mgmt_task.finished == 0) { - pfd.fd = iscsi_get_fd(iscsi); - pfd.events = iscsi_which_events(iscsi); - - if (poll(&pfd, 1, -1) < 0) { - printf("Poll failed"); - goto finished; - } - if (iscsi_service(iscsi, pfd.revents) < 0) { - printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); - break; - } - } - if (mgmt_task.status != 0) { - printf("[FAILED]\n"); - printf("Failed to reset the LUN\n"); - goto finished; - } - printf("[OK]\n"); - - - /* We might be getting UNIT_ATTENTION/BUS_RESET after the lun-reset above. - If so just loop and try the TESTUNITREADY again until it clears - */ - printf("Use TESTUNITREADY and clear any unit attentions on the second initiator.\n"); -again: - ret = testunitready(iscsi2, lun); - if (ret != 0) { - goto again; - } - - - printf("Verify we can access the LUN from the second initiator ... "); - ret = testunitready(iscsi2, lun); - if (ret != 0) { - goto finished; - } - - -finished: - if (iscsi2 != NULL) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (iscsi != NULL) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - return ret; -} diff --git a/test-tool/0430_report_all_supported_ops.c b/test-tool/0430_report_all_supported_ops.c deleted file mode 100644 index 185b39d..0000000 --- a/test-tool/0430_report_all_supported_ops.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - Copyright (C) 2012 by Jon Grimm - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T0430_report_all_supported_ops(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_report_supported_op_codes *tmp_rsoc; - struct scsi_command_descriptor *desc; - int ret, lun; - int full_size, desc_size; - int i; - - printf("0430_report_all_supported_ops:\n"); - printf("===================\n"); - if (show_info) { - printf("Test MaintenanceIn: Report Supported Operations.\n"); - printf("1, Report Supported Ops (no timeout information).\n"); - printf("2, Report Supported Ops (with timeout information).\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - printf("See if Report Supported Opcodes is supported... "); - /* See how big data is */ - task = iscsi_report_supported_opcodes_sync(iscsi, lun, - 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - 4); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send Report Supported Opcodes command : %s\n", - iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", - iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", - iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - 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_report_supported_opcodes_sync(iscsi, lun, - 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - full_size)) == NULL) { - printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - tmp_rsoc = scsi_datain_unmarshall(task); - if (tmp_rsoc == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall REPORT SUPPORTED OPCODES datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - - printf("Supported Commands: %d\n", tmp_rsoc->num_descriptors); - printf("=======================\n"); - for (i = 0; i < tmp_rsoc->num_descriptors; i++) { - printf("op:%x\tsa:%x\tcdb length:%d\n", - tmp_rsoc->descriptors[i].opcode, - tmp_rsoc->descriptors[i].sa, - tmp_rsoc->descriptors[i].cdb_len); - } - - printf("\n[OK]\n"); - scsi_free_scsi_task(task); - - /*Report All Supported Operations including timeout info.*/ - printf("See if Report Supported Opcodes with Timeouts is supported... "); - /* See how big data is */ - task = iscsi_report_supported_opcodes_sync(iscsi, lun, - 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - 4); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send Report Supported Opcodes command : %s\n", - iscsi_get_error(iscsi)); - 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_OPERATION_CODE - || task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB)) { - printf("[SKIPPED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", - iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -2; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", - iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - 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_report_supported_opcodes_sync(iscsi, lun, - 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - full_size)) == NULL) { - printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES failed : %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - tmp_rsoc = scsi_datain_unmarshall(task); - if (tmp_rsoc == NULL) { - printf("[FAILED]\n"); - printf("failed to unmarshall REPORT SUPPORTED OPCODES datain blob\n"); - scsi_free_scsi_task(task); - ret = -1; - goto finished; - } - - printf("Supported Commands (with timeout information): %d\n", tmp_rsoc->num_descriptors); - printf("=======================\n"); - desc_size = sizeof (struct scsi_command_descriptor) - + sizeof (struct scsi_op_timeout_descriptor); - desc = &tmp_rsoc->descriptors[0]; - for (i = 0; i < tmp_rsoc->num_descriptors; i++) { - printf("op:%x\tsa:%x\tcdb_length:%d\ttimeout info: length:%d\tcommand specific:%x\tnominal processing%d\trecommended%d\n", - desc->opcode, - desc->sa, - desc->cdb_len, - desc->to.descriptor_length, - desc->to.command_specific, - desc->to.nominal_processing_timeout, - desc->to.recommended_timeout); - desc = (struct scsi_command_descriptor *)((char *)desc + - desc_size); - } - - printf("\n[OK]\n"); - scsi_free_scsi_task(task); - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/1000_cmdsn_invalid.c b/test-tool/1000_cmdsn_invalid.c deleted file mode 100644 index 121ae35..0000000 --- a/test-tool/1000_cmdsn_invalid.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -static int change_cmdsn; - -static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) -{ - switch (change_cmdsn) { - case 1: - /* change the cmdsn so it becomes too big */ - scsi_set_uint32(&pdu->outdata.data[24], iscsi->maxcmdsn + 1); - break; - case 2: - /* change the cmdsn so it becomes too small */ - scsi_set_uint32(&pdu->outdata.data[24], 0); - break; - } - - change_cmdsn = 0; - return 0; -} - -static void test_cb(struct iscsi_context *iscsi _U_, int status, - void *command_data _U_, void *private_data) -{ - struct scsi_task *task = command_data; - struct iscsi_async_state *state = private_data; - - state->finished = 1; - state->status = status; - - if (status) { - task->status = status; - } -} - - -int T1000_cmdsn_invalid(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - unsigned char data[4096 * 2]; - struct iscsi_async_state test_state; - - printf("1000_cmdsn_invalid:\n"); - printf("==================\n"); - if (show_info) { - printf("Test sending commands with invalid cmdsn values.\n"); - printf("CMDSN MUST be in the range EXPCMDSN and MAXCMDSN\n"); - printf("1, Test that a CMDSN > MAXCMDSN is an error\n"); - printf("2, Test that a CMDSN == 0 is an error\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - local_iscsi_queue_pdu = my_iscsi_queue_pdu; - - printf("Write 2 blocks with CMDSN > MAXCMDSN ... "); - change_cmdsn = 1; - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - - printf("Write 2 blocks with CMDSN == 0 ... ");fflush(stdout); - change_cmdsn = 2; - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - - iscsi_set_noautoreconnect(iscsi, 1); - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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); - return ret; -} diff --git a/test-tool/1010_datasn_invalid.c b/test-tool/1010_datasn_invalid.c deleted file mode 100644 index 2516f36..0000000 --- a/test-tool/1010_datasn_invalid.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -static int clamp_datasn; - -static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu) -{ - uint32_t datasn; - - if (pdu->outdata.data[0] != ISCSI_PDU_DATA_OUT) { - return 0; - } - switch (clamp_datasn) { - case 1: - /* change datasn to 0 */ - scsi_set_uint32(&pdu->outdata.data[36], 0); - break; - case 2: - /* change datasn to 27 */ - scsi_set_uint32(&pdu->outdata.data[36], 27); - break; - case 3: - /* change datasn to -1 */ - scsi_set_uint32(&pdu->outdata.data[36], -1); - break; - case 4: - /* change datasn from (0,1) to (1,0) */ - datasn = scsi_get_uint32(&pdu->outdata.data[36]); - scsi_set_uint32(&pdu->outdata.data[36], 1 - datasn); - break; - } - return 0; -} - -static void test_cb(struct iscsi_context *iscsi _U_, int status, - void *command_data _U_, void *private_data) -{ - struct scsi_task *task = command_data; - struct iscsi_async_state *state = private_data; - - state->finished = 1; - state->status = status; - - if (status) { - task->status = status; - } -} - - -int T1010_datasn_invalid(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - unsigned char data[4096 * 2]; - struct iscsi_async_state test_state; - - printf("1010_datasn_invalid:\n"); - printf("==================\n"); - if (show_info) { - printf("Test sending commands with invalid datasn values.\n"); - printf("1, Test that 2 DATA-IN with DATASN==0 is an error\n"); - printf("2, Test that 2 DATA-IN with DATASN==27 is an error\n"); - printf("3, Test that 2 DATA-IN with DATASN==-1 is an error\n"); - printf("4, Test that 2 DATA-IN with DATASN in reverse order (1,0) is an error\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - local_iscsi_queue_pdu = my_iscsi_queue_pdu; - - printf("Write 2 DATA-IN with DATASN == 0 ... "); - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - clamp_datasn = 1; - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - clamp_datasn = 0; - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - - printf("Write 2 DATA-IN with DATASN == 27 ... "); - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - clamp_datasn = 2; - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - clamp_datasn = 0; - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - - printf("Write 2 DATA-IN with DATASN == -1 ... "); - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - clamp_datasn = 3; - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - clamp_datasn = 0; - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - - printf("Write 2 DATA-IN with DATASN in reverse order (1, 0) ... "); - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - clamp_datasn = 4; - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - clamp_datasn = 0; - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* 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); - return ret; -} diff --git a/test-tool/1020_bufferoffset_invalid.c b/test-tool/1020_bufferoffset_invalid.c deleted file mode 100644 index 8dd6230..0000000 --- a/test-tool/1020_bufferoffset_invalid.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -static int change_bufferoffset; - -static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu) -{ - uint32_t buffer_offset; - - if (pdu->outdata.data[0] != ISCSI_PDU_DATA_OUT) { - return 0; - } - buffer_offset = scsi_get_uint32(&pdu->outdata.data[40]); - switch (change_bufferoffset) { - case 1: - /* Add 1M to the buffer offset */ - scsi_set_uint32(&pdu->outdata.data[40], buffer_offset + 1024*1024); - break; - case 2: - /* Add -'block_size' to the buffer offset */ - scsi_set_uint32(&pdu->outdata.data[40], buffer_offset - block_size); - break; - } - return 0; -} - -static void test_cb(struct iscsi_context *iscsi _U_, int status, - void *command_data _U_, void *private_data) -{ - struct scsi_task *task = command_data; - struct iscsi_async_state *state = private_data; - - state->finished = 1; - state->status = status; - - if (status) { - task->status = status; - } -} - - -int T1020_bufferoffset_invalid(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - unsigned char data[4096 * 256]; - struct iscsi_async_state test_state; - - printf("1020_bufferoffset_invalid:\n"); - printf("==========================\n"); - if (show_info) { - printf("Test sending commands with invalid bufferoffset values.\n"); - printf("We negotiate both DataPDUInOrder and DataSequenceInOrder so BufferOffset must be in sequence both within and across multiple sequences\n"); - printf("1, Test that BufferOffset==1M too high is an error\n"); - printf("2, Test that BufferOffset==-'block_size' is an error\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - local_iscsi_queue_pdu = my_iscsi_queue_pdu; - - printf("Write 2 DATA-IN with BUFFEROFFSET 1M too high ... "); - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - change_bufferoffset = 1; - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - change_bufferoffset = 0; - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - - printf("Write 2 DATA-IN with BUFFEROFFSET==-%zu ... ", block_size); - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - change_bufferoffset = 2; - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - change_bufferoffset = 0; - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("WRITE10 command successful. Should have failed with error\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - /* in case the previous test failed the session */ - iscsi_set_noautoreconnect(iscsi, 0); - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - iscsi->target_max_recv_data_segment_length = block_size; - -finished: - local_iscsi_queue_pdu = NULL; - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/1030_unsolicited_data_overflow.c b/test-tool/1030_unsolicited_data_overflow.c deleted file mode 100644 index f646308..0000000 --- a/test-tool/1030_unsolicited_data_overflow.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -static void test_cb(struct iscsi_context *iscsi _U_, int status, - void *command_data _U_, void *private_data) -{ - struct scsi_task *task = command_data; - struct iscsi_async_state *state = private_data; - - state->finished = 1; - state->status = status; - - if (status) { - task->status = status; - } -} - -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; - int ret, lun; - unsigned char *buf = NULL; - struct iscsi_async_state test_state; - - printf("1030_unsolicited_data_overflow:\n"); - printf("===============================\n"); - if (show_info) { - printf("Test sending command with way more unsolicited data than the target supports\n"); - printf("1, Send HUGE unsolicited data to the target.\n"); - printf("2, Verify the target is still alive\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_YES; - - /* make first burst REAL big */ - iscsi->first_burst_length *= 16; - buf = malloc(iscsi->first_burst_length); - - printf("Write too much unsolicited data ... "); - /* we don't want autoreconnect since some targets will drop the session - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - // 102400 -- 1024000 - task = iscsi_write16_task(iscsi, lun, 0, buf, - iscsi->first_burst_length, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - printf("[OK]\n"); - - - printf("Verify the target is still alive ... "); - iscsi2 = iscsi_context_login(initiator, url, &lun); - if (iscsi2 == NULL) { - printf("[FAILED]\n"); - printf("Target is dead?\n"); - ret = -1; - goto finished; - } - printf("[OK]\n"); - -finished: - free(buf); - iscsi_destroy_context(iscsi); - iscsi_destroy_context(iscsi2); - return ret; -} diff --git a/test-tool/1031_unsolicited_data_out.c b/test-tool/1031_unsolicited_data_out.c deleted file mode 100644 index 39a1ff9..0000000 --- a/test-tool/1031_unsolicited_data_out.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -static int -my_iscsi_add_data(struct iscsi_context *iscsi _U_, struct iscsi_data *data, - unsigned char *dptr, int dsize, int pdualignment) -{ - int len, aligned; - unsigned char *buf; - - if (dsize == 0) { - printf("Trying to append zero size data to iscsi_data"); - return -1; - } - - len = data->size + dsize; - aligned = len; - if (pdualignment) { - aligned = (aligned+3)&0xfffffffc; - } - buf = malloc(aligned); - if (buf == NULL) { - printf("failed to allocate buffer for %d bytes", len); - return -1; - } - - if (data->size > 0) { - memcpy(buf, data->data, data->size); - } - memcpy(buf + data->size, dptr, dsize); - if (len != aligned) { - /* zero out any padding at the end */ - memset(buf+len, 0, aligned-len); - } - - free(data->data); - - data->data = buf; - data->size = len; - - return 0; -} - -static int -my_iscsi_pdu_add_data(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, - unsigned char *dptr, int dsize) -{ - if (my_iscsi_add_data(iscsi, &pdu->outdata, dptr, dsize, 1) != 0) { - printf("failed to add data to pdu buffer"); - return -1; - } - - /* update data segment length */ - scsi_set_uint32(&pdu->outdata.data[4], pdu->outdata.size - ISCSI_HEADER_SIZE); - - return 0; -} - -static void -my_iscsi_pdu_set_itt(struct iscsi_pdu *pdu, uint32_t itt) -{ - scsi_set_uint32(&pdu->outdata.data[16], itt); -} - -static void -my_iscsi_pdu_set_expstatsn(struct iscsi_pdu *pdu, uint32_t expstatsnsn) -{ - scsi_set_uint32(&pdu->outdata.data[28], expstatsnsn); -} - -static void -my_iscsi_pdu_set_pduflags(struct iscsi_pdu *pdu, unsigned char flags) -{ - pdu->outdata.data[1] = flags; -} - -static void -my_iscsi_pdu_set_lun(struct iscsi_pdu *pdu, uint32_t lun) -{ - pdu->outdata.data[8] = lun >> 8; - pdu->outdata.data[9] = lun & 0xff; -} - -static struct iscsi_pdu * -my_iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opcode opcode, - enum iscsi_opcode response_opcode, uint32_t itt, uint32_t flags) -{ - struct iscsi_pdu *pdu; - - pdu = malloc(sizeof(struct iscsi_pdu)); - if (pdu == NULL) { - printf("failed to allocate pdu"); - return NULL; - } - memset(pdu, 0, sizeof(struct iscsi_pdu)); - - pdu->outdata.size = ISCSI_HEADER_SIZE; - pdu->outdata.data = malloc(pdu->outdata.size); - - if (pdu->outdata.data == NULL) { - printf("failed to allocate pdu header"); - free(pdu); - return NULL; - } - memset(pdu->outdata.data, 0, pdu->outdata.size); - - /* opcode */ - pdu->outdata.data[0] = opcode; - pdu->response_opcode = response_opcode; - - /* isid */ - if (opcode == ISCSI_PDU_LOGIN_REQUEST) { - memcpy(&pdu->outdata.data[8], &iscsi->isid[0], 6); - } - - /* itt */ - my_iscsi_pdu_set_itt(pdu, itt); - pdu->itt = itt; - - /* flags */ - pdu->flags = flags; - - return pdu; -} - -int T1031_unsolicited_data_out(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi = NULL; - struct iscsi_context *iscsi2 = NULL; - int i, ret, lun; - unsigned char buf[1024]; - - printf("1031_unsolicited_data_out:\n"); - printf("==========================\n"); - if (show_info) { - printf("Test sending unsolicited DATA-OUT that are not associated with any SCSI-command.\n"); - printf("1, Send 100 DATA-OUT PDUs\n"); - printf("2, Verify the target is still alive\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - - ret = 0; - - printf("Send unsolicited DATA-OUT PDUs ... "); - for (i = 0; i < 100; i++) { - struct iscsi_pdu *pdu; - - pdu = my_iscsi_allocate_pdu_with_itt_flags(iscsi, ISCSI_PDU_DATA_OUT, - ISCSI_PDU_NO_PDU, - i + 0x1000, - ISCSI_PDU_DELETE_WHEN_SENT|ISCSI_PDU_NO_CALLBACK); - if (pdu == NULL) { - printf("Failed to allocated PDU. Aborting\n"); - ret = -2; - goto finished; - } - my_iscsi_pdu_set_pduflags(pdu, ISCSI_PDU_SCSI_FINAL); - my_iscsi_pdu_set_lun(pdu, lun); - my_iscsi_pdu_set_expstatsn(pdu, iscsi->statsn+1); - if (my_iscsi_pdu_add_data(iscsi, pdu, buf, sizeof(buf)) != 0) { - printf("Failed to add data to PDU. Aborting\n"); - ret = -2; - goto finished; - } - pdu->callback = NULL; - pdu->private_data = NULL; - if (iscsi_queue_pdu(iscsi, pdu) != 0) { - printf("Failed to queue PDU. Aborting\n"); - ret = -2; - goto finished; - } - } - printf("[OK]\n"); - - /* Send a TUR to drive the eventsystem and make sure the - * DATA-OUT PDUs are flushed - */ - printf("Send a TESTUNITREADY and flush tx queue.\n"); - ret = testunitready(iscsi, lun); - if (ret != 0) { - goto finished; - } - - - printf("Verify the target is still alive ... "); - iscsi2 = iscsi_context_login(initiator, url, &lun); - if (iscsi2 == NULL) { - printf("[FAILED]\n"); - printf("Target is dead?\n"); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - -finished: - iscsi_destroy_context(iscsi); - iscsi_destroy_context(iscsi2); - return ret; -} diff --git a/test-tool/1040_saturate_maxcmdsn.c b/test-tool/1040_saturate_maxcmdsn.c deleted file mode 100644 index 49f873b..0000000 --- a/test-tool/1040_saturate_maxcmdsn.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" -#include - -static int num_cmds_in_flight; - -static void test_cb(struct iscsi_context *iscsi _U_, int status, - void *command_data _U_, void *private_data) -{ - struct iscsi_async_state *state = private_data; - - if (status != SCSI_STATUS_GOOD) { - state->status = status; - } - - if (--num_cmds_in_flight == 0) { - state->finished = 1; - } -} - -#define T1040_NO_OF_WRITES (1024) - -int T1040_saturate_maxcmdsn(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int i, ret, lun; - unsigned char *data = NULL; - struct iscsi_async_state test_state; - - printf("1040_saturate_maxcmdsn:\n"); - printf("=======================\n"); - if (show_info) { - printf("Test sending so many commands we saturate maxcmdsn we do recover eventually\n"); - printf("1, Send 1024 commands in one go and make sure we eventually finish the queue of commands in flight\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -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; - goto finished; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - /* we don't want autoreconnect since some targets will drop the - * on this condition. - */ - iscsi_set_noautoreconnect(iscsi, 1); - - data = malloc(2*iscsi->first_burst_length); - if (data == NULL) { - printf("failed to malloc data buffer\n"); - ret = -1; - goto finished; - } - - int run=0; - - do { - if (run || iscsi->use_immediate_data == ISCSI_IMMEDIATE_DATA_NO) { - iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; - printf("Send %d Writes w/ ISCSI_IMMEDIATE_DATA_NO each needing a R2T so that we saturate the maxcmdsn queue ... ",T1040_NO_OF_WRITES); - } else { - printf("Send %d Writes w/ ISCSI_IMMEDIATE_DATA_YES each needing a R2T so that we saturate the maxcmdsn queue ... ",T1040_NO_OF_WRITES); - } - - for (i = 0; i < T1040_NO_OF_WRITES; i++) { - num_cmds_in_flight++; - task = iscsi_write10_task(iscsi, lun, 2 * iscsi->first_burst_length * i / block_size, data, 2 * iscsi->first_burst_length, block_size, - 0, 0, 0, 0, 0, - test_cb, &test_state); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - } - - test_state.task = task; - test_state.finished = 0; - test_state.status = 0; - wait_until_test_finished(iscsi, &test_state); - if (num_cmds_in_flight != 0) { - printf("[FAILED]\n"); - printf("Did not complete all I/O before deadline.\n"); - ret = -1; - goto finished; - } else if (test_state.status != 0) { - printf("[FAILED]\n"); - printf("Not all I/O commands succeeded.\n"); - ret = -1; - goto finished; - } - printf("[OK]\n"); - run++; - } while (iscsi->use_immediate_data == ISCSI_IMMEDIATE_DATA_YES); - - -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 deleted file mode 100644 index 367023a..0000000 --- a/test-tool/1041_unsolicited_immediate_data.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" -#include - -int pdu_was_valid; - -/* one block sent as immediate data. PDU should have F-bit set - * and datasegmentlength should be a single block. - */ -static int my_queue_immediate_data(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu) -{ - pdu_was_valid = 1; - - if (!(pdu->outdata.data[1] & 0x80)) { - printf("SCSI-Command PDU with immediate data did not have the F-flag set.\n"); - pdu_was_valid = 0; - return 0; - } - if ( (scsi_get_uint32(&pdu->outdata.data[4]) & 0x00ffffff) != block_size) { - printf("SCSI-Command PDU did not have one block of immediate data.\n"); - pdu_was_valid = 0; - return 0; - } - return 1; -} - -int T1041_unsolicited_immediate_data(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - struct iscsi_url *iscsi_url; - unsigned char data[4096]; - - printf("1041_unsolicited_immediate_data:\n"); - printf("================================\n"); - if (show_info) { - printf("Test we can send unsolicited data to the target\n"); - printf("1, Login to target with IMMEDIATE_DATA=YES and INITIAL_R2T=YES.\n"); - printf("2, Write one block to the target as immediate data.\n"); - printf("3, Verify that the PDU sent has the F-flag set.\n"); - printf("4, Verify that the PDU sent has of immediate data.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi_url = iscsi_parse_full_url(iscsi, url); - if (iscsi_url == NULL) { - printf("Failed to parse iscsi url\n"); - return -1; - } - - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* This setting will allow us to send unsolicited data as - * immediate data but not as a data-out. - */ - printf("Login to target with IMMEDIATE_DATA=YES and INITIAL_R2T=YES ... "); - iscsi_destroy_context(iscsi); - iscsi_url->iscsi = NULL; - iscsi = iscsi_create_context(initiator); - iscsi_set_targetname(iscsi, iscsi_url->target); - iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL); - iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); - iscsi_set_immediate_data(iscsi, ISCSI_IMMEDIATE_DATA_YES); - iscsi_set_initial_r2t(iscsi, ISCSI_INITIAL_R2T_YES); - if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, lun) != 0) { - printf("[FAILED]\n"); - printf("Failed to log in to target with IMMEDIATE_DATA=YES and INITIAL_R2T=YES %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (iscsi->use_immediate_data != ISCSI_IMMEDIATE_DATA_YES) { - printf("[FAILED]\n"); - printf("Failed to negotiate IMMEDIATE_DATA==YES with target\n"); - ret = -1; - goto finished; - } - if (iscsi->use_initial_r2t != ISCSI_INITIAL_R2T_YES) { - printf("[FAILED]\n"); - printf("Failed to negotiate INITIAL_R2T==YES with target\n"); - ret = -1; - goto finished; - } - printf("[OK]\n"); - - - - printf("Write one block as immediate data ... "); - local_iscsi_queue_pdu = my_queue_immediate_data; - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0); - local_iscsi_queue_pdu = NULL; - /* Verify that the PDU we sent had the F-bit set and that - * datasegmentlength was one block. - */ - if (pdu_was_valid == 0) { - printf("[FAILED]\n"); - printf("PDU to send was invalid.\n"); - ret = -1; - goto finished; - } - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - -finished: - iscsi_destroy_url(iscsi_url); - iscsi_destroy_context(iscsi); - - return ret; -} diff --git a/test-tool/1042_unsolicited_nonimmediate_data.c b/test-tool/1042_unsolicited_nonimmediate_data.c deleted file mode 100644 index 46d69c8..0000000 --- a/test-tool/1042_unsolicited_nonimmediate_data.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "iscsi-private.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" -#include - -static int pdu_was_valid = 1; - -/* one block sent as immediate data. PDU should have F-bit set - * and datasegmentlength should be a single block. - */ -static int my_queue_immediate_data(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu _U_) -{ - /* The COMMAND PDU */ - if ((pdu->outdata.data[0] & 0x3f) == ISCSI_PDU_SCSI_REQUEST) { - if (pdu->outdata.data[1] & 0x80) { - printf("SCSI-Command PDU with immediate data had the F-flag set.\n"); - pdu_was_valid = 0; - return 0; - } - if ( scsi_get_uint32(&pdu->outdata.data[4]) & 0x00ffffff ) { - printf("SCSI-Command PDU had non-zero datasegmentsize.\n"); - pdu_was_valid = 0; - return 0; - } - } - /* The DATA-OUT PDU */ - if ((pdu->outdata.data[0] & 0x3f) == ISCSI_PDU_DATA_OUT) { - if (!(pdu->outdata.data[1] & 0x80)) { - printf("The DATA-OUT PDU did not have the F-flag set.\n"); - pdu_was_valid = 0; - return 0; - } - if ( (scsi_get_uint32(&pdu->outdata.data[4]) & 0x00ffffff) != block_size) { - printf("The DATA-OUT PDU did not carry a full block.\n"); - pdu_was_valid = 0; - return 0; - } - } - - - return 1; -} - -int T1042_unsolicited_nonimmediate_data(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun; - struct iscsi_url *iscsi_url; - unsigned char data[4096]; - - printf("1042_unsolicited_nonimmediate_data:\n"); - printf("================================\n"); - if (show_info) { - printf("Test we can send unsolicited nonimmediate data to the target\n"); - printf("1, Login to target with IMMEDIATE_DATA=NO and INITIAL_R2T=NO.\n"); - printf("2, Write one block to the target.\n"); - printf("3, Verify that the COMMAND PDU does not have the F-flag set.\n"); - printf("4, Verify that the COMMAND PDU sent has no immediate data.\n"); - printf("5, Verify that the DATA-OUT PDU has the F-flag set.\n"); - printf("6, Verify that the DATA-OUT PDU has one block of data.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - iscsi_url = iscsi_parse_full_url(iscsi, url); - if (iscsi_url == NULL) { - printf("Failed to parse iscsi url\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - - ret = 0; - - - /* This setting will allow us to send unsolicited data as - * immediate data but not as a data-out. - */ - printf("Login to target with IMMEDIATE_DATA=NO and INITIAL_R2T=NO ... "); - iscsi_destroy_context(iscsi); - iscsi_url->iscsi = NULL; - iscsi = iscsi_create_context(initiator); - iscsi_set_targetname(iscsi, iscsi_url->target); - iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL); - iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); - iscsi_set_immediate_data(iscsi, ISCSI_IMMEDIATE_DATA_NO); - iscsi_set_initial_r2t(iscsi, ISCSI_INITIAL_R2T_NO); - if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, lun) != 0) { - printf("[FAILED]\n"); - printf("Failed to log in to target with IMMEDIATE_DATA=NO and INITIAL_R2T=NO %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (iscsi->use_immediate_data != ISCSI_IMMEDIATE_DATA_NO) { - printf("[FAILED]\n"); - printf("Failed to negotiate IMMEDIATE_DATA==NO with target\n"); - ret = -1; - goto finished; - } - - if (iscsi->use_initial_r2t != ISCSI_INITIAL_R2T_NO) { - printf("[SKIPPED]\n"); - printf("Target does not allow INITIAL_R2T==NO. Skipping test\n"); - ret = -2; - goto finished; - } - printf("[OK]\n"); - - - - printf("Write one block as unsolicited data-out ... "); - local_iscsi_queue_pdu = my_queue_immediate_data; - task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0); - local_iscsi_queue_pdu = NULL; - /* Verify that the PDU we sent had the F-bit set and that - * datasegmentlength was one block. - */ - if (pdu_was_valid == 0) { - printf("[FAILED]\n"); - printf("PDU to send was invalid.\n"); - ret = -1; - goto finished; - } - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send write10 command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - 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 finished; - } - - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - -finished: - iscsi_destroy_url(iscsi_url); - iscsi_destroy_context(iscsi); - - return ret; -} diff --git a/test-tool/1100_persistent_reserve_in_read_keys_simple.c b/test-tool/1100_persistent_reserve_in_read_keys_simple.c deleted file mode 100644 index 86bb83b..0000000 --- a/test-tool/1100_persistent_reserve_in_read_keys_simple.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T1100_persistent_reserve_in_read_keys_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun, al; - - printf("1100_persistent_reserve_in_read_keys_simple:\n"); - printf("============================================\n"); - if (show_info) { - printf("Test basic PERSISTENT_RESERVE_IN/READ_KEYS functionality.\n"); - printf("1, Verify that READ_KEYS works.\n"), - printf("2, Verify that DATA-IN is at least 8 bytes.\n"); - printf("3, Verify that ADDITIONAL_LENGTH matches DATA-IN size.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - /* Verify that PERSISTENT_RESERVE_IN/READ_KEYS works */ - printf("Send PERSISTENT_RESERVE_IN/READ_KEYS ... "); - task = iscsi_persistent_reserve_in_sync(iscsi, lun, - SCSI_PERSISTENT_RESERVE_READ_KEYS, - 16384); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PERSISTENT_RESERVE_IN command: %s\n", iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("PERSISTENT_RESERVE_IN Not Supported\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PERSISTENT_RESERVE_IN command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - printf("[OK]\n"); - - - /* Verify that DATA-IN was at least 8 bytes */ - printf("Verify that DATA-IN is at least 8 bytes ... "); - if (task->datain.size < 8) { - printf("[FAILED]\n"); - printf("DATA-IN returned less than 8 bytes\n"); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - printf("[OK]\n"); - - - /* Verify that ADDITIONAL_LENGTH matches DATA-IN size */ - printf("Verify that ADDITIONAL_LENGTH matches DATA-IN size ... "); - al = scsi_get_uint32(&task->datain.data[4]); - if (al != task->datain.size - 8) { - printf("[FAILED]\n"); - printf("ADDITIONAL_LENGTH was %d bytes but %d was expected.\n", - al, task->datain.size - 8); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/1110_persistent_reserve_in_serviceaction_range.c b/test-tool/1110_persistent_reserve_in_serviceaction_range.c deleted file mode 100644 index 415eb69..0000000 --- a/test-tool/1110_persistent_reserve_in_serviceaction_range.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - -int T1110_persistent_reserve_in_serviceaction_range(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - struct scsi_task *task; - int ret, lun, i; - - printf("1110_persistent_reserve_in_serviceaction_range:\n"); - printf("============================================\n"); - if (show_info) { - printf("Test the range for PERSISTENT_RESERVE_IN service actions.\n"); - printf("1, Verify that PERSISTENT_RESERVE_IN works.\n"), - printf("2, Verify that SERVICE ACTIONS 0 - 3 works.\n"); - printf("3, Verify that SERVICE ACTIONS > 3 fail.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - ret = 0; - - /* Verify that PERSISTENT_RESERVE_IN works */ - printf("Verify PERSISTENT_RESERVE_IN works ... "); - task = iscsi_persistent_reserve_in_sync(iscsi, lun, - SCSI_PERSISTENT_RESERVE_READ_KEYS, - 16384); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PERSISTENT_RESERVE_IN command: %s\n", iscsi_get_error(iscsi)); - 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_OPERATION_CODE) { - printf("[SKIPPED]\n"); - printf("PERSISTENT_RESERVE_IN Not Supported\n"); - ret = -2; - scsi_free_scsi_task(task); - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PERSISTENT_RESERVE_IN command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - - - printf("Verify that SERVICE ACTIONS 0 - 3 works ... "); - for (i = 0; i < 4; i ++) { - task = iscsi_persistent_reserve_in_sync(iscsi, lun, - i, - 16384); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PERSISTENT_RESERVE_IN command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PERSISTENT_RESERVE_IN with serviceaction:%d failed with sense. %s\n", i, iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - printf("Verify that SERVICE ACTIONS > 3 fails ... "); - for (i = 4; i < 0x20; i ++) { - task = iscsi_persistent_reserve_in_sync(iscsi, lun, - i, - 16384); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send PERSISTENT_RESERVE_IN command: %s\n", iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status == SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("PERSISTENT_RESERVE_IN command successful for invalid ServiceAction: %d\n", i); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - } - printf("[OK]\n"); - - - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/1120_persistent_register_simple.c b/test-tool/1120_persistent_register_simple.c deleted file mode 100644 index 6b4b56f..0000000 --- a/test-tool/1120_persistent_register_simple.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) 2012 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - - -int T1120_persistent_register_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret, lun; - const unsigned long long key = rand_key(); - - - printf("1120_persistent_register_simple:\n"); - printf("============================================\n"); - if (show_info) { - printf("Test basic PERSISTENT_RESERVE_OUT/REGISTER functionality.\n"); - printf("1, Register with a target using REGISTER_AND_IGNORE.\n"); - printf("2, Make sure READ_KEYS sees the registration.\n"); - printf("3, Make sure we cannot REGISTER again\n"); - printf("4, Remove the registration using REGISTER\n"); - printf("5, Make sure READ_KEYS shows the registration is gone.\n"); - printf("\n"); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) { - goto finished; - } - - /* verify we can read the registration */ - ret = prin_verify_key_presence(iscsi, lun, key, 1); - if (ret != 0) { - goto finished; - } - - /* try to reregister, which should fail */ - ret = prout_reregister_key_fails(iscsi, lun, key+1); - if (ret != 0) { - goto finished; - } - - /* release from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) { - goto finished; - } - - /* Verify the registration is gone */ - /* verify we can read the registration */ - ret = prin_verify_key_presence(iscsi, lun, key, 0); - if (ret != 0) { - goto finished; - } - -finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/1130_persistent_reserve_simple.c b/test-tool/1130_persistent_reserve_simple.c deleted file mode 100644 index 8127c5d..0000000 --- a/test-tool/1130_persistent_reserve_simple.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -/* - * list of persistent reservation types to test, in order - */ -static enum scsi_persistent_out_type pr_types_to_test[] = { - SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, - SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, - SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, - SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, - SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, - SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, - 0 -}; - -int T1130_persistent_reserve_simple(const char *initiator, const char *url) -{ - struct iscsi_context *iscsi; - int ret; - int lun; - const unsigned long long key = rand_key(); - int i; - - printf("1130_persistent_reserve_simple:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that we can use each type of Persistent Reservation,\n"); - printf(" and that we can release each type, as well\n"); - printf("%d, We can register a key\n", idx++); - for (i = 0; pr_types_to_test[i] != 0; i++) { - printf("%d, Can reserve %s\n", idx++, - scsi_pr_type_str(pr_types_to_test[i])); - printf("%d, Can read reservation\n", idx++); - printf("%d, Can release reservation\n", idx++); - } - printf("%d, Can unregister\n", idx++); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - return -1; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - ret = 0; - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - - /* test each reservatoin type */ - for (i = 0; pr_types_to_test[i] != 0; i++) { - enum scsi_persistent_out_type pr_type = pr_types_to_test[i]; - - /* reserve the target */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - } - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - return ret; -} diff --git a/test-tool/1140_persistent_reserve_access_check_ea.c b/test-tool/1140_persistent_reserve_access_check_ea.c deleted file mode 100644 index 79e5738..0000000 --- a/test-tool/1140_persistent_reserve_access_check_ea.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -int T1140_persistent_reserve_access_check_ea(const char *initiator, - const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - int ret; - int lun, lun2; - const unsigned long long key = rand_key(); - const unsigned long long key2 = rand_key(); - const enum scsi_persistent_out_type pr_type = - SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS; - const char *pr_type_str = scsi_pr_type_str(pr_type); - unsigned char *buf = NULL; - - - printf("1140_persistent_reserve_access_check_ea:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that access constrols are correct for %s Persistent Reservations\n", - pr_type_str); - printf("%d, %s Reservation Holder Read Access\n", - idx++, pr_type_str); - printf("%d, %s Reservation Holder Write Access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have read access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have write access\n", - idx++, pr_type_str); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - ret = -1; - goto finished; - } - iscsi2 = iscsi_context_login(initiatorname2, url, &lun2); - if (iscsi2 == NULL) { - printf("Failed to login to target (2nd initiator)\n"); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - ret = prout_register_and_ignore(iscsi2, lun2, key2); - if (ret != 0) - goto finished; - - /* reserve the target through initiator 1 */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - buf = malloc(512); /* allocate a buffer */ - if (buf == NULL) { - printf("failed to allocate 512 byes of memory\n"); - ret = -1; - goto finished; - } - - /* make sure init1 can read */ - ret = verify_read_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init1 can write */ - ret = verify_write_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have read access */ - ret = verify_read_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* unregister init2 */ - ret = prout_register_key(iscsi2, lun2, 0, key); - if (ret != 0) { - goto finished; - } - - /* make sure init2 does not have read access */ - ret = verify_read_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - if (iscsi) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - if (iscsi2) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (buf) - free(buf); - return ret; -} diff --git a/test-tool/1141_persistent_reserve_access_check_we.c b/test-tool/1141_persistent_reserve_access_check_we.c deleted file mode 100644 index 239b8af..0000000 --- a/test-tool/1141_persistent_reserve_access_check_we.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -int T1141_persistent_reserve_access_check_we(const char *initiator, - const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - int ret; - int lun, lun2; - const unsigned long long key = rand_key(); - const unsigned long long key2 = rand_key(); - const enum scsi_persistent_out_type pr_type = - SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE; - const char *pr_type_str = scsi_pr_type_str(pr_type); - unsigned char *buf = NULL; - - - printf("1141_persistent_reserve_access_check_we:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that access constrols are correct for %s Persistent Reservations\n", - pr_type_str); - printf("%d, %s Reservation Holder Read Access\n", - idx++, pr_type_str); - printf("%d, %s Reservation Holder Write Access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have read access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have write access\n", - idx++, pr_type_str); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - ret = -1; - goto finished; - } - iscsi2 = iscsi_context_login(initiatorname2, url, &lun2); - if (iscsi2 == NULL) { - printf("Failed to login to target (2nd initiator)\n"); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - ret = prout_register_and_ignore(iscsi2, lun2, key2); - if (ret != 0) - goto finished; - - /* reserve the target through initiator 1 */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - buf = malloc(512); /* allocate a buffer */ - if (buf == NULL) { - printf("failed to allocate 512 byes of memory\n"); - ret = -1; - goto finished; - } - - /* make sure init1 can read */ - ret = verify_read_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init1 can write */ - ret = verify_write_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* unregister init2 */ - ret = prout_register_key(iscsi2, lun2, 0, key); - if (ret != 0) { - goto finished; - } - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - if (iscsi) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - if (iscsi2) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (buf) - free(buf); - return ret; -} diff --git a/test-tool/1142_persistent_reserve_access_check_earo.c b/test-tool/1142_persistent_reserve_access_check_earo.c deleted file mode 100644 index b3e8877..0000000 --- a/test-tool/1142_persistent_reserve_access_check_earo.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -int T1142_persistent_reserve_access_check_earo(const char *initiator, - const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - int ret; - int lun, lun2; - const unsigned long long key = rand_key(); - const unsigned long long key2 = rand_key(); - const enum scsi_persistent_out_type pr_type = - SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY; - const char *pr_type_str = scsi_pr_type_str(pr_type); - unsigned char *buf = NULL; - - - printf("1142_persistent_reserve_access_check_earo:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that access constrols are correct for %s Persistent Reservations\n", - pr_type_str); - printf("%d, %s Reservation Holder Read Access\n", - idx++, pr_type_str); - printf("%d, %s Reservation Holder Write Access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have read access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have write access\n", - idx++, pr_type_str); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - ret = -1; - goto finished; - } - iscsi2 = iscsi_context_login(initiatorname2, url, &lun2); - if (iscsi2 == NULL) { - printf("Failed to login to target (2nd initiator)\n"); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - ret = prout_register_and_ignore(iscsi2, lun2, key2); - if (ret != 0) - goto finished; - - /* reserve the target through initiator 1 */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - buf = malloc(512); /* allocate a buffer */ - if (buf == NULL) { - printf("failed to allocate 512 byes of memory\n"); - ret = -1; - goto finished; - } - - /* make sure init1 can read */ - ret = verify_read_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init1 can write */ - ret = verify_write_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have write access */ - ret = verify_write_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* unregister init2 */ - ret = prout_register_key(iscsi2, lun2, 0, key); - if (ret != 0) { - goto finished; - } - - /* make sure init2 does not have read access */ - ret = verify_read_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - if (iscsi) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - if (iscsi2) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (buf) - free(buf); - return ret; -} diff --git a/test-tool/1143_persistent_reserve_access_check_wero.c b/test-tool/1143_persistent_reserve_access_check_wero.c deleted file mode 100644 index faf32c6..0000000 --- a/test-tool/1143_persistent_reserve_access_check_wero.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -int T1143_persistent_reserve_access_check_wero(const char *initiator, - const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - int ret; - int lun, lun2; - const unsigned long long key = rand_key(); - const unsigned long long key2 = rand_key(); - const enum scsi_persistent_out_type pr_type = - SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY; - const char *pr_type_str = scsi_pr_type_str(pr_type); - unsigned char *buf = NULL; - - - printf("1143_persistent_reserve_access_check_wero:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that access constrols are correct for %s Persistent Reservations\n", - pr_type_str); - printf("%d, %s Reservation Holder Read Access\n", - idx++, pr_type_str); - printf("%d, %s Reservation Holder Write Access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have read access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have write access\n", - idx++, pr_type_str); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - ret = -1; - goto finished; - } - iscsi2 = iscsi_context_login(initiatorname2, url, &lun2); - if (iscsi2 == NULL) { - printf("Failed to login to target (2nd initiator)\n"); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - ret = prout_register_and_ignore(iscsi2, lun2, key2); - if (ret != 0) - goto finished; - - /* reserve the target through initiator 1 */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - buf = malloc(512); /* allocate a buffer */ - if (buf == NULL) { - printf("failed to allocate 512 byes of memory\n"); - ret = -1; - goto finished; - } - - /* make sure init1 can read */ - ret = verify_read_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init1 can write */ - ret = verify_write_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have write access */ - ret = verify_write_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* unregister init2 */ - ret = prout_register_key(iscsi2, lun2, 0, key); - if (ret != 0) { - goto finished; - } - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - if (iscsi) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - if (iscsi2) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (buf) - free(buf); - return ret; -} diff --git a/test-tool/1144_persistent_reserve_access_check_eaar.c b/test-tool/1144_persistent_reserve_access_check_eaar.c deleted file mode 100644 index fdf955a..0000000 --- a/test-tool/1144_persistent_reserve_access_check_eaar.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -int T1144_persistent_reserve_access_check_eaar(const char *initiator, - const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - int ret; - int lun, lun2; - const unsigned long long key = rand_key(); - const unsigned long long key2 = rand_key(); - const enum scsi_persistent_out_type pr_type = - SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS; - const char *pr_type_str = scsi_pr_type_str(pr_type); - unsigned char *buf = NULL; - - - printf("1144_persistent_reserve_access_check_eaar:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that access constrols are correct for %s Persistent Reservations\n", - pr_type_str); - printf("%d, %s Reservation Holder Read Access\n", - idx++, pr_type_str); - printf("%d, %s Reservation Holder Write Access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have read access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have write access\n", - idx++, pr_type_str); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - ret = -1; - goto finished; - } - iscsi2 = iscsi_context_login(initiatorname2, url, &lun2); - if (iscsi2 == NULL) { - printf("Failed to login to target (2nd initiator)\n"); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - ret = prout_register_and_ignore(iscsi2, lun2, key2); - if (ret != 0) - goto finished; - - /* reserve the target through initiator 1 */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - buf = malloc(512); /* allocate a buffer */ - if (buf == NULL) { - printf("failed to allocate 512 byes of memory\n"); - ret = -1; - goto finished; - } - - /* make sure init1 can read */ - ret = verify_read_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init1 can write */ - ret = verify_write_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have write access */ - ret = verify_write_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* unregister init2 */ - ret = prout_register_key(iscsi2, lun2, 0, key); - if (ret != 0) { - goto finished; - } - - /* make sure init2 does not have read access */ - ret = verify_read_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - if (iscsi) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - if (iscsi2) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (buf) - free(buf); - return ret; -} diff --git a/test-tool/1145_persistent_reserve_access_check_wear.c b/test-tool/1145_persistent_reserve_access_check_wear.c deleted file mode 100644 index 002d2cd..0000000 --- a/test-tool/1145_persistent_reserve_access_check_wear.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013 by Lee Duncan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-test.h" - - -int T1145_persistent_reserve_access_check_wear(const char *initiator, - const char *url) -{ - struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; - int ret; - int lun, lun2; - const unsigned long long key = rand_key(); - const unsigned long long key2 = rand_key(); - const enum scsi_persistent_out_type pr_type = - SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS; - const char *pr_type_str = scsi_pr_type_str(pr_type); - unsigned char *buf = NULL; - - - printf("1145_persistent_reserve_access_check_wear:\n"); - printf("=========================================\n"); - if (show_info) { - int idx = 1; - - printf("Test that access constrols are correct for %s Persistent Reservations\n", - pr_type_str); - printf("%d, %s Reservation Holder Read Access\n", - idx++, pr_type_str); - printf("%d, %s Reservation Holder Write Access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have read access\n", - idx++, pr_type_str); - printf("%d, non-%s Reservation Holder does not have write access\n", - idx++, pr_type_str); - return 0; - } - - iscsi = iscsi_context_login(initiator, url, &lun); - if (iscsi == NULL) { - printf("Failed to login to target\n"); - ret = -1; - goto finished; - } - iscsi2 = iscsi_context_login(initiatorname2, url, &lun2); - if (iscsi2 == NULL) { - printf("Failed to login to target (2nd initiator)\n"); - ret = -1; - goto finished; - } - - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; - } - - /* register our reservation key with the target */ - ret = prout_register_and_ignore(iscsi, lun, key); - if (ret != 0) - goto finished; - ret = prout_register_and_ignore(iscsi2, lun2, key2); - if (ret != 0) - goto finished; - - /* reserve the target through initiator 1 */ - ret = prout_reserve(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* verify target reservation */ - ret = prin_verify_reserved_as(iscsi, lun, - pr_type_is_all_registrants(pr_type) ? 0 : key, - pr_type); - if (ret != 0) - goto finished; - - buf = malloc(512); /* allocate a buffer */ - if (buf == NULL) { - printf("failed to allocate 512 byes of memory\n"); - ret = -1; - goto finished; - } - - /* make sure init1 can read */ - ret = verify_read_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init1 can write */ - ret = verify_write_works(iscsi, lun, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does have write access */ - ret = verify_write_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* unregister init2 */ - ret = prout_register_key(iscsi2, lun2, 0, key); - if (ret != 0) { - goto finished; - } - - /* make sure init2 does have read access */ - ret = verify_read_works(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* make sure init2 does not have write access */ - ret = verify_write_fails(iscsi2, lun2, buf); - if (ret != 0) - goto finished; - - /* release our reservation */ - ret = prout_release(iscsi, lun, key, pr_type); - if (ret != 0) - goto finished; - - /* remove our key from the target */ - ret = prout_register_key(iscsi, lun, 0, key); - if (ret != 0) - goto finished; - -finished: - /* XXX should we clean up key if needed? */ - if (iscsi) { - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - } - if (iscsi2) { - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); - } - if (buf) - free(buf); - return ret; -} diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am index 9cfbd3c..0f21ba6 100644 --- a/test-tool/Makefile.am +++ b/test-tool/Makefile.am @@ -6,7 +6,6 @@ LDADD = ../lib/libiscsi.la EXTRA_DIST = README dist_noinst_HEADERS = iscsi-support.h \ - iscsi-test.h \ iscsi-test-cu.h # libiscsi test tool using cunit @@ -194,112 +193,3 @@ endif -# old deprecated libiscsi test tool -noinst_PROGRAMS = iscsi-test -iscsi_test_LDFLAGS = -ldl -iscsi_test_SOURCES = iscsi-test.c \ - iscsi-support.c \ - 0000_testunitready_simple.c \ - 0100_read10_simple.c 0101_read10_beyond_eol.c \ - 0102_read10_0blocks.c 0103_read10_rdprotect.c \ - 0104_read10_flags.c 0105_read10_invalid.c \ - 0110_readcapacity10_simple.c \ - 0120_read6_simple.c \ - 0121_read6_beyond_eol.c 0122_read6_invalid.c \ - 0130_verify10_simple.c 0131_verify10_mismatch.c \ - 0132_verify10_mismatch_no_cmp.c 0133_verify10_beyondeol.c \ - 0160_readcapacity16_simple.c \ - 0161_readcapacity16_alloclen.c \ - 0170_unmap_simple.c 0171_unmap_zero.c \ - 0180_writesame10_unmap.c 0181_writesame10_unmap_unaligned.c \ - 0182_writesame10_beyondeol.c \ - 0183_writesame10_wrprotect.c \ - 0184_writesame10_0blocks.c \ - 0190_writesame16_unmap.c 0191_writesame16_unmap_unaligned.c \ - 0192_writesame16_beyondeol.c \ - 0193_writesame16_wrprotect.c \ - 0194_writesame16_0blocks.c \ - 0200_read16_simple.c 0201_read16_rdprotect.c \ - 0202_read16_flags.c 0203_read16_0blocks.c \ - 0204_read16_beyondeol.c \ - 0210_read12_simple.c 0211_read12_rdprotect.c \ - 0212_read12_flags.c 0213_read12_0blocks.c \ - 0214_read12_beyondeol.c \ - 0220_write16_simple.c 0221_write16_wrprotect.c \ - 0222_write16_flags.c 0223_write16_0blocks.c \ - 0224_write16_beyondeol.c \ - 0230_write12_simple.c 0231_write12_wrprotect.c \ - 0232_write12_flags.c 0233_write12_0blocks.c \ - 0234_write12_beyondeol.c \ - 0240_prefetch10_simple.c \ - 0241_prefetch10_flags.c \ - 0242_prefetch10_beyondeol.c \ - 0243_prefetch10_0blocks.c \ - 0250_prefetch16_simple.c \ - 0251_prefetch16_flags.c \ - 0252_prefetch16_beyondeol.c \ - 0253_prefetch16_0blocks.c \ - 0260_get_lba_status_simple.c 0264_get_lba_status_beyondeol.c \ - 0270_verify16_simple.c 0271_verify16_mismatch.c \ - 0272_verify16_mismatch_no_cmp.c 0273_verify16_beyondeol.c \ - 0280_verify12_simple.c 0281_verify12_mismatch.c \ - 0282_verify12_mismatch_no_cmp.c 0283_verify12_beyondeol.c \ - 0290_write10_simple.c 0291_write10_wrprotect.c \ - 0292_write10_flags.c 0293_write10_0blocks.c \ - 0294_write10_beyondeol.c \ - 0300_readonly.c \ - 0310_writeverify10_simple.c 0311_writeverify10_wrprotect.c \ - 0314_writeverify10_beyondeol.c \ - 0320_writeverify12_simple.c 0321_writeverify12_wrprotect.c \ - 0324_writeverify12_beyondeol.c \ - 0330_writeverify16_simple.c 0331_writeverify16_wrprotect.c \ - 0334_writeverify16_beyondeol.c \ - 0340_compareandwrite_simple.c 0341_compareandwrite_mismatch.c \ - 0343_compareandwrite_beyondeol.c \ - 0350_orwrite_simple.c \ - 0351_orwrite_wrprotect.c \ - 0354_orwrite_beyondeol.c \ - 0360_startstopunit_simple.c \ - 0361_startstopunit_pwrcnd.c \ - 0362_startstopunit_noloej.c \ - 0370_nomedia.c \ - 0380_preventallow_simple.c \ - 0381_preventallow_eject.c \ - 0382_preventallow_itnexus_loss.c \ - 0383_preventallow_target_warm_reset.c \ - 0384_preventallow_target_cold_reset.c \ - 0385_preventallow_lun_reset.c \ - 0386_preventallow_2_it_nexuses.c \ - 0390_mandatory_opcodes_sbc.c \ - 0400_inquiry_basic.c \ - 0401_inquiry_alloclen.c \ - 0402_inquiry_evpd.c \ - 0403_inquiry_supported_vpd.c \ - 0404_inquiry_all_reported_vpd.c \ - 0410_readtoc_basic.c \ - 0420_reserve6_simple.c \ - 0421_reserve6_lun_reset.c \ - 0422_reserve6_logout.c \ - 0423_reserve6_sessionloss.c \ - 0424_reserve6_target_reset.c \ - 0430_report_all_supported_ops.c \ - \ - 1000_cmdsn_invalid.c \ - 1010_datasn_invalid.c \ - 1020_bufferoffset_invalid.c \ - 1030_unsolicited_data_overflow.c \ - 1031_unsolicited_data_out.c \ - 1040_saturate_maxcmdsn.c \ - 1041_unsolicited_immediate_data.c \ - 1042_unsolicited_nonimmediate_data.c \ - 1100_persistent_reserve_in_read_keys_simple.c \ - 1110_persistent_reserve_in_serviceaction_range.c \ - 1120_persistent_register_simple.c \ - 1130_persistent_reserve_simple.c \ - 1140_persistent_reserve_access_check_ea.c \ - 1141_persistent_reserve_access_check_we.c \ - 1142_persistent_reserve_access_check_earo.c \ - 1143_persistent_reserve_access_check_wero.c \ - 1144_persistent_reserve_access_check_eaar.c \ - 1145_persistent_reserve_access_check_wear.c - diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c deleted file mode 100644 index 9ec1d77..0000000 --- a/test-tool/iscsi-test.c +++ /dev/null @@ -1,553 +0,0 @@ -/* - iscsi-test tool - - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "slist.h" -#include "iscsi.h" -#include "scsi-lowlevel.h" -#include "iscsi-private.h" -#include "iscsi-test.h" -#include "iscsi-support.h" - -#ifndef discard_const -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) -#endif - -int loglevel = LOG_VERBOSE; - -int (*real_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu); - - -int show_info; - -struct scsi_test { - const char *name; - int (*test)(const char *initiator, const char *url); -}; - -static struct scsi_test tests[] = { -/* SCSI protocol tests */ - -/* testunitready*/ -{ "T0000_testunitready_simple", T0000_testunitready_simple }, - -/* read10*/ -{ "T0100_read10_simple", T0100_read10_simple }, -{ "T0101_read10_beyond_eol", T0101_read10_beyond_eol }, -{ "T0102_read10_0blocks", T0102_read10_0blocks }, -{ "T0103_read10_rdprotect", T0103_read10_rdprotect }, -{ "T0104_read10_flags", T0104_read10_flags }, -{ "T0105_read10_invalid", T0105_read10_invalid }, - -/* readcapacity10*/ -{ "T0110_readcapacity10_simple", T0110_readcapacity10_simple }, - -/* read6*/ -{ "T0120_read6_simple", T0120_read6_simple }, -{ "T0121_read6_beyond_eol", T0121_read6_beyond_eol }, -{ "T0122_read6_invalid", T0122_read6_invalid }, - -/* verify10*/ -{ "T0130_verify10_simple", T0130_verify10_simple }, -{ "T0131_verify10_mismatch", T0131_verify10_mismatch }, -{ "T0132_verify10_mismatch_no_cmp", T0132_verify10_mismatch_no_cmp }, -{ "T0133_verify10_beyondeol", T0133_verify10_beyondeol }, - -/* readcapacity16*/ -{ "T0160_readcapacity16_simple", T0160_readcapacity16_simple }, -{ "T0161_readcapacity16_alloclen", T0161_readcapacity16_alloclen }, - -/* unmap*/ -{ "T0170_unmap_simple", T0170_unmap_simple }, -{ "T0171_unmap_zero", T0171_unmap_zero }, - -/* writesame10*/ -{ "T0180_writesame10_unmap", T0180_writesame10_unmap }, -{ "T0181_writesame10_unmap_unaligned", T0181_writesame10_unmap_unaligned }, -{ "T0182_writesame10_beyondeol", T0182_writesame10_beyondeol }, -{ "T0183_writesame10_wrprotect", T0183_writesame10_wrprotect }, -{ "T0184_writesame10_0blocks", T0184_writesame10_0blocks }, - -/* writesame16*/ -{ "T0190_writesame16_unmap", T0190_writesame16_unmap }, -{ "T0191_writesame16_unmap_unaligned", T0191_writesame16_unmap_unaligned }, -{ "T0192_writesame16_beyondeol", T0192_writesame16_beyondeol }, -{ "T0193_writesame16_wrprotect", T0193_writesame16_wrprotect }, -{ "T0194_writesame16_0blocks", T0194_writesame16_0blocks }, - -/* read16*/ -{ "T0200_read16_simple", T0200_read16_simple }, -{ "T0201_read16_rdprotect", T0201_read16_rdprotect }, -{ "T0202_read16_flags", T0202_read16_flags }, -{ "T0203_read16_0blocks", T0203_read16_0blocks }, -{ "T0204_read16_beyondeol", T0204_read16_beyondeol }, - -/* read12*/ -{ "T0210_read12_simple", T0210_read12_simple }, -{ "T0211_read12_rdprotect", T0211_read12_rdprotect }, -{ "T0212_read12_flags", T0212_read12_flags }, -{ "T0213_read12_0blocks", T0213_read12_0blocks }, -{ "T0214_read12_beyondeol", T0214_read12_beyondeol }, - -/* write16*/ -{ "T0220_write16_simple", T0220_write16_simple }, -{ "T0221_write16_wrprotect", T0221_write16_wrprotect }, -{ "T0222_write16_flags", T0222_write16_flags }, -{ "T0223_write16_0blocks", T0223_write16_0blocks }, -{ "T0224_write16_beyondeol", T0224_write16_beyondeol }, - -/* write12*/ -{ "T0230_write12_simple", T0230_write12_simple }, -{ "T0231_write12_wrprotect", T0231_write12_wrprotect }, -{ "T0232_write12_flags", T0232_write12_flags }, -{ "T0233_write12_0blocks", T0233_write12_0blocks }, -{ "T0234_write12_beyondeol", T0234_write12_beyondeol }, - -/* prefetch10*/ -{ "T0240_prefetch10_simple", T0240_prefetch10_simple }, -{ "T0241_prefetch10_flags", T0241_prefetch10_flags }, -{ "T0242_prefetch10_beyondeol", T0242_prefetch10_beyondeol }, -{ "T0243_prefetch10_0blocks", T0243_prefetch10_0blocks }, - -/* prefetch16*/ -{ "T0250_prefetch16_simple", T0250_prefetch16_simple }, -{ "T0251_prefetch16_flags", T0251_prefetch16_flags }, -{ "T0252_prefetch16_beyondeol", T0252_prefetch16_beyondeol }, -{ "T0253_prefetch16_0blocks", T0253_prefetch16_0blocks }, - -/* get_lba_status */ -{ "T0260_get_lba_status_simple", T0260_get_lba_status_simple }, -{ "T0264_get_lba_status_beyondeol", T0264_get_lba_status_beyondeol }, - -/* verify16*/ -{ "T0270_verify16_simple", T0270_verify16_simple }, -{ "T0271_verify16_mismatch", T0271_verify16_mismatch }, -{ "T0272_verify16_mismatch_no_cmp", T0272_verify16_mismatch_no_cmp }, -{ "T0273_verify16_beyondeol", T0273_verify16_beyondeol }, - -/* verify12*/ -{ "T0280_verify12_simple", T0280_verify12_simple }, -{ "T0281_verify12_mismatch", T0281_verify12_mismatch }, -{ "T0282_verify12_mismatch_no_cmp", T0282_verify12_mismatch_no_cmp }, -{ "T0283_verify12_beyondeol", T0283_verify12_beyondeol }, - -/* write10*/ -{ "T0290_write10_simple", T0290_write10_simple }, -{ "T0291_write10_wrprotect", T0291_write10_wrprotect }, -{ "T0292_write10_flags", T0292_write10_flags }, -{ "T0293_write10_0blocks", T0293_write10_0blocks }, -{ "T0294_write10_beyondeol", T0294_write10_beyondeol }, - -/* Readonly */ -{ "T0300_readonly", T0300_readonly }, - -/* writeverify10*/ -{ "T0310_writeverify10_simple", T0310_writeverify10_simple }, -{ "T0311_writeverify10_wrprotect", T0311_writeverify10_wrprotect }, -{ "T0314_writeverify10_beyondeol", T0314_writeverify10_beyondeol }, - -/* writeverify12*/ -{ "T0320_writeverify12_simple", T0320_writeverify12_simple }, -{ "T0321_writeverify12_wrprotect", T0321_writeverify12_wrprotect }, -{ "T0324_writeverify12_beyondeol", T0324_writeverify12_beyondeol }, - -/* writeverify16*/ -{ "T0330_writeverify16_simple", T0330_writeverify16_simple }, -{ "T0331_writeverify16_wrprotect", T0331_writeverify16_wrprotect }, -{ "T0334_writeverify16_beyondeol", T0334_writeverify16_beyondeol }, - -/* compareandwrite*/ -{ "T0340_compareandwrite_simple", T0340_compareandwrite_simple }, -{ "T0341_compareandwrite_mismatch", T0341_compareandwrite_mismatch }, -{ "T0343_compareandwrite_beyondeol", T0343_compareandwrite_beyondeol }, - -/* orwrite*/ -{ "T0350_orwrite_simple", T0350_orwrite_simple }, -{ "T0351_orwrite_wrprotect", T0351_orwrite_wrprotect }, -{ "T0354_orwrite_beyindeol", T0354_orwrite_beyondeol }, - -/* startstopunit*/ -{ "T0360_startstopunit_simple", T0360_startstopunit_simple }, -{ "T0361_startstopunit_pwrcnd", T0361_startstopunit_pwrcnd }, -{ "T0362_startstopunit_noloej", T0362_startstopunit_noloej }, - -/* nomedia*/ -{ "T0370_nomedia", T0370_nomedia }, - -/* preventallowmediumremoval*/ -{ "T0380_preventallow_simple", T0380_preventallow_simple }, -{ "T0381_preventallow_eject", T0381_preventallow_eject }, -{ "T0382_preventallow_itnexus_loss", T0382_preventallow_itnexus_loss }, -{ "T0383_preventallow_target_warm_reset", T0383_preventallow_target_warm_reset }, -{ "T0384_preventallow_target_cold_reset", T0384_preventallow_target_cold_reset }, -{ "T0385_preventallow_lun_reset", T0385_preventallow_lun_reset }, -{ "T0386_preventallow_2_itl_nexuses", T0386_preventallow_2_itl_nexuses }, - -/* support for mandatory opcodes*/ -{ "T0390_mandatory_opcodes_sbc", T0390_mandatory_opcodes_sbc }, - -/* inquiry*/ -{ "T0400_inquiry_basic", T0400_inquiry_basic }, -{ "T0401_inquiry_alloclen", T0401_inquiry_alloclen }, -{ "T0402_inquiry_evpd", T0402_inquiry_evpd }, -{ "T0403_inquiry_supported_vpd", T0403_inquiry_supported_vpd }, -{ "T0404_inquiry_all_reported_vpd", T0404_inquiry_all_reported_vpd }, - -/* read TOC/PMA/ATIP */ -{ "T0410_readtoc_basic", T0410_readtoc_basic }, - -/* reserve6/release6 */ -{ "T0420_reserve6_simple", T0420_reserve6_simple }, -{ "T0421_reserve6_lun_reset", T0421_reserve6_lun_reset }, -{ "T0422_reserve6_logout", T0422_reserve6_logout }, -{ "T0423_reserve6_sessionloss", T0423_reserve6_sessionloss }, -{ "T0424_reserve6_target_reset", T0424_reserve6_target_reset }, - -/* Maintenance In - Report Supported Operations */ -{ "T0430_report_all_supported_ops", T0430_report_all_supported_ops }, - -/* iSCSI protocol tests */ - -/* invalid cmdsn from initiator */ -{ "T1000_cmdsn_invalid", T1000_cmdsn_invalid }, - -/* invalid datasn from initiator */ -{ "T1010_datasn_invalid", T1010_datasn_invalid }, - -/* invalid bufferoffset from initiator */ -{ "T1020_bufferoffset_invalid", T1020_bufferoffset_invalid }, - -/* sending too much unsolicited data */ -{ "T1030_unsolicited_data_overflow", T1030_unsolicited_data_overflow }, -{ "T1031_unsolicited_data_out", T1031_unsolicited_data_out }, - -/* Test that if we start blocking new I/O due to saturating maxcmdsn - that we eventualld do recover and finish -*/ -{ "T1040_saturate_maxcmdsn", T1040_saturate_maxcmdsn }, - -{ "T1041_unsolicited_immediate_data", T1041_unsolicited_immediate_data }, -{ "T1042_unsolicited_nonimmediate_data",T1042_unsolicited_nonimmediate_data }, - -/* PERSISTENT_RESERVE_IN/PERSISTENT_RESERVE_OUT */ -{ "T1100_persistent_reserve_in_read_keys_simple", T1100_persistent_reserve_in_read_keys_simple }, -{ "T1110_persistent_reserve_in_serviceaction_range", T1110_persistent_reserve_in_serviceaction_range }, -{ "T1120_persistent_register_simple", T1120_persistent_register_simple }, -{ "T1130_persistent_reserve_simple", T1130_persistent_reserve_simple }, -{ "T1140_persistent_reserve_access_check_ea", T1140_persistent_reserve_access_check_ea }, -{ "T1141_persistent_reserve_access_check_we", T1141_persistent_reserve_access_check_we }, -{ "T1142_persistent_reserve_access_check_earo", T1142_persistent_reserve_access_check_earo }, -{ "T1143_persistent_reserve_access_check_wero", T1143_persistent_reserve_access_check_wero }, -{ "T1144_persistent_reserve_access_check_eaar", T1144_persistent_reserve_access_check_eaar }, -{ "T1145_persistent_reserve_access_check_wear", T1145_persistent_reserve_access_check_wear }, - -{ NULL, NULL } -}; - - -static void print_usage(void) -{ - fprintf(stderr, "Usage: iscsi-test [-?] [-?|--help] [--usage] [-t|--test=] [-s|--skip=]\n" - "\t\t[-l|--list] [--info] [-i|--initiator-name=]\n" - "\t\t\n"); -} - -static void print_help(void) -{ - fprintf(stderr, "Usage: iscsi-test [OPTION...] \n"); - fprintf(stderr, " -i, --initiator-name=iqn-name Initiatorname to use\n"); - fprintf(stderr, " -I, --initiator-name-2=iqn-name Second initiatorname to use\n"); - fprintf(stderr, " -t, --test=test-name Which test to run. Default is to run all tests.\n"); - fprintf(stderr, " -s, --skip=test-name Which test to skip. Default is to run all tests.\n"); - fprintf(stderr, " -l, --list List all tests.\n"); - fprintf(stderr, " --info, Print extra info about a test.\n"); - fprintf(stderr, " --dataloss Allow destructive tests.\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Help options:\n"); - fprintf(stderr, " -?, --help Show this help message\n"); - fprintf(stderr, " --usage Display brief usage message\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "iSCSI URL format : %s\n", ISCSI_URL_SYNTAX); - fprintf(stderr, "\n"); - fprintf(stderr, " is either of:\n"); - fprintf(stderr, " \"hostname\" iscsi.example\n"); - fprintf(stderr, " \"ipv4-address\" 10.1.1.27\n"); - fprintf(stderr, " \"ipv6-address\" [fce0::1]\n"); -} - - -int main(int argc, char *argv[]) -{ - const char *url = NULL; - int show_help = 0, show_usage = 0, list_tests = 0; - int res, num_failed, num_skipped; - struct scsi_test *test; - char *testname = NULL; - char *skipname = NULL; - int lun; - struct iscsi_context *iscsi; - struct scsi_task *task; - struct scsi_task *inq_task; - struct scsi_task *inq_bl_task; - struct scsi_task *rc16_task; - struct scsi_readcapacity10 *rc10; - int full_size; - int c; - - static struct option long_options[] = { - {"help", no_argument, NULL, 'h'}, - {"usage", no_argument, NULL, 'u'}, - {"dataloss", no_argument, NULL, 'D'}, - {"info", no_argument, NULL, 'X'}, - {"list", no_argument, NULL, 'l'}, - {"test", required_argument, NULL, 't'}, - {"skip", required_argument, NULL, 's'}, - {"initiator-name", required_argument, NULL, 'i'}, - {"initiator-name-2", required_argument, NULL, 'I'}, - {0, 0, 0, 0} - }; - int option_index; - - while ((c = getopt_long(argc, argv, "h?ui:I:ls:t:", long_options, - &option_index)) != -1) { - switch (c) { - case 'h': - case '?': - show_help = 1; - break; - case 'u': - show_usage = 1; - break; - case 'l': - list_tests = 1; - break; - case 'D': - data_loss = 1; - break; - case 'X': - show_info = 1; - break; - case 's': - skipname = optarg; - break; - case 't': - testname = optarg; - break; - case 'i': - initiatorname1 = optarg; - break; - case 'I': - initiatorname2 = optarg; - break; - default: - fprintf(stderr, "Unrecognized option '%c'\n\n", c); - print_help(); - exit(0); - } - } - - - real_iscsi_queue_pdu = dlsym(RTLD_NEXT, "iscsi_queue_pdu"); - - - if (show_help != 0) { - print_help(); - exit(0); - } - - if (show_usage != 0) { - print_usage(); - exit(0); - } - - if (list_tests != 0) { - for (test = &tests[0]; test->name; test++) { - printf("%s\n", test->name); - if (show_info) { - test->test(initiatorname1, url); - } - } - exit(0); - } - - if (argv[optind] != NULL) { - url = strdup(argv[optind]); - } - if (url == NULL) { - fprintf(stderr, "You must specify the URL\n"); - print_usage(); - 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 - 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)); - 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); - - rc16_task = iscsi_readcapacity16_sync(iscsi, lun); - if (rc16_task == NULL) { - printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - iscsi_destroy_context(iscsi); - return -1; - } - if (rc16_task->status == SCSI_STATUS_GOOD) { - rc16 = scsi_datain_unmarshall(rc16_task); - if (rc16 == NULL) { - printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(rc16_task); - iscsi_destroy_context(iscsi); - return -1; - } - block_size = rc16->block_length; - num_blocks = rc16->returned_lba; - lbppb = 1 << rc16->lbppbe; - } - - - inq_task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - full_size = scsi_datain_getfullsize(inq_task); - if (full_size > inq_task->datain.size) { - scsi_free_scsi_task(inq_task); - - /* we need more data for the full list */ - if ((inq_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(inq_task); - if (inq == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(inq_task); - return -1; - } - - /* try reading block limits vpd */ - inq_bl_task = iscsi_inquiry_sync(iscsi, lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 64); - if (inq_bl_task && inq_bl_task->status != SCSI_STATUS_GOOD) { - scsi_free_scsi_task(inq_bl_task); - inq_bl_task = NULL; - } - if (inq_bl_task) { - full_size = scsi_datain_getfullsize(inq_bl_task); - if (full_size > inq_bl_task->datain.size) { - scsi_free_scsi_task(inq_bl_task); - - if ((inq_bl_task = iscsi_inquiry_sync(iscsi, lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, full_size)) == NULL) { - printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); - return -1; - } - } - - inq_bl = scsi_datain_unmarshall(inq_bl_task); - if (inq_bl == NULL) { - printf("failed to unmarshall inquiry datain blob\n"); - return -1; - } - } - - - num_failed = num_skipped = 0; - for (test = &tests[0]; test->name; test++) { - if (testname != NULL && fnmatch(testname, test->name, 0)) { - continue; - } - - if (skipname != NULL) { - char * pchr = skipname; - char * pchr2 = NULL; - int skip = 0; - do { - pchr2 = strchr(pchr,','); - if (pchr2) pchr2[0]=0x00; - if (!fnmatch(pchr, test->name, 0)) { - skip = 1; - } - if (pchr2) {pchr2[0]=',';pchr=pchr2+1;} - } while (pchr2); - if (skip) continue; - } - - res = test->test(initiatorname1, url); - if (res == 0) { - printf("TEST %s [OK]\n", test->name); - } else if (res == -2) { - printf("TEST %s [SKIPPED]\n", test->name); - num_skipped++; - } else { - printf("TEST %s [FAILED]\n", test->name); - num_failed++; - } - printf("\n"); - } - - scsi_free_scsi_task(inq_task); - scsi_free_scsi_task(rc16_task); - scsi_free_scsi_task(inq_bl_task); - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - - free(discard_const(url)); - - return num_failed ? num_failed : num_skipped ? 77 : 0; -} diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h deleted file mode 100644 index 71c19f4..0000000 --- a/test-tool/iscsi-test.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - iscsi-test tool - - Copyright (C) 2010 by Ronnie Sahlberg - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#ifndef _ISCSI_TEST_H_ -#define _ISCSI_TEST_H_ - -#include -#include -#include -#include - -#include "iscsi-support.h" - -extern int show_info; - -int T0000_testunitready_simple(const char *initiator, const char *url); - -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 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 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 T0161_readcapacity16_alloclen(const char *initiator, const char *url); - -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 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 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 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 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 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 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 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 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 T0264_get_lba_status_beyondeol(const char *initiator, const char *url); - -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 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 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 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 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 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 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 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 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 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 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 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 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 T1140_persistent_reserve_access_check_ea(const char *initiator, const char *url); -int T1141_persistent_reserve_access_check_we(const char *initiator, const char *url); -int T1142_persistent_reserve_access_check_earo(const char *initiator, const char *url); -int T1143_persistent_reserve_access_check_wero(const char *initiator, const char *url); -int T1144_persistent_reserve_access_check_eaar(const char *initiator, const char *url); -int T1145_persistent_reserve_access_check_wear(const char *initiator, const char *url); - -#endif /* _ISCSI_TEST_H_ */