TESTS: Change all tests to use 'block_size' instead of hardcoded 512

This should allow the testst to work corectly on block devices with 4k blocksize too.
This commit is contained in:
Ronnie Sahlberg
2012-09-03 08:58:56 -07:00
parent 5639b92d95
commit 77fc2497f7
46 changed files with 197 additions and 95 deletions

View File

@@ -28,6 +28,8 @@ int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss
struct scsi_task *task;
int full_size;
struct scsi_inquiry_standard *inq;
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
int ret, i, lun;
printf("0103_read10_rdprotect:\n");
@@ -83,6 +85,29 @@ int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss
scsi_free_scsi_task(task);
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;
@@ -104,7 +129,7 @@ int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss
task->cdb[8] = 1;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");

View File

@@ -27,6 +27,8 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
int ret, lun;
printf("0104_read10_flags:\n");
@@ -48,9 +50,6 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
return -1;
}
ret = 0;
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
@@ -69,6 +68,33 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
return -2;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;
/* Try out DPO : 1 */
printf("Read10 with DPO==1 ... ");
@@ -85,7 +111,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
task->cdb[8] = 1;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");
@@ -122,7 +148,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
task->cdb[8] = 1;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");
@@ -158,7 +184,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
task->cdb[8] = 1;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");
@@ -194,7 +220,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
task->cdb[8] = 1;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");
@@ -230,7 +256,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
task->cdb[8] = 1;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");

View File

