diff --git a/test-tool/test_write10_residuals.c b/test-tool/test_write10_residuals.c index 911c39c..a8cbf94 100644 --- a/test-tool/test_write10_residuals.c +++ b/test-tool/test_write10_residuals.c @@ -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) { diff --git a/test-tool/test_write12_residuals.c b/test-tool/test_write12_residuals.c index 02819ba..fb27f9d 100644 --- a/test-tool/test_write12_residuals.c +++ b/test-tool/test_write12_residuals.c @@ -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) { diff --git a/test-tool/test_write16_residuals.c b/test-tool/test_write16_residuals.c index 7088cac..3e48d85 100644 --- a/test-tool/test_write16_residuals.c +++ b/test-tool/test_write16_residuals.c @@ -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) {