This commit is contained in:
Lee Duncan
2012-12-27 19:18:53 -08:00
127 changed files with 1451 additions and 4590 deletions

View File

@@ -20,7 +20,7 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0000_testunitready_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0000_testunitready_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
int ret, lun;

View File

@@ -1,3 +1,4 @@
/*
Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -20,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0100_read10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0100_read10_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size, num_blocks;
printf("0100_read10_simple:\n");
printf("===================\n");
@@ -44,31 +43,6 @@ int T0100_read10_simple(const char *initiator, const char *url, int data_loss _U
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
num_blocks = rc10->lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0101_read10_beyond_eol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size, num_blocks;
printf("0101_read10_beyond_eol:\n");
printf("=======================\n");
@@ -47,31 +45,6 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
num_blocks = rc10->lba;
scsi_free_scsi_task(task);
ret = 0;
if (num_blocks >= 0x80000000) {
@@ -89,14 +62,14 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 beyond end-of-lun did not fail with sense.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -105,13 +78,13 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* Reading 1 - 256 blocks at LBA 2^31 */
printf("Reaing 1-256 blocks at LBA 2^31 ... ");
for (i = 1; i <= 256; i++) {
@@ -120,14 +93,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command should fail when reading from LBA 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -136,14 +109,13 @@ test2:
printf("READ10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at LBA -1 */
printf("Read 1-256 blocks at LBA -1 ... ");
for (i = 1; i <= 256; i++) {
@@ -152,14 +124,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command should fail when reading at LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -168,14 +140,13 @@ test3:
printf("READ10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Reading 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -184,14 +155,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 beyond end-of-lun did not return sense.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -200,15 +171,13 @@ test3:
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0102_read10_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0102_read10_0blocks:\n");
printf("====================\n");
@@ -47,31 +44,6 @@ int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss _
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
printf("READ10 0blocks at LBA:0 ... ");
task = iscsi_read10_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0);
@@ -79,39 +51,38 @@ int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss _
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("READ10 0blocks at one block beyond <end-of-LUN> ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
task = iscsi_read10_sync(iscsi, lun, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command: Should fail when reading 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -120,32 +91,31 @@ test2:
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("READ10 0blocks at LBA 2^31 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test4;
goto finished;
}
task = iscsi_read10_sync(iscsi, lun, 0x80000000, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command: Should fail when reading 0blocks at 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -154,32 +124,31 @@ test3:
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("READ10 0blocks at LBA -1 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test5;
goto finished;
}
task = iscsi_read10_sync(iscsi, lun, -1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command: Should fail when reading 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -188,15 +157,12 @@ test4:
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -22,14 +22,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0103_read10_rdprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
int full_size;
struct scsi_inquiry_standard *inq;
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
int ret, i, lun;
printf("0103_read10_rdprotect:\n");
@@ -47,67 +43,11 @@ int T0103_read10_rdprotect(const char *initiator, const char *url, int data_loss
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
if (inq->protect) {
printf("LUN is formatted with protection information. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
scsi_free_scsi_task(task);
/* 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;

View File

@@ -22,13 +22,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0104_read10_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
int ret, lun;
printf("0104_read10_flags:\n");
@@ -51,46 +48,11 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
/* 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;

View File

@@ -23,14 +23,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0105_read10_invalid(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct iscsi_data data;
char buf[4096];
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
int ret, lun;
printf("0105_read10_invalid:\n");
@@ -52,30 +50,6 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;
@@ -111,14 +85,14 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _
if (task->status == SCSI_STATUS_CANCELLED) {
scsi_free_scsi_task(task);
printf("Target dropped the session [OK]\n");
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read10 of 1 block with iscsi ExpectedDataTransferLength==0 should not fail.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW ||
task->residual != (int64_t)block_size) {
@@ -126,13 +100,12 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _
printf("Read10 returned incorrect residual overflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
/* in case the previous test failed the session */
iscsi_set_noautoreconnect(iscsi, 0);
@@ -165,7 +138,7 @@ test2:
printf("Read10 of 1 block with iscsi ExpectedDataTransferLength==1024 should not fail.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW ||
task->residual != (int64_t)block_size) {
@@ -173,13 +146,12 @@ test2:
printf("Read10 returned incorrect residual underflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
/* Try a read of 1 block but xferlength == 200 */
printf("Read10 1 block but with iscsi ExpectedDataTransferLength==200 ... ");
@@ -209,7 +181,7 @@ test3:
printf("Read10 of 1 block with iscsi ExpectedDataTransferLength==200 should not fail.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW ||
task->residual != (int64_t)(block_size - 200)) {
@@ -217,12 +189,12 @@ test3:
printf("Read10 returned incorrect residual overflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
/* Try a read of 2 blocks but xferlength == 'block_size' */
printf("Read10 2 blocks but with iscsi ExpectedDataTransferLength==%d ... ", block_size);
@@ -252,7 +224,7 @@ test4:
printf("Read10 of 2 blocks with iscsi ExpectedDataTransferLength==%d should succeed.\n", block_size);
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW ||
task->residual != (int64_t)block_size) {
@@ -260,14 +232,13 @@ test4:
printf("Read10 returned incorrect residual overflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
/* Try a read of 1 block but make it a data-out write on the iscsi layer */
printf("Read10 of 1 block but sent as data-out write in iscsi layer ... ");

View File

@@ -20,7 +20,7 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0110_readcapacity10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0110_readcapacity10_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0120_read6_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0120_read6_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size;
printf("0120_read6_simple:\n");
printf("===================\n");
@@ -43,30 +41,6 @@ int T0120_read6_simple(const char *initiator, const char *url, int data_loss _U_
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0121_read6_beyond_eol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size, num_blocks;
printf("0121_read6_beyond_eol:\n");
printf("======================\n");
@@ -46,29 +44,6 @@ int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
num_blocks = rc10->lba;
scsi_free_scsi_task(task);
ret = 0;
@@ -88,35 +63,34 @@ int T0121_read6_beyond_eol(const char *initiator, const char *url, int data_loss
printf("[FAILED]\n");
printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ6 beyond end-of-lun did not fail with sense.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST) {
printf("[FAILED]\n");
printf("READ6 beyond end-of-lun did not return sense key ILLEGAL_REQUEST. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ6 beyond end-of-lun did not return sense ascq LBA OUT OF RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Reading 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -125,35 +99,34 @@ test2:
printf("[FAILED]\n");
printf("Failed to send READ6 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ6 beyond end-of-lun did not return sense.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST) {
printf("[FAILED]\n");
printf("READ6 beyond end-of-lun did not return sense key ILLEGAL_REQUEST. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ6 beyond end-of-lun did not return sense ascq LBA OUT OF RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 0 (==256) blocks 128 blocks from eol */
printf("Reading 0(==256) blocks beyond eol starting at 128 blocks before eol ... ");
task = iscsi_read6_sync(iscsi, lun, num_blocks-128, i * block_size, block_size);

View File

@@ -23,14 +23,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0122_read6_invalid(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct iscsi_data data;
char buf[4096];
struct scsi_readcapacity10 *rc10;
uint32_t block_size;
int ret, lun;
printf("0122_read6_invalid:\n");
@@ -52,29 +50,6 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
ret = 0;
@@ -110,14 +85,14 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U
if (task->status == SCSI_STATUS_CANCELLED) {
scsi_free_scsi_task(task);
printf("Target dropped the session [OK]\n");
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==0 should not fail.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW ||
task->residual != (ssize_t)block_size) {
@@ -125,13 +100,12 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U
printf("Read6 returned incorrect residual overflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
/* in case the previous test failed the session */
iscsi_set_noautoreconnect(iscsi, 0);
@@ -164,7 +138,7 @@ test2:
printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==1024 should not fail.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW ||
task->residual != (ssize_t)block_size) {
@@ -172,13 +146,12 @@ test2:
printf("Read6 returned incorrect residual underflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
/* Try a read of 1 block but xferlength == 200 */
printf("Read6 1 block but with iscsi ExpectedDataTransferLength==200 ... ");
@@ -208,7 +181,7 @@ test3:
printf("Read6 of 1 block with iscsi ExpectedDataTransferLength==200 should not fail.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW ||
task->residual != (ssize_t)block_size - 200) {
@@ -216,12 +189,12 @@ test3:
printf("Read6 returned incorrect residual overflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
/* Try a read of 2 blocks but xferlength == block_size */
printf("Read6 2 blocks but with iscsi ExpectedDataTransferLength==%d ... ", block_size);
@@ -251,7 +224,7 @@ test4:
printf("Read6 of 2 blocks with iscsi ExpectedDataTransferLength==%d should succeed.\n", block_size);
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW ||
task->residual != (ssize_t)block_size) {
@@ -259,14 +232,12 @@ test4:
printf("Read6 returned incorrect residual overflow.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
/* Try a read of 1 block but make it a data-out write on the iscsi layer */
printf("Read6 of 1 block but sent as data-out write in iscsi layer ... ");
@@ -304,6 +275,7 @@ test5:
scsi_free_scsi_task(task);
printf("[OK]\n");
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0130_verify10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0130_verify10_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0130_verify10_simple:\n");
@@ -45,29 +43,6 @@ int T0130_verify10_simple(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
buf = malloc(256 * block_size);
if (buf == NULL) {

View File

@@ -22,13 +22,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0131_verify10_mismatch(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0131_verify10_mismatch(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
@@ -47,29 +45,6 @@ int T0131_verify10_mismatch(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
buf = malloc(256 * block_size);
if (buf == NULL) {

View File

@@ -22,13 +22,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0132_verify10_mismatch_no_cmp:\n");
@@ -47,29 +45,6 @@ int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url, int d
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
buf = malloc(256 * block_size);
if (buf == NULL) {

View File

@@ -20,14 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0133_verify10_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0133_verify10_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char *buf = NULL;
printf("0133_verify10_beyond_eol:\n");
@@ -46,31 +42,6 @@ int T0133_verify10_beyondeol(const char *initiator, const char *url, int data_lo
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,18 +20,18 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0160_readcapacity16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0160_readcapacity16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_task *task;
int ret, lun;
printf("0160_readcapacity16_simple:\n");
printf("===========================\n");
if (show_info) {
printf("Test that basic READCAPACITY16 works\n");
printf("1, Readcapacity16 should work.\n");
printf("1, READCAPACITY16 should work.\n");
printf("\n");
return 0;
}
@@ -44,17 +44,17 @@ int T0160_readcapacity16_simple(const char *initiator, const char *url, int data
return -1;
}
printf("Test that Readcapacity10 is supported ... ");
printf("Test that READCAPACITY16 is supported ... ");
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
@@ -62,7 +62,7 @@ int T0160_readcapacity16_simple(const char *initiator, const char *url, int data
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("[FAILED]\n");
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;

View File

@@ -23,7 +23,7 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0161_readcapacity16_alloclen(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
@@ -33,7 +33,7 @@ int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int da
printf("=======================\n");
if (show_info) {
printf("Test allocation-length for READCAPACITY16\n");
printf("1, Readcapacity with alloclen==0 is not an error\n");
printf("1, READCAPACITY16 with alloclen==0 is not an error\n");
printf("\n");
return 0;
}
@@ -48,7 +48,6 @@ int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int da
printf("READCAPACITY16 with AllocationLength==0 ... ");
task = malloc(sizeof(struct scsi_task));
if (task == NULL) {
printf("Failed to allocate task structure\n");
@@ -68,21 +67,19 @@ int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int da
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READCAPACITY16 with AllocationLength==0 should not fail. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0170_unmap_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0170_unmap_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t num_blocks;
printf("0170_unmap_simple:\n");
printf("==================\n");
@@ -44,38 +42,12 @@ int T0170_unmap_simple(const char *initiator, const char *url, int data_loss, in
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (rc16->lbpme == 0){
if (lbpme == 0){
printf("Logical unit is fully provisioned. Skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("data_loss flag is not set. Skipping test\n");
ret = -2;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0171_unmap_zero(const char *initiator, const char *url, int data_loss, int show_info)
int T0171_unmap_zero(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t num_blocks;
printf("0171_unmap_zero:\n");
printf("================\n");
@@ -46,38 +44,12 @@ int T0171_unmap_zero(const char *initiator, const char *url, int data_loss, int
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (rc16->lbpme == 0){
if (lbpme == 0){
printf("Logical unit is fully provisioned. Skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("data_loss flag is not set. Skipping test\n");
ret = -2;

View File

@@ -20,17 +20,13 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0180_writesame10_unmap(const char *initiator, const char *url, int data_loss, int show_info)
int T0180_writesame10_unmap(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int full_size;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
int ret, i, lun;
uint32_t num_blocks;
int lbppb;
int lbpme;
int lbpws10 = 0;
int anc_sup = 0;
@@ -53,35 +49,10 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
lbppb = 1 << rc16->lbppbe;
lbpme = rc16->lbpme;
scsi_free_scsi_task(task);
ret = 0;
if (lbpme == 0){
printf("Logical unit is fully provisioned. All commands should fail with check condition.\n");
goto test2;
}
/* Check that id we have logical block provisioning we also have the VPD page for it */
@@ -93,7 +64,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los
printf("[FAILED]\n");
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
@@ -104,7 +75,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los
printf("[FAILED]\n");
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
}
@@ -113,7 +84,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
ret = -1;
goto test2;
goto finished;
}
lbpws10 = inq_lbp->lbpws10;
@@ -126,8 +97,6 @@ int T0180_writesame10_unmap(const char *initiator, const char *url, int data_los
printf("Device does not support WRITE_SAME10 for UNMAP. All WRITE_SAME10 commands to unmap should fail.\n");
}
test2:
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -154,7 +123,7 @@ test2:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -171,7 +140,7 @@ test2:
printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test3;
goto finished;
}
} else {
if (task->status != SCSI_STATUS_CHECK_CONDITION
@@ -181,7 +150,7 @@ test2:
printf("WRITESAME10 command should fail since LBPWS10 is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test3;
goto finished;
}
}
@@ -189,7 +158,7 @@ test2:
}
printf("[OK]\n");
test3:
/* unmap the last 1 - 256 blocks at the end of the LUN */
printf("Unmapping last 1-256 blocks ... ");
if (lbpws10 == 0) {
@@ -209,7 +178,7 @@ test3:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (lbpws10) {
if (task->status != SCSI_STATUS_GOOD) {
@@ -217,7 +186,7 @@ test3:
printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test4;
goto finished;
}
} else {
if (task->status != SCSI_STATUS_CHECK_CONDITION
@@ -227,15 +196,13 @@ test3:
printf("WRITESAME10 command should fail since LBPWS10 is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test4;
goto finished;
}
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* Test that UNMAP=0 and ANCHOR==1 fails with check condition */
printf("Try UNMAP==0 and ANCHOR==1 ... ");
@@ -246,7 +213,7 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -258,12 +225,11 @@ test4:
scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
scsi_free_scsi_task(task);
ret = -1;
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
/* Test UNMAP=1 and ANCHOR==1 */
printf("Try UNMAP==1 and ANCHOR==1 ... ");
@@ -277,7 +243,7 @@ test5:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (anc_sup == 0) {
if (task->status != SCSI_STATUS_CHECK_CONDITION
@@ -290,7 +256,7 @@ test5:
scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
scsi_free_scsi_task(task);
ret = -1;
goto test6;
goto finished;
}
} else {
if (task->status != SCSI_STATUS_GOOD) {
@@ -298,15 +264,12 @@ test5:
printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test6;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test6:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, int data_loss, int show_info)
int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
int lbppb;
printf("0181_writesame10_unmap_unaligned:\n");
printf("=================================\n");
@@ -43,37 +41,12 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, in
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (rc16->lbpme == 0){
if (lbpme == 0){
printf("Logical unit is fully provisioned. Skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
lbppb = 1 << rc16->lbppbe;
scsi_free_scsi_task(task);
if (lbppb < 2) {
printf("LBPPB==%d Can not unmap fractional physical block\n", lbppb);
@@ -99,7 +72,7 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, in
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -115,13 +88,12 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url, in
printf("WRITESAME10 command to unmap a fractional physical block should fail\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0182_writesame10_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[4096];
printf("0182_writesame10_beyondeol:\n");
@@ -48,30 +45,6 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -97,7 +70,7 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -113,7 +86,7 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data
printf("WRITESAME10 command should fail when writing beyond end of device\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -122,14 +95,13 @@ int T0182_writesame10_beyondeol(const char *initiator, const char *url, int data
printf("WRITESAME10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* writing 1 - 256 blocks at LBA 2^31 */
printf("Writing 1-256 blocks at LBA 2^31 ... ");
for (i = 1; i <= 256; i++) {
@@ -139,14 +111,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command should fail when writing at LBA 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -155,14 +127,13 @@ test2:
printf("WRITESAME10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* write 1 - 256 blocks at LBA -1 */
printf("Writing 1-256 blocks at LBA -1 ... ");
for (i = 1; i <= 256; i++) {
@@ -172,14 +143,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command should fail when reading at LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -188,15 +159,13 @@ test3:
printf("WRITESAME10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0183_writesame10_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char buf[4096];
printf("0183_writesame10_wrptotect:\n");
@@ -44,28 +42,6 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -86,7 +62,7 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -102,7 +78,7 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data
printf("WRITESAME10 command should fail when WRPROTECT is set\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -111,16 +87,13 @@ int T0183_writesame10_wrprotect(const char *initiator, const char *url, int data
printf("WRITESAME10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0184_writesame10_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[4096];
printf("0184_writesame10_0blocks:\n");
@@ -48,30 +45,6 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -88,7 +61,7 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -104,18 +77,17 @@ int T0184_writesame10_0blocks(const char *initiator, const char *url, int data_l
printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Writesame10 0blocks at one block beyond <end-of-LUN> ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
task = iscsi_writesame10_sync(iscsi, lun, buf, block_size,
num_blocks + 1, 0, 0, 0, 0, 0, 0, 0);
@@ -123,14 +95,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command: Should fail when writing 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -139,18 +111,17 @@ test2:
printf("WRITESAME10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("Writesame10 0blocks at LBA 2^31 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test4;
goto finished;
}
task = iscsi_writesame10_sync(iscsi, lun, buf, block_size,
0x80000000, 0, 0, 0, 0, 0, 0, 0);
@@ -158,14 +129,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command: Should fail when writing 0blocks at 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -174,18 +145,17 @@ test3:
printf("WRITESAME10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("Writesame10 0blocks at LBA -1 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test5;
goto finished;
}
task = iscsi_writesame10_sync(iscsi, lun, buf, block_size,
-1, 0, 0, 0, 0, 0, 0, 0);
@@ -193,14 +163,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command: Should fail when writing 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -209,15 +179,12 @@ test4:
printf("WRITESAME10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,17 +20,13 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0190_writesame16_unmap(const char *initiator, const char *url, int data_loss, int show_info)
int T0190_writesame16_unmap(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int full_size;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
int ret, i, lun;
uint32_t num_blocks;
int lbppb;
int lbpme;
int lbpws = 0;
int anc_sup = 0;
@@ -53,36 +49,11 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
lbppb = 1 << rc16->lbppbe;
lbpme = rc16->lbpme;
scsi_free_scsi_task(task);
ret = 0;
if (lbpme == 0) {
printf("LBPME not set. Skip test for CPD page 0xB2 (logical block provisioning)\n");
goto test2;
goto finished;
}
/* Check that id we have logical block provisioning we also have the VPD page for it */
@@ -94,7 +65,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
printf("[FAILED]\n");
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
@@ -105,7 +76,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
printf("[FAILED]\n");
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
}
@@ -114,7 +85,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
ret = -1;
goto test2;
goto finished;
}
lbpws = inq_lbp->lbpws;
@@ -127,7 +98,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
printf("Device does not support WRITE_SAME16 for UNMAP. All WRITE_SAME16 commands to unmap should fail.\n");
}
test2:
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -155,7 +125,7 @@ test2:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -172,7 +142,7 @@ test2:
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test3;
goto finished;
}
} else {
if (task->status != SCSI_STATUS_CHECK_CONDITION
@@ -182,7 +152,7 @@ test2:
printf("WRITESAME16 command should fail since LBPWS is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test3;
goto finished;
}
}
@@ -190,7 +160,7 @@ test2:
}
printf("[OK]\n");
test3:
/* unmap the last 1 - 256 blocks at the end of the LUN */
printf("Unmapping last 1-256 blocks ... ");
if (lbpws == 0) {
@@ -210,7 +180,7 @@ test3:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (lbpws) {
if (task->status != SCSI_STATUS_GOOD) {
@@ -218,7 +188,7 @@ test3:
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test4;
goto finished;
}
} else {
if (task->status != SCSI_STATUS_CHECK_CONDITION
@@ -228,15 +198,13 @@ test3:
printf("WRITESAME16 command should fail since LBPWS is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test4;
goto finished;
}
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* Test that UNMAP=0 and ANCHOR==1 fails with check condition */
printf("Try UNMAP==0 and ANCHOR==1 ... ");
@@ -247,7 +215,7 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -256,12 +224,11 @@ test4:
printf("WRITESAME16 with UNMAP=0 ANCHOR=1 failed with wrong sense code %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
/* Test UNMAP=1 and ANCHOR==1 */
printf("Try UNMAP==1 and ANCHOR==1 ... ");
@@ -275,7 +242,7 @@ test5:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (anc_sup == 0) {
if (task->status != SCSI_STATUS_CHECK_CONDITION
@@ -285,7 +252,7 @@ test5:
printf("WRITESAME16 with UNMAP=1 ANCHOR=1 failed with wrong sense code %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test6;
goto finished;
}
} else {
if (task->status != SCSI_STATUS_GOOD) {
@@ -293,15 +260,12 @@ test5:
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1;
goto test6;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test6:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url, int data_loss, int show_info)
int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
int lbppb;
printf("0191_writesame16_unmap_unaligned:\n");
printf("=================================\n");
@@ -43,38 +41,12 @@ int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url, in
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (rc16->lbpme == 0){
if (lbpme == 0){
printf("Logical unit is fully provisioned. Skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
lbppb = 1 << rc16->lbppbe;
scsi_free_scsi_task(task);
if (lbppb < 2) {
printf("LBPPB==%d Can not unmap fractional physical block\n", lbppb);
ret = -2;

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0192_writesame16_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[4096];
printf("0192_writesame16_beyondeol:\n");
@@ -47,30 +44,6 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -89,7 +62,7 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -105,7 +78,7 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data
printf("WRITESAME16 command should fail when writing beyond end of device\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -114,14 +87,13 @@ int T0192_writesame16_beyondeol(const char *initiator, const char *url, int data
printf("WRITESAME16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* writing 1 - 256 blocks at LBA 2^63 */
printf("Writing 1-256 blocks at LBA 2^63 ... ");
for (i = 1; i <= 256; i++) {
@@ -131,14 +103,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command should fail when writing at LBA 2^63\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -147,14 +119,13 @@ test2:
printf("WRITESAME16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* write 1 - 256 blocks at LBA -1 */
printf("Writing 1-256 blocks at LBA -1 ... ");
for (i = 1; i <= 256; i++) {
@@ -164,14 +135,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command should fail when reading at LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -180,15 +151,13 @@ test3:
printf("WRITESAME16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0193_writesame16_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char buf[4096];
printf("0193_writesame16_wrptotect:\n");
@@ -44,29 +42,6 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -86,7 +61,7 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -102,7 +77,7 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data
printf("WRITESAME16 command should fail when WRPROTECT is set\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -111,16 +86,13 @@ int T0193_writesame16_wrprotect(const char *initiator, const char *url, int data
printf("WRITESAME16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0194_writesame16_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[4096];
printf("0194_writesame16_0blocks:\n");
@@ -48,30 +45,6 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -88,7 +61,7 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -104,13 +77,12 @@ int T0194_writesame16_0blocks(const char *initiator, const char *url, int data_l
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Writesame16 0blocks at one block beyond <end-of-LUN> ... ");
task = iscsi_writesame16_sync(iscsi, lun, buf, block_size,
num_blocks + 1, 0, 0, 0, 0, 0, 0, 0);
@@ -118,14 +90,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command: Should fail when writing 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -134,13 +106,12 @@ test2:
printf("WRITESAME16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("Writesame16 0blocks at LBA 2^63 ... ");
task = iscsi_writesame16_sync(iscsi, lun, buf, block_size,
0x8000000000000000, 0, 0, 0, 0, 0, 0, 0);
@@ -148,14 +119,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command: Should fail when writing 0blocks at 2^63\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -164,13 +135,12 @@ test3:
printf("WRITESAME16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("Writesame16 0blocks at LBA -1 ... ");
task = iscsi_writesame16_sync(iscsi, lun, buf, block_size,
-1, 0, 0, 0, 0, 0, 0, 0);
@@ -178,14 +148,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command: Should fail when writing 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -194,14 +164,12 @@ test4:
printf("WRITESAME16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0200_read16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0200_read16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size, num_blocks;
printf("0200_read16_simple:\n");
printf("===================\n");
@@ -44,31 +42,6 @@ int T0200_read16_simple(const char *initiator, const char *url, int data_loss _U
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
num_blocks = rc10->lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0201_read16_rdprotect(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0201_read16_rdprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
printf("0201_read16_rdprotect:\n");
printf("======================\n");
@@ -43,37 +41,6 @@ int T0201_read16_rdprotect(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
printf("Read16 with RDPROTECT ");
for (i = 1; i <= 7; i++) {

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0202_read16_flags(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0202_read16_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
printf("0202_read16_flags:\n");
printf("==================\n");
@@ -48,47 +45,11 @@ int T0202_read16_flags(const char *initiator, const char *url, int data_loss _U_
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
printf("Read16 with DPO ");
task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0203_read16_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0203_read16_0blocks:\n");
printf("====================\n");
@@ -47,31 +44,6 @@ int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
printf("READ16 0blocks at LBA:0 ... ");
task = iscsi_read16_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0);
@@ -79,34 +51,33 @@ int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("READ16 0blocks at LBA:<beyond end-of-disk> ... ");
task = iscsi_read16_sync(iscsi, lun, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: Should fail when reading 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -115,27 +86,26 @@ test2:
printf("READ16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("READ16 0blocks at LBA 2^63 ... ");
task = iscsi_read16_sync(iscsi, lun, 0x8000000000000000, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: Should fail when reading 0blocks at 2^63\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -144,27 +114,26 @@ test3:
printf("READ16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("READ16 0blocks at LBA -1 ... ");
task = iscsi_read16_sync(iscsi, lun, -1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: Should fail when reading 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -173,15 +142,12 @@ test4:
printf("READ16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0204_read16_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0204_read16_beyond_eol:\n");
printf("=======================\n");
@@ -46,31 +43,6 @@ int T0204_read16_beyondeol(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0210_read12_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0210_read12_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size, num_blocks;
printf("0210_read12_simple:\n");
printf("===================\n");
@@ -44,31 +42,6 @@ int T0210_read12_simple(const char *initiator, const char *url, int data_loss _U
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
num_blocks = rc10->lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0211_read12_rdprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
printf("0211_read12_rdprotect:\n");
printf("======================\n");
@@ -43,37 +41,6 @@ int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
printf("Read12 with RDPROTECT ");
for (i = 1; i <= 7; i++) {
@@ -97,6 +64,7 @@ int T0211_read12_rdprotect(const char *initiator, const char *url, int data_loss
}
printf("[OK]\n");
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0212_read12_flags(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0212_read12_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
printf("0212_read12_flags:\n");
printf("==================\n");
@@ -48,47 +45,11 @@ int T0212_read12_flags(const char *initiator, const char *url, int data_loss _U_
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
printf("Read12 with DPO ");
task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0213_read12_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0213_read12_0blocks:\n");
printf("====================\n");
@@ -48,31 +45,6 @@ int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss _
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
printf("READ12 0blocks at LBA:0 ... ");
task = iscsi_read12_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0);
@@ -80,39 +52,38 @@ int T0213_read12_0blocks(const char *initiator, const char *url, int data_loss _
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("READ12 0blocks at one block beyond <end-of-LUN> ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
task = iscsi_read12_sync(iscsi, lun, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command: Should fail when reading 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -121,32 +92,31 @@ test2:
printf("READ12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("READ12 0blocks at LBA 2^31 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test4;
goto finished;
}
task = iscsi_read12_sync(iscsi, lun, 0x80000000, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command: Should fail when reading 0blocks at 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -155,32 +125,31 @@ test3:
printf("READ12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("READ12 0blocks at LBA -1 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test5;
goto finished;
}
task = iscsi_read12_sync(iscsi, lun, -1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command: Should fail when reading 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -189,15 +158,12 @@ test4:
printf("READ12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0214_read12_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0214_read12_beyond_eol:\n");
printf("=======================\n");
@@ -47,31 +44,6 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;
@@ -89,100 +61,99 @@ int T0214_read12_beyondeol(const char *initiator, const char *url, int data_loss
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command should fail when reading beyond end of device\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ12 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 256 blocks at LBA 2^31 */
printf("Reading 1-256 blocks at LBA 2^31 ... ");
if (num_blocks >= 0xffffffff) {
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
for (i = 2; i <= 257; i++) {
task = iscsi_read12_sync(iscsi, lun, 0x80000000U, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command should fail when reading from LBA 2^31\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ12 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at LBA -1 */
printf("Reading 1-256 blocks at LBA -1 ... ");
if (num_blocks > 0x80000000) {
printf("LUN is too big, skipping test\n");
goto test4;
goto finished;
}
for (i = 2; i <= 257; i++) {
task = iscsi_read12_sync(iscsi, lun, -1, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ12 command should fail when reading from LBA -1\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("READ12 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0220_write16_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0220_write16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 256];
printf("0220_write16_simple:\n");
@@ -46,30 +43,6 @@ int T0220_write16_simple(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0221_write16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0221_write16_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0221_write16_wrprotect:\n");
@@ -44,37 +42,6 @@ int T0221_write16_wrprotect(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0222_write16_flags(const char *initiator, const char *url, int data_loss, int show_info)
int T0222_write16_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
unsigned char data[4096 * 256];
printf("0222_write16_flags:\n");
@@ -49,47 +46,11 @@ int T0222_write16_flags(const char *initiator, const char *url, int data_loss, i
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
printf("Write16 with DPO ");
task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss, int show_info)
int T0223_write16_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0223_write16_0blocks:\n");
printf("====================\n");
@@ -47,31 +44,6 @@ int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -85,34 +57,33 @@ int T0223_write16_0blocks(const char *initiator, const char *url, int data_loss,
printf("[FAILED]\n");
printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("WRITE16 0blocks at one block beyond <end-of-LUN> ... ");
task = iscsi_write16_sync(iscsi, lun, num_blocks + 1, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE16 command: Should fail when writing 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -121,26 +92,26 @@ test2:
printf("WRITE16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("WRITE16 0blocks at LBA 2^63 ... ");
task = iscsi_write16_sync(iscsi, lun, 0x8000000000000000, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE16 command: Should fail when writing 0blocks at 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -149,27 +120,26 @@ test3:
printf("WRITE16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("WRITE16 0blocks at LBA -1 ... ");
task = iscsi_write16_sync(iscsi, lun, -1, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE16 command: Should fail when writing 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -178,14 +148,12 @@ test4:
printf("WRITE16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0224_write16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0224_write16_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 258];
printf("0224_write16_beyond_eol:\n");
@@ -45,29 +42,6 @@ int T0224_write16_beyondeol(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0230_write12_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0230_write12_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 256];
printf("0230_write12_simple:\n");
@@ -46,30 +43,6 @@ int T0230_write12_simple(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0231_write12_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0231_write12_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0231_write12_wrprotect:\n");
@@ -44,37 +42,6 @@ int T0231_write12_wrprotect(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0232_write12_flags(const char *initiator, const char *url, int data_loss, int show_info)
int T0232_write12_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0232_write12_flags:\n");
@@ -49,47 +46,11 @@ int T0232_write12_flags(const char *initiator, const char *url, int data_loss, i
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
printf("Write12 with DPO ");
task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss, int show_info)
int T0233_write12_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0233_write12_0blocks:\n");
printf("====================\n");
@@ -47,30 +44,6 @@ int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -85,39 +58,38 @@ int T0233_write12_0blocks(const char *initiator, const char *url, int data_loss,
printf("[FAILED]\n");
printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE12 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("WRITE12 0blocks at one block beyond <end-of-LUN> ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
task = iscsi_write12_sync(iscsi, lun, num_blocks + 1, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE12 command: Should fail when writing 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -126,31 +98,31 @@ test2:
printf("WRITE12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("WRITE12 0blocks at LBA 2^31 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test4;
goto finished;
}
task = iscsi_write12_sync(iscsi, lun, 0x80000000, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE12 command: Should fail when writing 0blocks at 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -159,32 +131,31 @@ test3:
printf("WRITE12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("WRITE12 0blocks at LBA -1 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test5;
goto finished;
}
task = iscsi_write12_sync(iscsi, lun, -1, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE12 command: Should fail when writing 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -193,14 +164,12 @@ test4:
printf("WRITE12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0234_write12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0234_write12_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 258];
printf("0234_write12_beyond_eol:\n");
@@ -46,30 +43,6 @@ int T0234_write12_beyondeol(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;

View File

@@ -20,13 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0240_prefetch10_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0240_prefetch10_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint64_t num_blocks;
printf("0240_prefetch10_simple:\n");
printf("===================\n");
@@ -44,29 +41,6 @@ int T0240_prefetch10_simple(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;
/* prefetch the first 0 - 256 blocks at the start of the LUN */

View File

@@ -20,11 +20,9 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0241_prefetch10_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
printf("0241_prefetch10_flags:\n");
@@ -43,28 +41,6 @@ int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0242_prefetch10_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0242_prefetch10_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint64_t num_blocks;
printf("0242_prefetch10_beyondeol:\n");
printf("===================\n");
@@ -47,28 +44,6 @@ int T0242_prefetch10_beyondeol(const char *initiator, const char *url, int data_
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0243_prefetch10_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0243_prefetch10_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint64_t num_blocks;
printf("0243_prefetch10_0blocks:\n");
printf("===================\n");
@@ -47,28 +44,6 @@ int T0243_prefetch10_0blocks(const char *initiator, const char *url, int data_lo
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0250_prefetch16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0250_prefetch16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint64_t num_blocks;
printf("0250_prefetch16_simple:\n");
printf("===================\n");
@@ -44,29 +41,6 @@ int T0250_prefetch16_simple(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;
/* prefetch the first 0 - 256 blocks at the start of the LUN */

View File

@@ -20,11 +20,9 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0251_prefetch16_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
printf("0251_prefetch16_flags:\n");
@@ -43,28 +41,6 @@ int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0252_prefetch16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0252_prefetch16_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint64_t num_blocks;
printf("0252_prefetch16_beyondeol:\n");
printf("===================\n");
@@ -46,29 +43,6 @@ int T0252_prefetch16_beyondeol(const char *initiator, const char *url, int data_
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0253_prefetch16_0blocks(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0253_prefetch16_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint64_t num_blocks;
printf("0253_prefetch16_0blocks:\n");
printf("===================\n");
@@ -46,29 +43,6 @@ int T0253_prefetch16_0blocks(const char *initiator, const char *url, int data_lo
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0260_get_lba_status_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0260_get_lba_status_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint64_t num_blocks;
printf("0260_get_lba_status_simple:\n");
printf("===================\n");
@@ -44,38 +42,12 @@ int T0260_get_lba_status_simple(const char *initiator, const char *url, int data
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (rc16->lbpme == 0){
if (lbpme == 0){
printf("Logical unit is fully provisioned. Skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;
/* try reading one descriptor at offset 0 */

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0264_get_lba_status_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0264_get_lba_status_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
uint64_t num_blocks;
printf("0264_get_lba_status_beyondeol:\n");
printf("==============================\n");
@@ -43,38 +41,12 @@ int T0264_get_lba_status_beyondeol(const char *initiator, const char *url, int d
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (rc16->lbpme == 0){
if (lbpme == 0){
printf("Logical unit is fully provisioned. Skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;
/* try reading one descriptor beyond end-of-device */

View File

@@ -16,18 +16,17 @@
*/
#include <stdio.h>
#include <string.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0270_verify16_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0270_verify16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_task *vtask;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0270_verify16_simple:\n");
printf("=====================\n");
@@ -44,97 +43,48 @@ int T0270_verify16_simple(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
buf = malloc(256 * block_size);
if (buf == NULL) {
printf("Failed to allocate buffer.\n");
ret = -1;
goto finished;
}
printf("Read first 256 blocks.\n");
task = iscsi_read10_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
printf("[FAILED]\n");
printf("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
memcpy(buf, task->datain.data, task->datain.size);
scsi_free_scsi_task(task);
ret = 0;
/* read and verify the first 1 - 256 blocks at the start of the LUN */
printf("Read+verify first 1-256 blocks ... ");
/* verify the first 1 - 256 blocks at the start of the LUN */
printf("Verify first 1-256 blocks.\n");
for (i = 1; i <= 256; i++) {
unsigned char *buf;
task = iscsi_read16_sync(iscsi, lun, 0, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
buf = task->datain.data;
if (buf == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
vtask = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size);
if (vtask == NULL) {
printf("[FAILED]\n");
printf("Failed to send verify16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
if (vtask->status == SCSI_STATUS_CHECK_CONDITION
&& vtask->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& vtask->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("Opcode is not implemented on target\n");
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
ret = -2;
ret = verify16(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size);
if (ret != 0) {
goto finished;
}
if (vtask->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Verify16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
goto test2;
}
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
}
printf("[OK]\n");
test2:
finished:
free(buf);
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;

View File

@@ -17,18 +17,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0271_verify16_mismatch(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0271_verify16_mismatch(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_task *vtask;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0271_verify16_mismatch:\n");
printf("=======================\n");
@@ -45,108 +44,55 @@ int T0271_verify16_mismatch(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
buf = malloc(256 * block_size);
if (buf == NULL) {
printf("Failed to allocate buffer.\n");
ret = -1;
goto finished;
}
printf("Read first 256 blocks.\n");
task = iscsi_read10_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
printf("[FAILED]\n");
printf("READ10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
memcpy(buf, task->datain.data, task->datain.size);
scsi_free_scsi_task(task);
ret = 0;
/* read and verify the first 1 - 256 blocks at the start of the LUN */
printf("Read+verify first 1-256 blocks ... ");
printf("Verify first 1-256 blocks with a miscompare.\n");
for (i = 1; i <= 256; i++) {
unsigned char *buf;
int offset = random() % (i * block_size);
task = iscsi_read16_sync(iscsi, lun, 0, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
buf = task->datain.data;
if (buf == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
/* flip a random byte in the data */
buf[random() % task->datain.size] ^= 'X';
buf[offset] ^= 'X';
vtask = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size);
if (vtask == NULL) {
printf("[FAILED]\n");
printf("Failed to send verify10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
if (vtask->status == SCSI_STATUS_CHECK_CONDITION
&& vtask->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& vtask->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("Opcode is not implemented on target\n");
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
ret = -2;
ret = verify16_miscompare(iscsi, lun, buf, i * block_size, 0, 0, 1, 1, block_size);
if (ret != 0) {
goto finished;
}
if (vtask->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Verify16 command returned sense ok but the data is not matching.\n");
ret = -1;
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
goto test2;
}
if (vtask->sense.key != SCSI_SENSE_MISCOMPARE) {
printf("[FAILED]\n");
printf("Verify16 command returned wrong sense key. MISCOMPARE 0x%x expected but got key 0x%x\n", SCSI_SENSE_MISCOMPARE, vtask->sense.key);
ret = -1;
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
goto test2;
}
scsi_free_scsi_task(task);
scsi_free_scsi_task(vtask);
/* flip the byte back */
buf[offset] ^= 'X';
}
printf("[OK]\n");
test2:
finished:
free(buf);
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;

View File

@@ -17,17 +17,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0272_verify16_mismatch_no_cmp:\n");
printf("==============================\n");
@@ -45,89 +45,54 @@ int T0272_verify16_mismatch_no_cmp(const char *initiator, const char *url, int d
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
buf = malloc(256 * block_size);
if (buf == NULL) {
printf("Failed to allocate buffer.\n");
ret = -1;
goto finished;
}
printf("Read first 256 blocks.\n");
task = iscsi_read10_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
printf("[FAILED]\n");
printf("READ10 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;
memcpy(buf, task->datain.data, task->datain.size);
scsi_free_scsi_task(task);
ret = 0;
/* read and verify the first 1 - 256 blocks at the start of the LUN */
printf("Read 256 blocks and verify they are good ... ");
task = iscsi_read16_sync(iscsi, lun, 0, 256 * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Verify first 1-256 ... ");
printf("Verify first 1-256 blocks with a miscompare but BYTCHK==0.\n");
for (i = 1; i <= 256; i++) {
task = iscsi_verify16_sync(iscsi, lun, NULL, i * block_size, 0, 0, 1, 0, block_size);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("Opcode is not implemented on target\n");
scsi_free_scsi_task(task);
ret = -2;
int offset = random() % (i * block_size);
/* flip a random byte in the data */
buf[offset] ^= 'X';
ret = verify16(iscsi, lun, buf, i * block_size, 0, 0, 1, 0, block_size);
if (ret != 0) {
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("VERIFY16 returned sense but BYTCHK==1 means it should not check/compare the data. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
scsi_free_scsi_task(task);
/* flip the byte back */
buf[offset] ^= 'X';
}
printf("[OK]\n");
test3:
finished:
free(buf);
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;

View File

@@ -16,19 +16,16 @@
*/
#include <stdio.h>
#include <string.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0273_verify16_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char buf[4096 * 256];
unsigned char *buf = NULL;
printf("0273_verify16_beyond_eol:\n");
printf("========================\n");
@@ -47,136 +44,37 @@ int T0273_verify16_beyondeol(const char *initiator, const char *url, int data_lo
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;
buf = malloc(256 * block_size);
/* verify 2 - 256 blocks beyond the end of the device */
printf("Verifying 2-256 blocks beyond end-of-device ... ");
printf("Verifying 2-256 blocks beyond end-of-device.\n");
for (i = 2; i <= 256; i++) {
task = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, num_blocks, 0, 1, 1, block_size);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
ret = verify16_lbaoutofrange(iscsi, lun, buf, i * block_size, num_blocks, 0, 1, 1, block_size);
if (ret != 0) {
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("Opcode is not implemented on target\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("VERIFY16 command should fail when reading beyond end of device\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("VERIFY16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
/* verify 1 - 256 blocks at LBA 2^63 */
printf("Verify 1-256 blocks at LBA 2^63 ... ");
for (i = 2; i <= 257; i++) {
task = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, 0x8000000000000000ULL, 0, 1, 1, block_size);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
printf("Verifying 1-256 blocks at LBA 2^63.\n");
for (i = 1; i <= 256; i++) {
ret = verify16_lbaoutofrange(iscsi, lun, buf, i * block_size, 0x8000000000000000, 0, 1, 1, block_size);
if (ret != 0) {
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("VERIFY16 command should fail when reading at LBA 2^63\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("VERIFY16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
/* verify 1 - 256 blocks at LBA -1 */
printf("Verifying 1-256 blocks at LBA -1 ... ");
for (i = 2; i <= 257; i++) {
task = iscsi_verify16_sync(iscsi, lun, buf, i * block_size, -1LL, 0, 1, 1, block_size);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
printf("Verifying 1-256 blocks at LBA -1.\n");
for (i = 1; i <= 256; i++) {
ret = verify16_lbaoutofrange(iscsi, lun, buf, i * block_size, 0xffffffffffffffff, 0, 1, 1, block_size);
if (ret != 0) {
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("VERIFY16 command should fail when reading at LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("VERIFY16 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
free(buf);
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0280_verify12_simple(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0280_verify12_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0280_verify12_simple:\n");
@@ -45,29 +43,6 @@ int T0280_verify12_simple(const char *initiator, const char *url, int data_loss
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
buf = malloc(256 * block_size);
if (buf == NULL) {

View File

@@ -22,13 +22,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0281_verify12_mismatch(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0281_verify12_mismatch(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0281_verify12_mismatch:\n");
@@ -46,29 +44,6 @@ int T0281_verify12_mismatch(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("Readcapacity16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
buf = malloc(256 * block_size);
if (buf == NULL) {

View File

@@ -22,13 +22,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size;
unsigned char *buf = NULL;
printf("0282_verify12_mismatch_no_cmp:\n");
@@ -47,29 +45,6 @@ int T0282_verify12_mismatch_no_cmp(const char *initiator, const char *url, int d
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
scsi_free_scsi_task(task);
buf = malloc(256 * block_size);
if (buf == NULL) {

View File

@@ -21,14 +21,10 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0283_verify12_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char *buf = NULL;
printf("0283_verify12_beyond_eol:\n");
@@ -47,31 +43,6 @@ int T0283_verify12_beyondeol(const char *initiator, const char *url, int data_lo
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
ret = 0;

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0290_write10_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0290_write10_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[4096 * 256];
printf("0290_write10_simple:\n");
@@ -46,30 +43,6 @@ int T0290_write10_simple(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0291_write10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0291_write10_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0291_write10_wrprotect:\n");
@@ -44,36 +42,6 @@ int T0291_write10_wrprotect(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0292_write10_flags(const char *initiator, const char *url, int data_loss, int show_info)
int T0292_write10_flags(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0292_write10_flags:\n");
@@ -49,47 +46,11 @@ int T0292_write10_flags(const char *initiator, const char *url, int data_loss, i
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -2;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
printf("Write10 with DPO ");
task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss, int show_info)
int T0293_write10_0blocks(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, lun;
uint32_t block_size;
uint64_t num_blocks;
printf("0293_write10_0blocks:\n");
printf("====================\n");
@@ -47,30 +44,6 @@ int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -85,39 +58,38 @@ int T0293_write10_0blocks(const char *initiator, const char *url, int data_loss,
printf("[FAILED]\n");
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("WRITE10 0blocks at one block beyond <end-of-LUN> ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
task = iscsi_write10_sync(iscsi, lun, num_blocks + 1, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE10 command: Should fail when writing 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -126,31 +98,31 @@ test2:
printf("WRITE10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("WRITE10 0blocks at LBA:2^31 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test4;
goto finished;
}
task = iscsi_write10_sync(iscsi, lun, 0x80000000, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE10 command: Should fail when writing 0blocks at 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -159,32 +131,31 @@ test3:
printf("WRITE10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("WRITE10 0blocks at LBA:-1 ... ");
if (num_blocks > 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big, skipping test\n");
goto test5;
goto finished;
}
task = iscsi_write10_sync(iscsi, lun, -1, NULL, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE10 command: Should fail when writing 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -193,14 +164,12 @@ test4:
printf("WRITE10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0294_write10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0294_write10_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[4096 * 258];
printf("0294_write10_beyond_eol:\n");
@@ -46,29 +43,6 @@ int T0294_write10_beyondeol(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");

View File

@@ -20,19 +20,15 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0300_readonly(const char *initiator, const char *url, int data_loss, int show_info)
int T0300_readonly(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
struct scsi_mode_sense *ms;
int ret, lun;
uint32_t block_size;
unsigned char data[4096];
int full_size;
int lbpme;
struct unmap_list list[1];
int full_size;
ret = -1;
@@ -63,28 +59,6 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
lbpme = rc16->lbpme;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -92,21 +66,9 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh
}
/* This test is only valid for SBC devices */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("LUN is not SBC device. Skipping test\n");
scsi_free_scsi_task(task);
return -1;
return -2;
}
/* verify the device is readonly */
@@ -151,231 +113,216 @@ int T0300_readonly(const char *initiator, const char *url, int data_loss, int sh
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE10 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITE10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
/* Write one block at lba 0 */
printf("WRITE12 to LUN 0 ... ");
task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE12 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITE12 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
/* Write one block at lba 0 */
printf("WRITE16 to LUN 0 ... ");
task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE16 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITE16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
/* Write one block at lba 0 */
printf("WRITESAME10 to LUN 0 ... ");
task = iscsi_writesame10_sync(iscsi, lun, data, block_size, 0, 1, 0, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test5;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITESAME10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
/* Write one block at lba 0 */
printf("WRITESAME16 to LUN 0 ... ");
task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test6;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test6;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITESAME16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test6;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test6:
/* UNMAP one block at lba 0 */
printf("WRITESAME10 to UNMAP LUN 0 ... ");
if (lbpme == 0) {
printf("LUN is not thin-provisioned. [SKIPPED]\n");
goto test7;
goto finished;
}
task = iscsi_writesame10_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test7;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test7;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITESAME10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test7;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test7:
/* UNMAP one block at lba 0 */
printf("WRITESAME16 to UNMAP LUN 0 ... ");
if (lbpme == 0) {
printf("LUN is not thin-provisioned. [SKIPPED]\n");
goto test8;
goto finished;
}
task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test8;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test8;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITESAME16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test8;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test8:
/* UNMAP one block at lba 0 */
printf("UNMAP LUN 0 ... ");
if (lbpme == 0) {
printf("LUN is not thin-provisioned. [SKIPPED]\n");
goto test9;
goto finished;
}
list[0].lba = 0;
list[0].num = 1;
@@ -383,60 +330,57 @@ test8:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test9;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("UNMAP command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test9;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("UNMAP failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test9;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test9:
/* Write one block at lba 0 */
printf("WRITEVERIFY10 to LUN 0 ... ");
task = iscsi_writeverify10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test10;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test10;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test10;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test10:
/* Write one block at lba 0 */
printf("WRITEVERIFY12 to LUN 0 ... ");
@@ -444,29 +388,28 @@ test10:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test11;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test11;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test11;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test11:
/* Write one block at lba 0 */
printf("WRITEVERIFY16 to LUN 0 ... ");
@@ -474,58 +417,57 @@ test11:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test12;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test12;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test12;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test12:
/* Write one block at lba 0 */
printf("COMPAREWRITE to LUN 0 ... ");
task = iscsi_compareandwrite_sync(iscsi, lun, 0, data, block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test13;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test13;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test13;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test13:
/* Write one block at lba 0 */
printf("ORWRITE to LUN 0 ... ");
@@ -533,30 +475,28 @@ test13:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test14;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE command should fail when writing to readonly devices\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test14;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
printf("[FAILED]\n");
printf("ORWRITE failed with the wrong sense code. Should fail with DATA_PROTECTION/WRITE_PROTECTED\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test14;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test14:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0310_writeverify10_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0310_writeverify10_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[4096 * 256];
printf("0310_writeverify10_simple:\n");
@@ -46,30 +43,6 @@ int T0310_writeverify10_simple(const char *initiator, const char *url, int data_
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,22 +60,21 @@ int T0310_writeverify10_simple(const char *initiator, const char *url, int data_
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* write the last 1 - 256 blocks at the end of the LUN */
printf("Writing last 1-256 blocks ... ");
for (i = 1; i <= 256; i++) {
@@ -110,23 +82,21 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0311_writeverify10_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0311_writeverify10_wrprotect:\n");
@@ -44,36 +42,6 @@ int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int da
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
ret = -2;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,23 +55,22 @@ int T0311_writeverify10_wrprotect(const char *initiator, const char *url, int da
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0314_writeverify10_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[4096 * 258];
printf("0314_writeverify10_beyond_eol:\n");
@@ -49,29 +46,6 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -96,8 +70,8 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -111,9 +85,9 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -122,34 +96,33 @@ int T0314_writeverify10_beyondeol(const char *initiator, const char *url, int da
printf("WRITEVERIFY10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 256 blocks at lba 2^31 */
printf("Writing 1-256 blocks at LBA 2^31 ... ");
if (num_blocks > 0x80000000) {
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
for (i = 1; i <= 256; i++) {
task = iscsi_writeverify10_sync(iscsi, lun, 0x80000000, data, i * block_size, block_size, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -158,34 +131,33 @@ test2:
printf("WRITEVERIFY10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at lba -1 */
printf("Writing 1-256 blocks at LBA -1 ... ");
if (num_blocks >= 0xffffffff) {
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
for (i = 1; i <= 256; i++) {
task = iscsi_writeverify10_sync(iscsi, lun, 0xffffffff, data, i * block_size, block_size, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -194,13 +166,13 @@ test3:
printf("WRITEVERIFY10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Writing 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -209,14 +181,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY10 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -225,15 +197,13 @@ test4:
printf("WRITEVERIFY10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0320_writeverify12_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0320_writeverify12_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[4096 * 256];
printf("0320_writeverify12_simple:\n");
@@ -46,30 +43,6 @@ int T0320_writeverify12_simple(const char *initiator, const char *url, int data_
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,22 +60,21 @@ int T0320_writeverify12_simple(const char *initiator, const char *url, int data_
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* write the last 1 - 256 blocks at the end of the LUN */
printf("Writing last 1-256 blocks ... ");
for (i = 1; i <= 256; i++) {
@@ -110,23 +82,21 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0321_writeverify12_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0321_writeverify12_wrprotect:\n");
@@ -44,36 +42,6 @@ int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int da
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,23 +55,22 @@ int T0321_writeverify12_wrprotect(const char *initiator, const char *url, int da
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0324_writeverify12_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint32_t num_blocks;
unsigned char data[4096 * 258];
printf("0324_writeverify12_beyond_eol:\n");
@@ -49,29 +46,6 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -96,8 +70,8 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -111,9 +85,9 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -122,34 +96,33 @@ int T0324_writeverify12_beyondeol(const char *initiator, const char *url, int da
printf("WRITEVERIFY12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 256 blocks at lba 2^31 */
printf("Writing 1-256 blocks at LBA 2^31 ... ");
if (num_blocks > 0x80000000) {
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
for (i = 1; i <= 256; i++) {
task = iscsi_writeverify12_sync(iscsi, lun, 0x80000000, data, i * block_size, block_size, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -158,34 +131,33 @@ test2:
printf("WRITEVERIFY12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at lba -1 */
printf("Writing 1-256 blocks at LBA -1 ... ");
if (num_blocks >= 0xffffffff) {
printf("LUN is too big, skipping test\n");
goto test3;
goto finished;
}
for (i = 1; i <= 256; i++) {
task = iscsi_writeverify12_sync(iscsi, lun, 0xffffffff, data, i * block_size, block_size, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -194,13 +166,13 @@ test3:
printf("WRITEVERIFY12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Writing 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -209,14 +181,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY12 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -225,15 +197,13 @@ test4:
printf("WRITEVERIFY12 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0330_writeverify16_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0330_writeverify16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 256];
printf("0330_writeverify16_simple:\n");
@@ -46,30 +43,6 @@ int T0330_writeverify16_simple(const char *initiator, const char *url, int data_
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,22 +60,21 @@ int T0330_writeverify16_simple(const char *initiator, const char *url, int data_
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* write the last 1 - 256 blocks at the end of the LUN */
printf("Writing last 1-256 blocks ... ");
for (i = 1; i <= 256; i++) {
@@ -110,23 +82,21 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0331_writeverify16_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0331_writeverify16_wrprotect:\n");
@@ -44,36 +42,6 @@ int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int da
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,23 +55,22 @@ int T0331_writeverify16_wrprotect(const char *initiator, const char *url, int da
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0334_writeverify16_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 258];
printf("0334_writeverify16_beyond_eol:\n");
@@ -48,29 +45,6 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -88,8 +62,8 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -103,9 +77,9 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -114,13 +88,12 @@ int T0334_writeverify16_beyondeol(const char *initiator, const char *url, int da
printf("WRITEVERIFY16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 256 blocks at lba 2^63 */
printf("Writing 1-256 blocks at LBA 2^63 ... ");
@@ -129,15 +102,15 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -146,13 +119,12 @@ test2:
printf("WRITEVERIFY16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at lba -1 */
printf("Writing 1-256 blocks at LBA -1 ... ");
@@ -161,15 +133,15 @@ test3:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -178,13 +150,13 @@ test3:
printf("WRITEVERIFY16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Writing 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -193,14 +165,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITEVERIFY16 beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -209,15 +181,13 @@ test4:
printf("WRITEVERIFY16 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -21,14 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0340_compareandwrite_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0340_compareandwrite_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 256];
printf("0340_compareandwrite_simple:\n");
@@ -47,31 +44,6 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -89,23 +61,23 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
memcpy(data, task->datain.data, i * block_size);
scsi_free_scsi_task(task);
@@ -114,8 +86,8 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -129,16 +101,15 @@ int T0340_compareandwrite_simple(const char *initiator, const char *url, int dat
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* write the last 1 - 255 blocks at the end of the LUN */
printf("Compare and write last 1-255 blocks ... ");
for (i = 1; i < 256; i++) {
@@ -146,23 +117,23 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
memcpy(data, task->datain.data, i * block_size);
scsi_free_scsi_task(task);
@@ -171,21 +142,20 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -21,14 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int data_loss, int show_info)
int T0341_compareandwrite_mismatch(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 256];
printf("0341_compareandwrite_mismatch:\n");
@@ -47,30 +44,6 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -89,23 +62,23 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
memcpy(data, task->datain.data, i * block_size);
scsi_free_scsi_task(task);
@@ -117,8 +90,8 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -132,25 +105,24 @@ int T0341_compareandwrite_mismatch(const char *initiator, const char *url, int d
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE successful. It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_MISCOMPARE
|| task->sense.ascq != SCSI_SENSE_ASCQ_MISCOMPARE_DURING_VERIFY) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE Failed with the wrong sense : %s(0x%02x)/%s(0x%04x). It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n", scsi_sense_key_str(task->sense.key), task->sense.key, scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* write the last 1 - 255 blocks at the end of the LUN */
printf("Compare and write last 1-255 blocks (data is not matching) ... ");
for (i = 1; i < 256; i++) {
@@ -158,23 +130,23 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
memcpy(data, task->datain.data, i * block_size);
scsi_free_scsi_task(task);
@@ -186,30 +158,29 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE successful. It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_MISCOMPARE
|| task->sense.ascq != SCSI_SENSE_ASCQ_MISCOMPARE_DURING_VERIFY) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE Failed with the wrong sense : %s(0x%02x)/%s(0x%04x). It should have failed with MISCOMPARE/MISCOMPARE_DURING_VERIFY\n", scsi_sense_key_str(task->sense.key), task->sense.key, scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0343_compareandwrite_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 258];
printf("0343_compareandwrite_beyond_eol:\n");
@@ -48,30 +45,6 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -88,8 +61,8 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -103,9 +76,9 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -114,13 +87,12 @@ int T0343_compareandwrite_beyondeol(const char *initiator, const char *url, int
printf("COMPAREANDWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 255 blocks at lba 2^63 */
printf("Writing 1-255 blocks at LBA 2^63 ... ");
@@ -129,15 +101,15 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -146,13 +118,12 @@ test2:
printf("COMPAREANDWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 255 blocks at lba -1 */
printf("Writing 1-255 blocks at LBA -1 ... ");
@@ -161,15 +132,15 @@ test3:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -178,13 +149,13 @@ test3:
printf("COMPAREANDWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-255 blocks, all but one block beyond the eol */
printf("Writing 1-255 blocks beyond eol starting at last block ... ");
for (i = 2; i < 256; i++) {
@@ -193,14 +164,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send COMPAREANDWRITE command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("COMPAREANDWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -209,15 +180,13 @@ test4:
printf("COMPAREANDWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -21,14 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0350_orwrite_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, j, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char r1data[4096 * 256];
unsigned char r2data[4096 * 256];
unsigned char ordata[4096 * 256];
@@ -49,30 +46,6 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss,
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -91,23 +64,23 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss,
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
memcpy(r1data, task->datain.data, i * block_size);
memset(ordata, 0x5a, i * block_size);
@@ -120,15 +93,15 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss,
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
@@ -136,31 +109,31 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss,
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (memcmp(r2data, task->datain.data, i * block_size)) {
printf("[FAILED]\n");
printf("Blocks were not updated as expected.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
@@ -168,7 +141,6 @@ int T0350_orwrite_simple(const char *initiator, const char *url, int data_loss,
printf("[OK]\n");
test2:
/* write the last 1 - 255 blocks at the end of the LUN */
printf("Orwrite last 1-255 blocks ... ");
for (i = 1; i < 256; i++) {
@@ -176,23 +148,23 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
memcpy(r1data, task->datain.data, i * block_size);
memcpy(r1data, task->datain.data, i * block_size);
@@ -206,53 +178,52 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
task = iscsi_read16_sync(iscsi, lun, num_blocks + 1 - i, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->datain.data == NULL) {
printf("[FAILED]\n");
printf("Failed to access DATA-IN buffer %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (memcmp(r2data, task->datain.data, i * block_size)) {
printf("[FAILED]\n");
printf("Blocks were not updated as expected.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_loss, int show_info)
int T0351_orwrite_wrprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret = 0, i, lun;
uint32_t block_size;
unsigned char data[4096];
printf("0351_orwrite_wrprotect:\n");
@@ -44,36 +42,6 @@ int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
if(rc16->prot_en != 0) {
printf("device is formatted with protection information, skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
@@ -87,23 +55,22 @@ int T0351_orwrite_wrprotect(const char *initiator, const char *url, int data_los
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
printf("[FAILED]\n");
printf("ORWRITE with WRPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -20,14 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_loss, int show_info)
int T0354_orwrite_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, i, lun;
uint32_t block_size;
uint64_t num_blocks;
unsigned char data[4096 * 258];
printf("0354_orwrite_beyondeol:\n");
@@ -48,30 +45,6 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
num_blocks = rc16->returned_lba;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -88,8 +61,8 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
@@ -103,9 +76,9 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -114,13 +87,12 @@ int T0354_orwrite_beyondeol(const char *initiator, const char *url, int data_los
printf("ORWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* read 1 - 256 blocks at lba 2^63 */
printf("Writing 1-256 blocks at LBA 2^63 ... ");
@@ -129,15 +101,15 @@ test2:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -146,13 +118,12 @@ test2:
printf("ORWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at lba -1 */
printf("Writing 1-256 blocks at LBA -1 ... ");
@@ -161,15 +132,15 @@ test3:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -178,13 +149,13 @@ test3:
printf("ORWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Writing 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -193,14 +164,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("ORWRITE beyond end-of-lun did not return sense. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -209,15 +180,13 @@ test4:
printf("ORWRITE failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0360_startstopunit_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0360_startstopunit_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
printf("0360_startstopunit_simple:\n");
printf("===================\n");
@@ -47,32 +45,6 @@ int T0360_startstopunit_simple(const char *initiator, const char *url, int data_
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_loss, int show_info)
int T0361_startstopunit_pwrcnd(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, i, lun, removable;
int full_size;
int ret, i, lun;
printf("0361_startstopunit_pwrcnd:\n");
printf("===================\n");
@@ -45,32 +43,6 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -92,13 +64,13 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
@@ -119,13 +91,13 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_loss, int show_info)
int T0362_startstopunit_noloej(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
printf("0362_startstopunit_noloej:\n");
printf("===================\n");
@@ -51,32 +49,6 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -101,14 +73,14 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -120,7 +92,6 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_
}
test2:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -130,14 +101,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -149,7 +120,6 @@ test2:
}
test3:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -159,14 +129,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -178,8 +148,6 @@ test3:
}
test4:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -189,14 +157,14 @@ test4:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -208,7 +176,6 @@ test4:
}
test5:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -218,14 +185,14 @@ test5:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test6;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test6;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -237,7 +204,6 @@ test5:
}
test6:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -247,14 +213,14 @@ test6:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test7;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test7;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -266,7 +232,6 @@ test6:
}
test7:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -276,14 +241,14 @@ test7:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test8;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test8;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -295,7 +260,6 @@ test7:
}
test8:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
@@ -305,14 +269,14 @@ test8:
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test9;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test9;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
@@ -324,7 +288,6 @@ test8:
}
test9:
/* in case the previous command did eject the media */
iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);

View File

@@ -21,15 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0370_nomedia(const char *initiator, const char *url, int data_loss, int show_info)
int T0370_nomedia(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
uint32_t block_size;
int full_size;
int ret, lun;
unsigned char buf[4096];
printf("0370_nomedia:\n");
@@ -75,65 +71,13 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
scsi_free_scsi_task(task);
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
ret = 0;
if (!removable) {
printf("Media is not removable. Skipping test.\n");
ret = -2;
goto finished;
}
ret = 0;
printf("Try to eject the media ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0);
@@ -376,28 +320,12 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho
goto finished;
}
printf("Test VERIFY16 ... ");
task = iscsi_verify16_sync(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
printf("Test VERIFY16.\n");
ret = verify16_nomedium(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size);
if (ret != 0) {
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_NOT_READY
|| (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) {
printf("[FAILED]\n");
printf("VERIFY16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
if (!data_loss) {

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0380_preventallow_simple(const char *initiator, const char *url, int data_loss, int show_info)
int T0380_preventallow_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
printf("0380_preventallow_simple:\n");
printf("=========================\n");
@@ -45,32 +43,6 @@ int T0380_preventallow_simple(const char *initiator, const char *url, int data_l
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -91,8 +63,8 @@ int T0380_preventallow_simple(const char *initiator, const char *url, int data_l
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
@@ -102,25 +74,22 @@ int T0380_preventallow_simple(const char *initiator, const char *url, int data_l
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Clear the PREVENTALLOW again ... ");
task = iscsi_preventallow_sync(iscsi, lun, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
* on a device that does not support medium removals.
@@ -129,19 +98,15 @@ test2:
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0381_preventallow_eject(const char *initiator, const char *url, int data_loss, int show_info)
int T0381_preventallow_eject(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
printf("0381_preventallow_eject:\n");
printf("========================\n");
@@ -47,55 +45,28 @@ int T0381_preventallow_eject(const char *initiator, const char *url, int data_lo
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
goto finished;
}
ret = 0;
if (!removable) {
printf("Media is not removable. Skipping tests\n");
ret = -2;
goto finished;
}
ret = 0;
printf("Try to set PREVENTALLOW ... ");
task = iscsi_preventallow_sync(iscsi, lun, 1);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
@@ -105,45 +76,43 @@ int T0381_preventallow_eject(const char *initiator, const char *url, int data_lo
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Try to eject the media ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("Eject failed. [OK]\n");
test3:
printf("Load the media again in case it was ejected ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
/* SBC doesnt really say anything about whether we can LOAD media when the prevent
* flag is set
@@ -151,16 +120,14 @@ test3:
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("Clear the PREVENTALLOW again ... ");
task = iscsi_preventallow_sync(iscsi, lun, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test5;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
* on a device that does not support medium removals.
@@ -169,18 +136,14 @@ test4:
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -21,13 +21,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int data_loss, int show_info)
{
int T0382_preventallow_itnexus_loss(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
printf("0382_preventallow_itnexus_loss:\n");
printf("===============================\n");
@@ -49,32 +47,6 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -96,8 +68,8 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
@@ -107,37 +79,36 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url, int
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Try to eject the media ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("Eject failed. [OK]\n");
test3:
printf("Tear down the IT_Nexus and create a new one ... ");
iscsi_destroy_context(iscsi);
iscsi = iscsi_context_login(initiator, url, &lun);
@@ -155,29 +126,27 @@ test3:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test5;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command should have worked but it failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test5:
printf("Load the media again in case it was ejected ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test6;
ret = -1;
goto finished;
}
/* SBC doesnt really say anything about whether we can LOAD media when the prevent
* flag is set
@@ -185,16 +154,14 @@ test5:
scsi_free_scsi_task(task);
printf("[OK]\n");
test6:
printf("Clear the PREVENTALLOW again ... ");
task = iscsi_preventallow_sync(iscsi, lun, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test7;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
* on a device that does not support medium removals.
@@ -203,16 +170,14 @@ test6:
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test7;
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test7:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -37,13 +37,11 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_,
}
int T0383_preventallow_target_warm_reset(const char *initiator, const char *url, int data_loss, int show_info)
int T0383_preventallow_target_warm_reset(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
struct mgmt_task mgmt_task = {0, 0};
struct pollfd pfd;
@@ -67,48 +65,21 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url,
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
goto finished;
}
ret = 0;
if (!removable) {
printf("Media is not removable. Skipping tests\n");
ret = -2;
goto finished;
}
ret = 0;
printf("Try to set PREVENTALLOW ... ");
task = iscsi_preventallow_sync(iscsi, lun, 1);
if (task == NULL) {

View File

@@ -37,13 +37,11 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_,
}
int T0384_preventallow_target_cold_reset(const char *initiator, const char *url, int data_loss, int show_info)
int T0384_preventallow_target_cold_reset(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
struct mgmt_task mgmt_task = {0, 0};
struct pollfd pfd;
@@ -67,47 +65,20 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url,
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
goto finished;
}
ret = 0;
if (!removable) {
printf("Media is not removable. Skipping tests\n");
ret = -2;
goto finished;
}
ret = 0;
printf("Try to set PREVENTALLOW ... ");
task = iscsi_preventallow_sync(iscsi, lun, 1);

View File

@@ -37,13 +37,11 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_,
}
int T0385_preventallow_lun_reset(const char *initiator, const char *url, int data_loss, int show_info)
int T0385_preventallow_lun_reset(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
struct mgmt_task mgmt_task = {0, 0};
struct pollfd pfd;
@@ -67,47 +65,20 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url, int dat
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
goto finished;
}
ret = 0;
if (!removable) {
printf("Media is not removable. Skipping tests\n");
ret = -2;
goto finished;
}
ret = 0;
printf("Try to set PREVENTALLOW ... ");
task = iscsi_preventallow_sync(iscsi, lun, 1);

View File

@@ -21,14 +21,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int data_loss, int show_info)
int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct iscsi_context *iscsi2 = NULL;
struct scsi_task *task;
struct scsi_inquiry_standard *inq;
int ret, lun, removable;
int full_size;
int ret, lun;
printf("0386_preventallow_2_itl_nexuses:\n");
printf("============================\n");
@@ -50,41 +48,11 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int
return -1;
}
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
removable = inq->rmb;
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
goto finished;
}
ret = 0;
if (!removable) {
printf("Media is not removable. Skipping tests\n");
@@ -92,14 +60,16 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int
goto finished;
}
ret = 0;
printf("Try to set PREVENTALLOW on 2 different IT_Nexusen ... ");
task = iscsi_preventallow_sync(iscsi, lun, 1);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test2;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
@@ -109,9 +79,9 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
}
scsi_free_scsi_task(task);
@@ -125,79 +95,74 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi2));
ret++;
goto test2;
ret = -1;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Try to eject the media ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("Eject failed. [OK]\n");
test3:
printf("Remove the PREVENT on this IT_Nexus ... ");
task = iscsi_preventallow_sync(iscsi, lun, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test4;
ret = -1;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test4:
printf("Try to eject the media ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test5;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) {
printf("[FAILED]\n");
printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
printf("Eject failed. [OK]\n");
test5:
printf("Load the media again in case it was ejected ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test6;
ret = -1;
goto finished;
}
/* SBC doesnt really say anything about whether we can LOAD media when the prevent
* flag is set
@@ -205,16 +170,14 @@ test5:
scsi_free_scsi_task(task);
printf("[OK]\n");
test6:
printf("Clear the PREVENTALLOW again ... ");
task = iscsi_preventallow_sync(iscsi, lun, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test7;
ret = -1;
goto finished;
}
/* SPC doesnt really say anything about what should happen if using PREVENTALLOW
* on a device that does not support medium removals.
@@ -223,9 +186,9 @@ test6:
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
ret = -1;
scsi_free_scsi_task(task);
goto test7;
goto finished;
}
}
scsi_free_scsi_task(task);
@@ -234,14 +197,12 @@ test6:
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi2));
ret++;
goto test7;
ret = -1;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test7:
finished:
iscsi_logout_sync(iscsi);

View File

@@ -21,16 +21,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data_loss, int show_info)
int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int ret = 0, lun, sccs, encserv, lbpme;
int ret = 0, lun;
unsigned char data[4096];
uint32_t block_size;
int full_size;
printf("0390_mandatory_opcodes_sbc:\n");
printf("===========================\n");
@@ -66,63 +62,12 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc16->block_length;
lbpme = rc16->lbpme;
scsi_free_scsi_task(task);
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
return -1;
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
sccs = inq->sccs;
encserv = inq->encserv;
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
printf("Not a SBC device. Skipping test\n");
scsi_free_scsi_task(task);
ret = -2;
goto finished;
}
scsi_free_scsi_task(task);
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
@@ -130,250 +75,202 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url, int data
}
printf("Test FORMAT UNIT ... ");
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test2;
test2:
printf("Test INQUIRY ... ");
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send INQUIRY command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test3;
printf("Test INQUIRY.\n");
if (inquiry(iscsi, lun, 0, 0, 64) == -1) {
ret = -1;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("INQUIRY command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
scsi_free_scsi_task(task);
goto test3;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("Test MAINTENANCE IN ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test4;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test4;
test4:
printf("Test MAINTENANCE OUT ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test5;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test5;
test5:
printf("Test READ CAPACITY10 ... ");
task = iscsi_readcapacity10_sync(iscsi, lun,0 ,0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ CAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test6;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ CAPACITY10 command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
scsi_free_scsi_task(task);
goto test6;
ret = -1;
} else {
printf("[OK]\n");
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test6:
printf("Test READ CAPACITY16 ... ");
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ CAPACITY16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test7;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ CAPACITY16 command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
scsi_free_scsi_task(task);
goto test7;
ret = -1;
} else {
printf("[OK]\n");
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test7:
printf("Test RECEIVE DIAGNOSTIC RESULT ... ");
if (encserv == 0) {
printf("[ENCSERV == 0, SKIPPING TEST]\n");
goto test8;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test8;
test8:
printf("Test REDUNDANCY GROUP IN ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test9;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test9;
test9:
printf("Test REDUNDANCY GROUP OUT ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test10;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test10;
test10:
printf("Test REPORT LUNS ... ");
task = iscsi_reportluns_sync(iscsi, 0, 64);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send REPORT LUNS command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test11;
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("REPORT LUNS command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
scsi_free_scsi_task(task);
goto test11;
ret = -1;
} else {
printf("[OK]\n");
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test11:
printf("Test REQUEST SENSE ... ");
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test12;
test12:
printf("Test SEND DIAGNOSTIC ... ");
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test13;
test13:
printf("Test SPARE IN ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test14;
goto finished;
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test14;
test14:
printf("Test SPARE OUT ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test15;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test15;
test15:
printf("Test TEST UNIT READY.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
if (testunitready(iscsi, lun) == -1) {
ret = -1;
}
printf("Test UNMAP ... ");
if (lbpme == 0) {
printf("[LBPME == 0, SKIPPING TEST]\n");
goto test17;
}
task = iscsi_unmap_sync(iscsi, lun, 0, 0, NULL, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test17;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("UNMAP command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
} else {
task = iscsi_unmap_sync(iscsi, lun, 0, 0, NULL, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("UNMAP command: failed with sense %s\n", iscsi_get_error(iscsi));
ret = -1;
} else {
printf("[OK]\n");
}
scsi_free_scsi_task(task);
goto test17;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test17:
printf("Test VOLUME SET IN ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test18;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test18;
test18:
printf("Test VOLUME SET OUT ... ");
if (sccs == 0) {
printf("[SCCS == 0, SKIPPING TEST]\n");
goto test19;
} else {
printf("[TEST NOT IMPLEMENTED YET]\n");
}
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test19;
test19:
printf("Test WRITE SAME16 ... ");
if (lbpme == 0) {
printf("[LBPME == 0, SKIPPING TEST]\n");
goto test20;
}
task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE SAME16 command: %s\n", iscsi_get_error(iscsi));
ret++;
goto test20;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE SAME16 command: failed with sense %s\n", iscsi_get_error(iscsi));
ret++;
} else {
task = iscsi_writesame16_sync(iscsi, lun, data, block_size, 0, 1, 0, 1, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send WRITE SAME16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITE SAME16 command: failed with sense %s\n", iscsi_get_error(iscsi));
ret = -1;
} else {
printf("[OK]\n");
}
scsi_free_scsi_task(task);
goto test20;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test20:
printf("Test WRITE SAME32 ... ");
printf("[TEST NOT IMPLEMENTED YET]\n");
goto test21;
test21:
finished:
iscsi_logout_sync(iscsi);

Some files were not shown because too many files have changed in this diff Show More