@@ -28,18 +28,20 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _
struct iscsi_context *iscsi;
struct scsi_task *task;
struct iscsi_data data;
char buf[512];
char buf[4096];
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
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 512 bytes.\n");
printf("2, Read 1 block but set xferlength to 1024. Should result in residual underflow of 512 bytes.\n");
printf("3, Read 1 block but set xferlength to 200. Should result in residual overflow of 312 bytes.\n");
printf("4, Read 2 blocks but set xferlength to 512. Should result in residual overflow of 512 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 512 bytes.\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;
}
@@ -50,6 +52,29 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;
@@ -95,7 +120,7 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _
scsi_free_scsi_task(task);
goto test2;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != 512) {
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) {
printf("[FAILED]\n");
printf("Read10 returned incorrect residual overflow.\n");
ret = -1;
@@ -141,7 +166,7 @@ test2:
scsi_free_scsi_task(task);
goto test3;
}
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != 512) {
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != block_size) {
printf("[FAILED]\n");
printf("Read10 returned incorrect residual underflow.\n");
ret = -1;
@@ -184,7 +209,7 @@ test3:
scsi_free_scsi_task(task);
goto test4;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != 312) {
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size - 200) {
printf("[FAILED]\n");
printf("Read10 returned incorrect residual overflow.\n");
ret = -1;
@@ -195,8 +220,8 @@ test3:
printf("[OK]\n");
test4:
/* Try a read of 2 blocks but xferlength == 512 */
printf("Read10 2 blocks but with iscsi ExpectedDataTransferLength==512 ... ");
/* Try a read of 2 blocks but xferlength == 'block_size' */
printf("Read10 2 blocks but with iscsi ExpectedDataTransferLength==%d ... ", block_size);
task = malloc(sizeof(struct scsi_task));
if (task == NULL) {
@@ -210,7 +235,7 @@ test4:
task->cdb[8] = 2;
task->cdb_size = 10;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");
@@ -221,12 +246,12 @@ test4:
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read10 of 2 blocks with iscsi ExpectedDataTransferLength==512 should succeed.\n");
printf("Read10 of 2 blocks with iscsi ExpectedDataTransferLength==%d should succeed.\n", block_size);
ret = -1;
scsi_free_scsi_task(task);
goto test5;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != 512) {
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) {
printf("[FAILED]\n");
printf("Read10 returned incorrect residual overflow.\n");
ret = -1;

View File

@@ -27,18 +27,20 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U
struct iscsi_context *iscsi;
struct scsi_task *task;
struct iscsi_data data;
char buf[512];
char buf[4096];
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
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 512 bytes.\n");
printf("2, Read 1 block but set xferlength to 1024. Should result in residual underflow of 512 bytes.\n");
printf("3, Read 1 block but set xferlength to 200. Should result in residual overflow of 312 bytes.\n");
printf("4, Read 2 blocks but set xferlength to 512. Should result in residual overflow of 512 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 512 bytes.\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;
}
@@ -49,6 +51,29 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;
@@ -93,7 +118,7 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U
scsi_free_scsi_task(task);
goto test2;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != 512) {
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) {
printf("[FAILED]\n");
printf("Read6 returned incorrect residual overflow.\n");
ret = -1;
@@ -139,7 +164,7 @@ test2:
scsi_free_scsi_task(task);
goto test3;
}
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != 512) {
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != block_size) {
printf("[FAILED]\n");
printf("Read6 returned incorrect residual underflow.\n");
ret = -1;
@@ -182,7 +207,7 @@ test3:
scsi_free_scsi_task(task);
goto test4;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != 312) {
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size - 200) {
printf("[FAILED]\n");
printf("Read6 returned incorrect residual overflow.\n");
ret = -1;
@@ -193,8 +218,8 @@ test3:
printf("[OK]\n");
test4:
/* Try a read of 2 blocks but xferlength == 512 */
printf("Read6 2 blocks but with iscsi ExpectedDataTransferLength==512 ... ");
/* Try a read of 2 blocks but xferlength == block_size */
printf("Read6 2 blocks but with iscsi ExpectedDataTransferLength==%d ... ", block_size);
task = malloc(sizeof(struct scsi_task));
if (task == NULL) {
@@ -208,7 +233,7 @@ test4:
task->cdb[4] = 2;
task->cdb_size = 6;
task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 512;
task->expxferlen = block_size;
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
printf("[FAILED]\n");
@@ -219,12 +244,12 @@ test4:
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read6 of 2 blocks with iscsi ExpectedDataTransferLength==512 should succeed.\n");
printf("Read6 of 2 blocks with iscsi ExpectedDataTransferLength==%d should succeed.\n", block_size);
ret = -1;
scsi_free_scsi_task(task);
goto test5;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != 512) {
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) {
printf("[FAILED]\n");
printf("Read6 returned incorrect residual overflow.\n");
ret = -1;

View File

@@ -28,7 +28,7 @@ int T0133_verify10_beyondeol(const char *initiator, const char *url, int data_lo
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512*256];
unsigned char buf[4096*256];
printf("0133_verify10_beyond_eol:\n");
printf("========================\n");

View File

@@ -28,7 +28,7 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512];
unsigned char buf[4096];
printf("0182_writesame10_beyondeol:\n");
printf("=======================\n");

View File

@@ -27,7 +27,7 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char buf[512];
unsigned char buf[4096];
printf("0183_writesame10_wrptotect:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l
int ret, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512];
unsigned char buf[4096];
printf("0184_writesame10_0blocks:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512];
unsigned char buf[4096];
printf("0192_writesame16_beyondeol:\n");
printf("=======================\n");

View File

@@ -27,7 +27,7 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char buf[512];
unsigned char buf[4096];
printf("0193_writesame16_wrptotect:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l
int ret, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512];
unsigned char buf[4096];
printf("0194_writesame16_0blocks:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0220_write16_simple(const char *initiator, const char *url, int data_loss,
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0220_write16_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0221_write16_wrprotect(const char *initiator, const char *url, int data_los
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0221_write16_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0222_write16_flags(const char *initiator, const char *url, int data_loss, i
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096 * 256];
printf("0222_write16_flags:\n");
printf("===================\n");

View File

@@ -28,7 +28,7 @@ int T0224_write16_beyondeol(const char *initiator, const char *url, int data_los
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0224_write16_beyond_eol:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0230_write12_simple(const char *initiator, const char *url, int data_loss,
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0230_write12_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0231_write12_wrprotect(const char *initiator, const char *url, int data_los
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0231_write12_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0232_write12_flags(const char *initiator, const char *url, int data_loss, i
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0232_write12_flags:\n");
printf("===================\n");

View File

@@ -28,7 +28,7 @@ int T0234_write12_beyondeol(const char *initiator, const char *url, int data_los
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0234_write12_beyond_eol:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_lo
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512*256];
unsigned char buf[4096 * 256];
printf("0273_verify16_beyond_eol:\n");
printf("========================\n");

View File

@@ -28,7 +28,7 @@ int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_lo
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[512*256];
unsigned char buf[4096 * 256];
printf("0283_verify12_beyond_eol:\n");
printf("========================\n");

View File

@@ -28,7 +28,7 @@ int T0290_write10_simple(const char *initiator, const char *url, int data_loss,
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0290_write10_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0291_write10_wrprotect(const char *initiator, const char *url, int data_los
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0291_write10_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0292_write10_flags(const char *initiator, const char *url, int data_loss, i
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0292_write10_flags:\n");
printf("===================\n");

View File

@@ -28,7 +28,7 @@ int T0294_write10_beyondeol(const char *initiator, const char *url, int data_los
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0294_write10_beyond_eol:\n");
printf("=======================\n");

View File

@@ -29,7 +29,7 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh
struct scsi_mode_sense *ms;
int ret, lun;
uint32_t block_size;
unsigned char data[258 * 512];
unsigned char data[4096];
int full_size;
int lbpme;
struct unmap_list list[1];

View File

@@ -28,7 +28,7 @@ int T0310_writeverify10_simple(const char *initiator, const char *url, int data_
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0310_writeverify10_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int da
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0311_writeverify10_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0314_writeverify10_beyond_eol:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0320_writeverify12_simple(const char *initiator, const char *url, int data_
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0320_writeverify12_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int da
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0321_writeverify12_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0324_writeverify12_beyond_eol:\n");
printf("=======================\n");

View File

@@ -28,7 +28,7 @@ int T0330_writeverify16_simple(const char *initiator, const char *url, int data_
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0330_writeverify16_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int da
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0331_writeverify16_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0334_writeverify16_beyond_eol:\n");
printf("=======================\n");

View File

@@ -29,7 +29,7 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0340_compareandwrite_simple:\n");
printf("===================\n");

View File

@@ -29,7 +29,7 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[512 * 256];
unsigned char data[4096 * 256];
printf("0341_compareandwrite_mismatch:\n");
printf("===================\n");

View File

@@ -28,7 +28,7 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0343_compareandwrite_beyond_eol:\n");
printf("=======================\n");

View File

@@ -29,9 +29,9 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss,
int ret, i, j, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char r1data[512 * 256];
unsigned char r2data[512 * 256];
unsigned char ordata[512 * 256];
unsigned char r1data[4096 * 256];
unsigned char r2data[4096 * 256];
unsigned char ordata[4096 * 256];
printf("0350_orwrite_simple:\n");
printf("===================\n");

View File

@@ -27,7 +27,7 @@ int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_los
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[256 * 512];
unsigned char data[4096];
printf("0351_orwrite_wrprotect:\n");
printf("======================\n");

View File

@@ -28,7 +28,7 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[258 * 512];
unsigned char data[4096 * 258];
printf("0354_orwrite_beyondeol:\n");
printf("=======================\n");

View File

@@ -30,7 +30,7 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho
int ret, lun, removable;
uint32_t block_size;
int full_size;
unsigned char buf[2048];
unsigned char buf[4096];
printf("0370_nomedia:\n");
printf("============\n");

View File

@@ -28,7 +28,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun, sccs, encserv, lbpme;
unsigned char data[2048];
unsigned char data[4096];
uint32_t block_size;
int full_size;

View File

@@ -63,7 +63,7 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint32_t block_size;
unsigned char data[512 * 256];
unsigned char data[4096 * 2];
struct iscsi_async_state test_state;
printf("1000_cmdsn_invalid:\n");
@@ -117,7 +117,7 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i
ret = 0;
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsi->target_max_recv_data_segment_length = 512;
iscsi->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
printf("Write 2 blocks with CMDSN > MAXCMDSN ... ");
@@ -155,7 +155,7 @@ test2:
/* 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 = 512;
iscsi->target_max_recv_data_segment_length = block_size;
printf("Write 2 blocks with CMDSN == 0 ... ");fflush(stdout);
change_cmdsn = 2;

View File

@@ -72,7 +72,7 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint32_t block_size;
unsigned char data[512 * 256];
unsigned char data[4096 * 2];
struct iscsi_async_state test_state;
printf("1010_datasn_invalid:\n");
@@ -127,7 +127,7 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
ret = 0;
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsi->target_max_recv_data_segment_length = 512;
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 ... ");
@@ -166,7 +166,7 @@ test2:
/* 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 = 512;
iscsi->target_max_recv_data_segment_length = block_size;
printf("Write 2 DATA-IN with DATASN == 27 ... ");
/* we dont want autoreconnect since some targets will drop the
@@ -204,7 +204,7 @@ test3:
/* 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 = 512;
iscsi->target_max_recv_data_segment_length = block_size;
printf("Write 2 DATA-IN with DATASN == -1 ... ");
/* we dont want autoreconnect since some targets will drop the
@@ -245,7 +245,7 @@ test4:
/* 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 = 512;
iscsi->target_max_recv_data_segment_length = block_size;
printf("Write 2 DATA-IN with DATASN in reverse order (1, 0) ... ");
/* we dont want autoreconnect since some targets will drop the

View File

@@ -24,6 +24,8 @@
static int change_bufferoffset;
uint32_t block_size;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu)
{
if (pdu->outdata.data[0] != ISCSI_PDU_DATA_OUT) {
@@ -35,8 +37,8 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu
*(uint32_t *)&pdu->outdata.data[40] = htonl(ntohl(*(uint32_t *)&pdu->outdata.data[40]) + 1024*1024);
break;
case 2:
/* Add -512 to the buffer offset */
*(uint32_t *)&pdu->outdata.data[40] = htonl(ntohl(*(uint32_t *)&pdu->outdata.data[40]) - 512);
/* Add -'block_size' to the buffer offset */
*(uint32_t *)&pdu->outdata.data[40] = htonl(ntohl(*(uint32_t *)&pdu->outdata.data[40]) - block_size);
break;
}
return 0;
@@ -63,8 +65,7 @@ int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint32_t block_size;
unsigned char data[512 * 256];
unsigned char data[block_size * 256];
struct iscsi_async_state test_state;
printf("1020_bufferoffset_invalid:\n");
@@ -73,7 +74,7 @@ int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_
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==-512 is an error\n");
printf("2, Test that BufferOffset==-'block_size' is an error\n");
printf("\n");
return 0;
}
@@ -118,7 +119,7 @@ int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_
ret = 0;
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsi->target_max_recv_data_segment_length = 512;
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 ... ");
@@ -156,9 +157,9 @@ test2:
/* 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 = 512;
iscsi->target_max_recv_data_segment_length = block_size;
printf("Write 2 DATA-IN with BUFFEROFFSET==-512 ... ");
printf("Write 2 DATA-IN with BUFFEROFFSET==-%d ... ", block_size);
/* we dont want autoreconnect since some targets will drop the
* on this condition.
*/
@@ -194,7 +195,7 @@ test3:
/* 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 = 512;
iscsi->target_max_recv_data_segment_length = block_size;
finished:
local_iscsi_queue_pdu = NULL;