TESTS: Add tests for WRITEVERIFY10/12/16
This commit is contained in:
17
Makefile.am
17
Makefile.am
@@ -267,7 +267,22 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
|
||||
test-tool/test_writesame16_wrprotect.c \
|
||||
test-tool/test_writesame16_unmap.c \
|
||||
test-tool/test_writesame16_unmap_unaligned.c \
|
||||
test-tool/test_writesame16_unmap_until_end.c
|
||||
test-tool/test_writesame16_unmap_until_end.c \
|
||||
test-tool/test_writeverify10_simple.c \
|
||||
test-tool/test_writeverify10_beyond_eol.c \
|
||||
test-tool/test_writeverify10_0blocks.c \
|
||||
test-tool/test_writeverify10_wrprotect.c \
|
||||
test-tool/test_writeverify10_flags.c \
|
||||
test-tool/test_writeverify12_simple.c \
|
||||
test-tool/test_writeverify12_beyond_eol.c \
|
||||
test-tool/test_writeverify12_0blocks.c \
|
||||
test-tool/test_writeverify12_wrprotect.c \
|
||||
test-tool/test_writeverify12_flags.c \
|
||||
test-tool/test_writeverify16_simple.c \
|
||||
test-tool/test_writeverify16_beyond_eol.c \
|
||||
test-tool/test_writeverify16_0blocks.c \
|
||||
test-tool/test_writeverify16_wrprotect.c \
|
||||
test-tool/test_writeverify16_flags.c
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -3270,6 +3270,548 @@ writesame16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, u
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify10(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY10 LBA:%d blocks:%d "
|
||||
"wrprotect:%d dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify10_sync(iscsi, lun, lba,
|
||||
data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 command: "
|
||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY10 returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY10 (Expecting INVALID_FIELD_IN_CDB) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify10_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"INVALID_FIELD_IN_CDB. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY10 returned ILLEGAL_REQUEST/INVALID_FIELD_IB_CDB.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY10 (Expecting LBA_OUT_OF_RANGE) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify10_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY10 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify10_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY10 (Expecting WRITE_PROTECTED) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify10_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 successful but should "
|
||||
"have failed with DATA_PROTECTION/WRITE_PROTECTED");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY10 failed with wrong sense. "
|
||||
"Should have failed with DATA_PRTOTECTION/"
|
||||
"WRITE_PROTECTED. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY10 returned DATA_PROTECTION/WRITE_PROTECTED.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify12(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY12 LBA:%d blocks:%d "
|
||||
"wrprotect:%d dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify12_sync(iscsi, lun, lba,
|
||||
data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY12 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 command: "
|
||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY12 returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY12 (Expecting INVALID_FIELD_IN_CDB) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify12_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY12 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"INVALID_FIELD_IN_CDB. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY12 returned ILLEGAL_REQUEST/INVALID_FIELD_IB_CDB.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY12 (Expecting LBA_OUT_OF_RANGE) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify12_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY12 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY12 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify12_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY12 (Expecting WRITE_PROTECTED) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify12_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY12 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 successful but should "
|
||||
"have failed with DATA_PROTECTION/WRITE_PROTECTED");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY12 failed with wrong sense. "
|
||||
"Should have failed with DATA_PRTOTECTION/"
|
||||
"WRITE_PROTECTED. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY12 returned DATA_PROTECTION/WRITE_PROTECTED.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify16(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY16 LBA:%" PRIu64 " blocks:%d "
|
||||
"wrprotect:%d dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify16_sync(iscsi, lun, lba,
|
||||
data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY16 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 command: "
|
||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY16 returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY16 (Expecting INVALID_FIELD_IN_CDB) "
|
||||
"LBA:%" PRIu64 " blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify16_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY16 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"INVALID_FIELD_IN_CDB. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY16 returned ILLEGAL_REQUEST/INVALID_FIELD_IB_CDB.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY16 (Expecting LBA_OUT_OF_RANGE) "
|
||||
"LBA:%" PRIu64 " blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify16_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY16 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY16 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writeverify16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int bytchk, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITEVERIFY16 (Expecting WRITE_PROTECTED) "
|
||||
"LBA:%" PRIu64 " blocks:%d wrprotect:%d "
|
||||
"dpo:%d bytchk:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, bytchk, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_writeverify16_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, bytchk, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITEVERIFY16 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 successful but should "
|
||||
"have failed with DATA_PROTECTION/WRITE_PROTECTED");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITEVERIFY16 failed with wrong sense. "
|
||||
"Should have failed with DATA_PRTOTECTION/"
|
||||
"WRITE_PROTECTED. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITEVERIFY16 returned DATA_PROTECTION/WRITE_PROTECTED.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize)
|
||||
|
||||
@@ -261,6 +261,18 @@ int writesame16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t dat
|
||||
int writesame16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
|
||||
int writesame16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
|
||||
int writesame16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
|
||||
int writeverify10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify10_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify12_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
int writeverify16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -256,6 +256,33 @@ static CU_TestInfo tests_writesame16[] = {
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_writeverify10[] = {
|
||||
{ (char *)"testWriteVerify10Simple", test_writeverify10_simple },
|
||||
{ (char *)"testWriteVerify10BeyondEol", test_writeverify10_beyond_eol },
|
||||
{ (char *)"testWriteVerify10ZeroBlocks", test_writeverify10_0blocks },
|
||||
{ (char *)"testWriteVerify10WriteProtect", test_writeverify10_wrprotect },
|
||||
{ (char *)"testWriteVerify10Flags", test_writeverify10_flags },
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_writeverify12[] = {
|
||||
{ (char *)"testWriteVerify12Simple", test_writeverify12_simple },
|
||||
{ (char *)"testWriteVerify12BeyondEol", test_writeverify12_beyond_eol },
|
||||
{ (char *)"testWriteVerify12ZeroBlocks", test_writeverify12_0blocks },
|
||||
{ (char *)"testWriteVerify12WriteProtect", test_writeverify12_wrprotect },
|
||||
{ (char *)"testWriteVerify12Flags", test_writeverify12_flags },
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_writeverify16[] = {
|
||||
{ (char *)"testWriteVerify16Simple", test_writeverify16_simple },
|
||||
{ (char *)"testWriteVerify16BeyondEol", test_writeverify16_beyond_eol },
|
||||
{ (char *)"testWriteVerify16ZeroBlocks", test_writeverify16_0blocks },
|
||||
{ (char *)"testWriteVerify16WriteProtect", test_writeverify16_wrprotect },
|
||||
{ (char *)"testWriteVerify16Flags", test_writeverify16_flags },
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_SuiteInfo suites[] = {
|
||||
{ (char *)"TestGetLBAStatus", test_setup, test_teardown,
|
||||
tests_get_lba_status },
|
||||
@@ -263,6 +290,14 @@ static CU_SuiteInfo suites[] = {
|
||||
tests_prefetch10 },
|
||||
{ (char *)"TestPrefetch16", test_setup, test_teardown,
|
||||
tests_prefetch16 },
|
||||
{ (char *)"TestPrinReadKeys", test_setup, test_teardown,
|
||||
tests_prin_read_keys },
|
||||
{ (char *)"TestPrinServiceactionRange", test_setup, test_teardown,
|
||||
tests_prin_serviceaction_range },
|
||||
{ (char *)"TestProutRegister", test_setup, test_teardown,
|
||||
tests_prout_register },
|
||||
{ (char *)"TestProutReserve", test_setup_pgr, test_teardown_pgr,
|
||||
tests_prout_reserve },
|
||||
{ (char *)"TestRead6", test_setup, test_teardown,
|
||||
tests_read6 },
|
||||
{ (char *)"TestRead10", test_setup, test_teardown,
|
||||
@@ -297,14 +332,12 @@ static CU_SuiteInfo suites[] = {
|
||||
tests_writesame10 },
|
||||
{ (char *)"TestWriteSame16", test_setup, test_teardown,
|
||||
tests_writesame16 },
|
||||
{ (char *)"TestPrinReadKeys", test_setup, test_teardown,
|
||||
tests_prin_read_keys },
|
||||
{ (char *)"TestPrinServiceactionRange", test_setup, test_teardown,
|
||||
tests_prin_serviceaction_range },
|
||||
{ (char *)"TestProutRegister", test_setup, test_teardown,
|
||||
tests_prout_register },
|
||||
{ (char *)"TestProutReserve", test_setup_pgr, test_teardown_pgr,
|
||||
tests_prout_reserve },
|
||||
{ (char *)"TestWriteVerify10", test_setup, test_teardown,
|
||||
tests_writeverify10 },
|
||||
{ (char *)"TestWriteVerify12", test_setup, test_teardown,
|
||||
tests_writeverify12 },
|
||||
{ (char *)"TestWriteVerify16", test_setup, test_teardown,
|
||||
tests_writeverify16 },
|
||||
CU_SUITE_INFO_NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -53,6 +53,18 @@ void test_prefetch16_beyond_eol(void);
|
||||
void test_prefetch16_0blocks(void);
|
||||
void test_prefetch16_flags(void);
|
||||
|
||||
void test_prin_read_keys_simple(void);
|
||||
void test_prin_serviceaction_range(void);
|
||||
|
||||
void test_prout_register_simple(void);
|
||||
void test_prout_reserve_simple(void);
|
||||
void test_prout_reserve_access_ea(void);
|
||||
void test_prout_reserve_access_we(void);
|
||||
void test_prout_reserve_access_earo(void);
|
||||
void test_prout_reserve_access_wero(void);
|
||||
void test_prout_reserve_access_eaar(void);
|
||||
void test_prout_reserve_access_wear(void);
|
||||
|
||||
void test_read6_simple(void);
|
||||
void test_read6_beyond_eol(void);
|
||||
void test_read6_0blocks(void);
|
||||
@@ -148,15 +160,22 @@ void test_writesame16_unmap(void);
|
||||
void test_writesame16_unmap_unaligned(void);
|
||||
void test_writesame16_unmap_until_end(void);
|
||||
|
||||
void test_prin_read_keys_simple(void);
|
||||
void test_prin_serviceaction_range(void);
|
||||
void test_prout_register_simple(void);
|
||||
void test_prout_reserve_simple(void);
|
||||
void test_prout_reserve_access_ea(void);
|
||||
void test_prout_reserve_access_we(void);
|
||||
void test_prout_reserve_access_earo(void);
|
||||
void test_prout_reserve_access_wero(void);
|
||||
void test_prout_reserve_access_eaar(void);
|
||||
void test_prout_reserve_access_wear(void);
|
||||
void test_writeverify10_simple(void);
|
||||
void test_writeverify10_beyond_eol(void);
|
||||
void test_writeverify10_0blocks(void);
|
||||
void test_writeverify10_wrprotect(void);
|
||||
void test_writeverify10_flags(void);
|
||||
|
||||
void test_writeverify12_simple(void);
|
||||
void test_writeverify12_beyond_eol(void);
|
||||
void test_writeverify12_0blocks(void);
|
||||
void test_writeverify12_wrprotect(void);
|
||||
void test_writeverify12_flags(void);
|
||||
|
||||
void test_writeverify16_simple(void);
|
||||
void test_writeverify16_beyond_eol(void);
|
||||
void test_writeverify16_0blocks(void);
|
||||
void test_writeverify16_wrprotect(void);
|
||||
void test_writeverify16_flags(void);
|
||||
|
||||
#endif /* _ISCSI_TEST_CU_H_ */
|
||||
|
||||
@@ -108,10 +108,35 @@ test_readonly_sbc(void)
|
||||
}
|
||||
CU_ASSERT_NOT_EQUAL(ret, -1);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 fails with WRITE_PROTECTED");
|
||||
ret = writeverify10_writeprotected(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
if (ret == -2) {
|
||||
logging(LOG_VERBOSE, "WRITEVERIFY10 not supported on target. Skipped.");
|
||||
}
|
||||
CU_ASSERT_NOT_EQUAL(ret, -1);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 fails with WRITE_PROTECTED");
|
||||
ret = writeverify12_writeprotected(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
if (ret == -2) {
|
||||
logging(LOG_VERBOSE, "WRITEVERIFY12 not supported on target. Skipped.");
|
||||
}
|
||||
CU_ASSERT_NOT_EQUAL(ret, -1);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 fails with WRITE_PROTECTED");
|
||||
ret = writeverify16_writeprotected(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
if (ret == -2) {
|
||||
logging(LOG_VERBOSE, "WRITEVERIFY16 not supported on target. Skipped.");
|
||||
}
|
||||
CU_ASSERT_NOT_EQUAL(ret, -1);
|
||||
|
||||
|
||||
/* NOT implemented yet */
|
||||
logging(LOG_VERBOSE, "Test for WRITEVERIFY10 not implemented yet.");
|
||||
logging(LOG_VERBOSE, "Test for WRITEVERIFY12 not implemented yet.");
|
||||
logging(LOG_VERBOSE, "Test for WRITEVERIFY16 not implemented yet.");
|
||||
logging(LOG_VERBOSE, "Test for COMPAREANDWRITE not implemented yet.");
|
||||
logging(LOG_VERBOSE, "Test for ORWRITE not implemented yet.");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
|
||||
60
test-tool/test_writeverify10_0blocks.c
Normal file
60
test-tool/test_writeverify10_0blocks.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify10_0blocks(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
if (num_blocks >= 0x80000000) {
|
||||
CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY10. Skipping test.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0");
|
||||
ret = writeverify10(iscsic, tgt_lun, 0, 0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN");
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0,
|
||||
block_size, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31");
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, 0x80000000, 0,
|
||||
block_size, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1");
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, -1, 0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
85
test-tool/test_writeverify10_beyond_eol.c
Normal file
85
test-tool/test_writeverify10_beyond_eol.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronneisahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_writeverify10_beyond_eol(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
if (num_blocks >= 0x80000000) {
|
||||
CU_PASS("LUN is too big for write-beyond-eol tests with WRITEVERIFY10. Skipping test.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks one block beyond the end");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
|
||||
block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end");
|
||||
for (i = 2; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
53
test-tool/test_writeverify10_flags.c
Normal file
53
test-tool/test_writeverify10_flags.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify10_flags(void)
|
||||
{
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 flags");
|
||||
|
||||
buf = malloc(block_size);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1");
|
||||
ret = writeverify10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 1, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1");
|
||||
ret = writeverify10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 1, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
61
test-tool/test_writeverify10_simple.c
Normal file
61
test-tool/test_writeverify10_simple.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-support.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_writeverify10_simple(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN");
|
||||
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify10(iscsic, tgt_lun, 0, i * block_size,
|
||||
block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
if (ret == -2) {
|
||||
CU_PASS("[SKIPPED] Target does not support WRITEVERIFY10. Skipping test");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the end of the LUN");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify10(iscsic, tgt_lun, num_blocks - i,
|
||||
i * block_size, block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
}
|
||||
50
test-tool/test_writeverify10_wrprotect.c
Normal file
50
test-tool/test_writeverify10_wrprotect.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify10_wrprotect(void)
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char *buf;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
/*
|
||||
* Try out different non-zero values for WRPROTECT.
|
||||
* They should all fail.
|
||||
*/
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with non-zero WRPROTECT");
|
||||
buf = malloc(block_size);
|
||||
for (i = 1; i < 8; i++) {
|
||||
ret = writeverify10_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
i, 0, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
60
test-tool/test_writeverify12_0blocks.c
Normal file
60
test-tool/test_writeverify12_0blocks.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify12_0blocks(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
if (num_blocks >= 0x80000000) {
|
||||
CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY12. Skipping test.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0");
|
||||
ret = writeverify12(iscsic, tgt_lun, 0, 0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN");
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0,
|
||||
block_size, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31");
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, 0x80000000, 0,
|
||||
block_size, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1");
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, -1, 0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
85
test-tool/test_writeverify12_beyond_eol.c
Normal file
85
test-tool/test_writeverify12_beyond_eol.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronneisahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_writeverify12_beyond_eol(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
if (num_blocks >= 0x80000000) {
|
||||
CU_PASS("LUN is too big for write-beyond-eol tests with WRITEVERIFY12. Skipping test.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks one block beyond the end");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
|
||||
block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end");
|
||||
for (i = 2; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
53
test-tool/test_writeverify12_flags.c
Normal file
53
test-tool/test_writeverify12_flags.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify12_flags(void)
|
||||
{
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 flags");
|
||||
|
||||
buf = malloc(block_size);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1");
|
||||
ret = writeverify12(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 1, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1");
|
||||
ret = writeverify12(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 1, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
61
test-tool/test_writeverify12_simple.c
Normal file
61
test-tool/test_writeverify12_simple.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-support.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_writeverify12_simple(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN");
|
||||
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify12(iscsic, tgt_lun, 0, i * block_size,
|
||||
block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
if (ret == -2) {
|
||||
CU_PASS("[SKIPPED] Target does not support WRITEVERIFY12. Skipping test");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify12(iscsic, tgt_lun, num_blocks - i,
|
||||
i * block_size, block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
}
|
||||
50
test-tool/test_writeverify12_wrprotect.c
Normal file
50
test-tool/test_writeverify12_wrprotect.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify12_wrprotect(void)
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char *buf;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
/*
|
||||
* Try out different non-zero values for WRPROTECT.
|
||||
* They should all fail.
|
||||
*/
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with non-zero WRPROTECT");
|
||||
buf = malloc(block_size);
|
||||
for (i = 1; i < 8; i++) {
|
||||
ret = writeverify12_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
i, 0, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
60
test-tool/test_writeverify16_0blocks.c
Normal file
60
test-tool/test_writeverify16_0blocks.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify16_0blocks(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0");
|
||||
ret = writeverify16(iscsic, tgt_lun, 0,
|
||||
0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN");
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1,
|
||||
0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63");
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
|
||||
0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1");
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun, -1,
|
||||
0, block_size,
|
||||
0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
86
test-tool/test_writeverify16_beyond_eol.c
Normal file
86
test-tool/test_writeverify16_beyond_eol.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronneisahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_writeverify16_beyond_eol(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks one block beyond the end");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
|
||||
num_blocks + 1 - i,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
|
||||
0x8000000000000000,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
|
||||
-1,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end");
|
||||
for (i = 2; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
|
||||
num_blocks - 1,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
53
test-tool/test_writeverify16_flags.c
Normal file
53
test-tool/test_writeverify16_flags.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify16_flags(void)
|
||||
{
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 flags");
|
||||
|
||||
buf = malloc(block_size);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1");
|
||||
ret = writeverify16(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 1, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1");
|
||||
ret = writeverify16(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 1, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
58
test-tool/test_writeverify16_simple.c
Normal file
58
test-tool/test_writeverify16_simple.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-support.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_writeverify16_simple(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN");
|
||||
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify16(iscsic, tgt_lun, 0, i * block_size,
|
||||
block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = writeverify16(iscsic, tgt_lun, num_blocks - i,
|
||||
i * block_size, block_size, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
}
|
||||
51
test-tool/test_writeverify16_wrprotect.c
Normal file
51
test-tool/test_writeverify16_wrprotect.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_writeverify16_wrprotect(void)
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char *buf;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
/*
|
||||
* Try out different non-zero values for WRPROTECT.
|
||||
* They should all fail.
|
||||
*/
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with non-zero WRPROTECT");
|
||||
buf = malloc(block_size);
|
||||
for (i = 1; i < 8; i++) {
|
||||
ret = writeverify16_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
i, 0, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
Reference in New Issue
Block a user