test-tool: Allow CHECK CONDITION in response to overflow/underflow

According to the RFC 7143 11.4.5.1:
"Targets may set the residual count,and initiators may use
 it when the response code is Command Completed at Target (even if the
 status returned is not GOOD)."

Therefore valid retuned status may be not only GOOD. Also this check:
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT
would make Underflow/Overflow response universal for FC/ISCSI.
This commit is contained in:
Anastasia Kovaleva
2021-01-27 11:58:00 +03:00
parent a2fa59bef0
commit 34fd477ede
3 changed files with 54 additions and 51 deletions

View File

@@ -26,6 +26,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
static int check_status (struct scsi_task *task) {
return (task->status == SCSI_STATUS_GOOD ||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT));
}
void
test_write10_residuals(void)
@@ -33,7 +39,6 @@ test_write10_residuals(void)
struct scsi_task *task_ret;
unsigned char buf[10000];
struct iscsi_data data;
int ok;
unsigned int i;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -75,11 +80,11 @@ test_write10_residuals(void)
return;
}
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -121,11 +126,11 @@ test_write10_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual underflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
@@ -163,15 +168,11 @@ test_write10_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
ok = task->status == SCSI_STATUS_GOOD ||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
if (!ok) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT(ok);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -212,11 +213,11 @@ test_write10_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -265,11 +266,11 @@ test_write10_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual underflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
@@ -337,11 +338,11 @@ test_write10_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {

View File

@@ -26,6 +26,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
static int check_status (struct scsi_task *task) {
return (task->status == SCSI_STATUS_GOOD ||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT));
}
void
test_write12_residuals(void)
@@ -33,7 +39,6 @@ test_write12_residuals(void)
struct scsi_task *task_ret;
unsigned char buf[10000];
struct iscsi_data data;
int ok;
unsigned int i;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -75,11 +80,11 @@ test_write12_residuals(void)
return;
}
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -121,11 +126,11 @@ test_write12_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual underflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
@@ -163,15 +168,11 @@ test_write12_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
ok = task->status == SCSI_STATUS_GOOD ||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
if (!ok) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT(ok);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -212,11 +213,11 @@ test_write12_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -264,11 +265,11 @@ test_write12_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual underflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
@@ -336,11 +337,11 @@ test_write12_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {

View File

@@ -26,6 +26,12 @@
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
static int check_status (struct scsi_task *task) {
return (task->status == SCSI_STATUS_GOOD ||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT));
}
void
test_write16_residuals(void)
@@ -33,7 +39,6 @@ test_write16_residuals(void)
struct scsi_task *task_ret;
unsigned char buf[10000];
struct iscsi_data data;
int ok;
unsigned int i;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -75,11 +80,11 @@ test_write16_residuals(void)
return;
}
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -121,11 +126,11 @@ test_write16_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual underflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
@@ -163,15 +168,11 @@ test_write16_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
ok = task->status == SCSI_STATUS_GOOD ||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
if (!ok) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT(ok);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -212,11 +213,11 @@ test_write16_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
@@ -264,11 +265,11 @@ test_write16_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual underflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
@@ -336,11 +337,11 @@ test_write16_residuals(void)
CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
if (!check_status(task)) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(sd->iscsi_ctx));
}
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
CU_ASSERT(check_status(task));
logging(LOG_VERBOSE, "Verify residual overflow flag is set");
if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {