TESTS: Read standard inq page before we spawn the tests
We dont need to call inq so often from the tests if we read the standard page once before the tests begin
This commit is contained in:
@@ -26,8 +26,6 @@ int T0103_read10_rdprotect(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
int full_size;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, i, lun;
|
||||
|
||||
printf("0103_read10_rdprotect:\n");
|
||||
@@ -45,44 +43,11 @@ int T0103_read10_rdprotect(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (inq->protect) {
|
||||
printf("LUN is formatted with protection information. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ int T0104_read10_flags(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun;
|
||||
|
||||
printf("0104_read10_flags:\n");
|
||||
@@ -49,20 +48,8 @@ int T0104_read10_flags(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ int T0202_read16_flags(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret = 0, lun;
|
||||
|
||||
printf("0202_read16_flags:\n");
|
||||
@@ -46,20 +45,8 @@ int T0202_read16_flags(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ int T0212_read12_flags(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret = 0, lun;
|
||||
|
||||
printf("0212_read12_flags:\n");
|
||||
@@ -46,20 +45,8 @@ int T0212_read12_flags(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ int T0222_write16_flags(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret = 0, lun;
|
||||
unsigned char data[4096 * 256];
|
||||
|
||||
@@ -47,20 +46,8 @@ int T0222_write16_flags(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ int T0232_write12_flags(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret = 0, lun;
|
||||
unsigned char data[4096];
|
||||
|
||||
@@ -47,20 +46,8 @@ int T0232_write12_flags(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ int T0292_write10_flags(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret = 0, lun;
|
||||
unsigned char data[4096];
|
||||
|
||||
@@ -47,20 +46,8 @@ int T0292_write10_flags(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,11 @@ int T0300_readonly(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
struct scsi_mode_sense *ms;
|
||||
int ret, lun;
|
||||
unsigned char data[4096];
|
||||
int full_size;
|
||||
struct unmap_list list[1];
|
||||
int full_size;
|
||||
|
||||
ret = -1;
|
||||
|
||||
@@ -67,21 +66,9 @@ int T0300_readonly(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("LUN is not SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* verify the device is readonly */
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0360_startstopunit_simple(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0360_startstopunit_simple:\n");
|
||||
printf("===================\n");
|
||||
@@ -47,32 +45,6 @@ int T0360_startstopunit_simple(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, i, lun, removable;
|
||||
int full_size;
|
||||
int ret, i, lun;
|
||||
|
||||
printf("0361_startstopunit_pwrcnd:\n");
|
||||
printf("===================\n");
|
||||
@@ -45,32 +43,6 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0362_startstopunit_noloej:\n");
|
||||
printf("===================\n");
|
||||
@@ -51,32 +49,6 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0370_nomedia(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
unsigned char buf[4096];
|
||||
|
||||
printf("0370_nomedia:\n");
|
||||
@@ -73,42 +71,13 @@ int T0370_nomedia(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
if (!removable) {
|
||||
printf("Media is not removable. Skipping test.\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
printf("Try to eject the media ... ");
|
||||
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0);
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0380_preventallow_simple(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0380_preventallow_simple:\n");
|
||||
printf("=========================\n");
|
||||
@@ -45,32 +43,6 @@ int T0380_preventallow_simple(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0381_preventallow_eject(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0381_preventallow_eject:\n");
|
||||
printf("========================\n");
|
||||
@@ -47,48 +45,21 @@ int T0381_preventallow_eject(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
if (!removable) {
|
||||
printf("Media is not removable. Skipping tests\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
printf("Try to set PREVENTALLOW ... ");
|
||||
task = iscsi_preventallow_sync(iscsi, lun, 1);
|
||||
if (task == NULL) {
|
||||
|
||||
@@ -25,9 +25,7 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0382_preventallow_itnexus_loss:\n");
|
||||
printf("===============================\n");
|
||||
@@ -49,32 +47,6 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
|
||||
@@ -41,9 +41,7 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
struct mgmt_task mgmt_task = {0, 0};
|
||||
struct pollfd pfd;
|
||||
|
||||
@@ -67,48 +65,21 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
if (!removable) {
|
||||
printf("Media is not removable. Skipping tests\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
printf("Try to set PREVENTALLOW ... ");
|
||||
task = iscsi_preventallow_sync(iscsi, lun, 1);
|
||||
if (task == NULL) {
|
||||
|
||||
@@ -41,9 +41,7 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
struct mgmt_task mgmt_task = {0, 0};
|
||||
struct pollfd pfd;
|
||||
|
||||
@@ -67,47 +65,20 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
if (!removable) {
|
||||
printf("Media is not removable. Skipping tests\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
printf("Try to set PREVENTALLOW ... ");
|
||||
task = iscsi_preventallow_sync(iscsi, lun, 1);
|
||||
|
||||
@@ -41,9 +41,7 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
struct mgmt_task mgmt_task = {0, 0};
|
||||
struct pollfd pfd;
|
||||
|
||||
@@ -67,47 +65,20 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
if (!removable) {
|
||||
printf("Media is not removable. Skipping tests\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
printf("Try to set PREVENTALLOW ... ");
|
||||
task = iscsi_preventallow_sync(iscsi, lun, 1);
|
||||
|
||||
@@ -26,9 +26,7 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url)
|
||||
struct iscsi_context *iscsi;
|
||||
struct iscsi_context *iscsi2 = NULL;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret, lun, removable;
|
||||
int full_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0386_preventallow_2_itl_nexuses:\n");
|
||||
printf("============================\n");
|
||||
@@ -50,41 +48,11 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
if (!removable) {
|
||||
printf("Media is not removable. Skipping tests\n");
|
||||
@@ -92,6 +60,8 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url)
|
||||
goto finished;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
printf("Try to set PREVENTALLOW on 2 different IT_Nexusen ... ");
|
||||
task = iscsi_preventallow_sync(iscsi, lun, 1);
|
||||
|
||||
@@ -25,10 +25,8 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int ret = 0, lun, sccs, encserv;
|
||||
int ret = 0, lun;
|
||||
unsigned char data[4096];
|
||||
int full_size;
|
||||
|
||||
printf("0390_mandatory_opcodes_sbc:\n");
|
||||
printf("===========================\n");
|
||||
@@ -64,39 +62,12 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See how big this inquiry data is */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
sccs = inq->sccs;
|
||||
encserv = inq->encserv;
|
||||
if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
|
||||
printf("Not a SBC device. Skipping test\n");
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
ret = -2;
|
||||
@@ -104,27 +75,14 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url)
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("Test FORMAT UNIT ... ");
|
||||
printf("[TEST NOT IMPLEMENTED YET]\n");
|
||||
|
||||
|
||||
printf("Test INQUIRY ... ");
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command: %s\n", iscsi_get_error(iscsi));
|
||||
printf("Test INQUIRY.\n");
|
||||
if (inquiry(iscsi, lun, 0, 0, 64) == -1) {
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("INQUIRY command: failed with sense %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
} else {
|
||||
printf("[OK]\n");
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
|
||||
printf("Test MAINTENANCE IN ... ");
|
||||
|
||||
@@ -47,6 +47,10 @@ uint64_t num_blocks;
|
||||
int lbpme;
|
||||
int lbppb;
|
||||
int lbpme;
|
||||
int removable;
|
||||
enum scsi_inquiry_peripheral_device_type device_type;
|
||||
int sccs;
|
||||
int encserv;
|
||||
|
||||
int data_loss;
|
||||
int show_info;
|
||||
@@ -1404,6 +1408,30 @@ int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
printf("Send INQUIRY evpd:%d page_code:%d ... ", evpd, page_code);
|
||||
task = iscsi_inquiry_sync(iscsi, lun, evpd, page_code, maxsize);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command: %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("INQUIRY command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("[OK]\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
poptContext pc;
|
||||
@@ -1420,6 +1448,8 @@ int main(int argc, const char *argv[])
|
||||
struct scsi_task *task;
|
||||
struct scsi_readcapacity10 *rc10;
|
||||
struct scsi_readcapacity16 *rc16;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
int full_size;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
{ "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL },
|
||||
@@ -1536,6 +1566,37 @@ int main(int argc, const char *argv[])
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
}
|
||||
|
||||
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) {
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
removable = inq->rmb;
|
||||
device_type = inq->device_type;
|
||||
sccs = inq->sccs;
|
||||
encserv = inq->encserv;
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ extern int lbppb;
|
||||
extern int lbpme;
|
||||
extern int data_loss;
|
||||
extern int show_info;
|
||||
extern int removable;
|
||||
extern enum scsi_inquiry_peripheral_device_type device_type;
|
||||
extern int sccs;
|
||||
extern int encserv;
|
||||
|
||||
struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun);
|
||||
|
||||
@@ -274,5 +278,6 @@ int verify16(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t
|
||||
int verify16_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||
int verify16_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||
int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize);
|
||||
|
||||
#endif /* _ISCSI_TEST_H_ */
|
||||
|
||||
Reference in New Issue
Block a user