From cfce944b355f37199a694ae255a58d24db043890 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 14 Oct 2013 18:22:02 +0200 Subject: [PATCH] test_write*_residuals: Fix overflow tests RFC 3720 is not clear about whether a target should return SUCCESS or CHECK CONDITION if SPDTL > EDTL. Hence accept both. See also Fred Knight, Re: [Ips] Data Out residual overflow/underflow handling, IETF mailing list archive, 21 September 2012 (http://www.ietf.org/mail-archive/web/ips/current/msg02756.html). Signed-off-by: Bart Van Assche --- include/scsi-lowlevel.h | 1 + test-tool/test_write10_residuals.c | 8 ++++++-- test-tool/test_write12_residuals.c | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/scsi-lowlevel.h b/include/scsi-lowlevel.h index 2aa24bb..897444f 100644 --- a/include/scsi-lowlevel.h +++ b/include/scsi-lowlevel.h @@ -177,6 +177,7 @@ EXTERN const char *scsi_sense_key_str(int key); #define SCSI_SENSE_ASCQ_INTERNAL_TARGET_FAILURE 0x4400 #define SCSI_SENSE_ASCQ_MEDIUM_LOAD_OR_EJECT_FAILED 0x5300 #define SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED 0x5302 +#define SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT 0x0e03 EXTERN const char *scsi_sense_ascq_str(int ascq); diff --git a/test-tool/test_write10_residuals.c b/test-tool/test_write10_residuals.c index 0e8f6c5..1e9d1d5 100644 --- a/test-tool/test_write10_residuals.c +++ b/test-tool/test_write10_residuals.c @@ -161,11 +161,15 @@ test_write10_residuals(void) CU_ASSERT_PTR_NOT_NULL(task_ret); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); - if (task->status != SCSI_STATUS_GOOD) { + if (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)) { logging(LOG_VERBOSE, "[FAILED] Target returned error %s", iscsi_get_error(iscsic)); + CU_ASSERT(0); } - CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); logging(LOG_VERBOSE, "Verify residual overflow flag is set"); if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) { diff --git a/test-tool/test_write12_residuals.c b/test-tool/test_write12_residuals.c index c9e4c78..4e278e6 100644 --- a/test-tool/test_write12_residuals.c +++ b/test-tool/test_write12_residuals.c @@ -161,11 +161,16 @@ test_write12_residuals(void) CU_ASSERT_PTR_NOT_NULL(task_ret); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); - if (task->status != SCSI_STATUS_GOOD) { + if (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)) + { logging(LOG_VERBOSE, "[FAILED] Target returned error %s", iscsi_get_error(iscsic)); + CU_ASSERT(0); } - CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); logging(LOG_VERBOSE, "Verify residual overflow flag is set"); if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {