test-tool, residuals: Rename struct residuals_test_data members
Bring the names of these struture members closer to the names used in the SCSI and iSCSI standards. Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
@@ -32,21 +32,45 @@ test_write10_residuals(void)
|
||||
{
|
||||
/* testing scenarios */
|
||||
const struct residuals_test_data write10_residuals[] = {
|
||||
/* cdb_size, xfer_len, buf_len, residuals_kind, residuals_amount */
|
||||
{10, 1, 0, SCSI_RESIDUAL_OVERFLOW, block_size,
|
||||
"Try writing one block but with iSCSI expected transfer length==0"},
|
||||
{.cdb_size = 10,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 0,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==0"},
|
||||
|
||||
{10, 1, 2 * block_size, SCSI_RESIDUAL_UNDERFLOW, block_size,
|
||||
{.cdb_size = 10,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 2 * block_size,
|
||||
.residual_type = SCSI_RESIDUAL_UNDERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing one block but set iSCSI EDTL to 2 blocks"},
|
||||
|
||||
{10, 2, block_size, SCSI_RESIDUAL_OVERFLOW, block_size,
|
||||
{.cdb_size = 10,
|
||||
.xfer_len = 2,
|
||||
.buf_len = block_size,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing two blocks but set iSCSI EDTL to 1 block"},
|
||||
|
||||
{10, 1, 10000, SCSI_RESIDUAL_UNDERFLOW, 10000 - block_size,
|
||||
"Try writing one block but with iSCSI expected transfer length==10000"},
|
||||
{.cdb_size = 10,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 10000,
|
||||
.residual_type = SCSI_RESIDUAL_UNDERFLOW,
|
||||
.residual = 10000 - block_size,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==10000"},
|
||||
|
||||
{10, 1, 200, SCSI_RESIDUAL_OVERFLOW, block_size - 200,
|
||||
"Try writing one block but with iSCSI expected transfer length==200"},
|
||||
{.cdb_size = 10,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 200,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size - 200,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==200"},
|
||||
};
|
||||
|
||||
unsigned int i = 0;
|
||||
@@ -66,7 +90,7 @@ test_write10_residuals(void)
|
||||
iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(write10_residuals); i++) {
|
||||
logging(LOG_VERBOSE, "\n%s", write10_residuals[i].log_messages);
|
||||
logging(LOG_VERBOSE, "\n%s", write10_residuals[i].description);
|
||||
write_residuals_test(&write10_residuals[i]);
|
||||
|
||||
if (!command_is_implemented) {
|
||||
|
||||
@@ -32,21 +32,45 @@ test_write12_residuals(void)
|
||||
{
|
||||
/* testing scenarios */
|
||||
const struct residuals_test_data write12_residuals[] = {
|
||||
/* cdb_size, xfer_len, buf_len, residuals_kind, residuals_amount */
|
||||
{12, 1, 0, SCSI_RESIDUAL_OVERFLOW, block_size,
|
||||
"Try writing one block but with iSCSI expected transfer length==0"},
|
||||
{.cdb_size = 12,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 0,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==0"},
|
||||
|
||||
{12, 1, 2 * block_size, SCSI_RESIDUAL_UNDERFLOW, block_size,
|
||||
{.cdb_size = 12,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 2 * block_size,
|
||||
.residual_type = SCSI_RESIDUAL_UNDERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing one block but set iSCSI EDTL to 2 blocks"},
|
||||
|
||||
{12, 2, block_size, SCSI_RESIDUAL_OVERFLOW, block_size,
|
||||
{.cdb_size = 12,
|
||||
.xfer_len = 2,
|
||||
.buf_len = block_size,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing two blocks but set iSCSI EDTL to 1 block"},
|
||||
|
||||
{12, 1, 10000, SCSI_RESIDUAL_UNDERFLOW, 10000 - block_size,
|
||||
"Try writing one block but with iSCSI expected transfer length==10000"},
|
||||
{.cdb_size = 12,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 10000,
|
||||
.residual_type = SCSI_RESIDUAL_UNDERFLOW,
|
||||
.residual = 10000 - block_size,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==10000"},
|
||||
|
||||
{12, 1, 200, SCSI_RESIDUAL_OVERFLOW, block_size - 200,
|
||||
"Try writing one block but with iSCSI expected transfer length==200"},
|
||||
{.cdb_size = 12,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 200,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size - 200,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==200"},
|
||||
};
|
||||
|
||||
unsigned int i = 0;
|
||||
@@ -66,7 +90,7 @@ test_write12_residuals(void)
|
||||
iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(write12_residuals); i++) {
|
||||
logging(LOG_VERBOSE, "\n%s", write12_residuals[i].log_messages);
|
||||
logging(LOG_VERBOSE, "\n%s", write12_residuals[i].description);
|
||||
write_residuals_test(&write12_residuals[i]);
|
||||
|
||||
if (!command_is_implemented) {
|
||||
|
||||
@@ -32,21 +32,45 @@ test_write16_residuals(void)
|
||||
{
|
||||
/* testing scenarios */
|
||||
const struct residuals_test_data write16_residuals[] = {
|
||||
/* cdb_size, xfer_len, buf_len, residuals_kind, residuals_amount */
|
||||
{16, 1, 0, SCSI_RESIDUAL_OVERFLOW, block_size,
|
||||
"Try writing one block but with iSCSI expected transfer length==0"},
|
||||
{.cdb_size = 16,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 0,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==0"},
|
||||
|
||||
{16, 1, 2 * block_size, SCSI_RESIDUAL_UNDERFLOW, block_size,
|
||||
{.cdb_size = 16,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 2 * block_size,
|
||||
.residual_type = SCSI_RESIDUAL_UNDERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing one block but set iSCSI EDTL to 2 blocks"},
|
||||
|
||||
{16, 2, block_size, SCSI_RESIDUAL_OVERFLOW, block_size,
|
||||
{.cdb_size = 16,
|
||||
.xfer_len = 2,
|
||||
.buf_len = block_size,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size,
|
||||
.description =
|
||||
"Try writing two blocks but set iSCSI EDTL to 1 block"},
|
||||
|
||||
{16, 1, 10000, SCSI_RESIDUAL_UNDERFLOW, 10000 - block_size,
|
||||
"Try writing one block but with iSCSI expected transfer length==10000"},
|
||||
{.cdb_size = 16,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 10000,
|
||||
.residual_type = SCSI_RESIDUAL_UNDERFLOW,
|
||||
.residual = 10000 - block_size,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==10000"},
|
||||
|
||||
{16, 1, 200, SCSI_RESIDUAL_OVERFLOW, block_size - 200,
|
||||
"Try writing one block but with iSCSI expected transfer length==200"},
|
||||
{.cdb_size = 16,
|
||||
.xfer_len = 1,
|
||||
.buf_len = 200,
|
||||
.residual_type = SCSI_RESIDUAL_OVERFLOW,
|
||||
.residual = block_size - 200,
|
||||
.description =
|
||||
"Try writing one block but with iSCSI EDTL==200"},
|
||||
};
|
||||
|
||||
unsigned int i = 0;
|
||||
@@ -66,7 +90,7 @@ test_write16_residuals(void)
|
||||
iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(write16_residuals); i++) {
|
||||
logging(LOG_VERBOSE, "\n%s", write16_residuals[i].log_messages);
|
||||
logging(LOG_VERBOSE, "\n%s", write16_residuals[i].description);
|
||||
write_residuals_test(&write16_residuals[i]);
|
||||
|
||||
if (!command_is_implemented) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -43,7 +44,7 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
unsigned int i;
|
||||
unsigned int transfer_length;
|
||||
unsigned int scsi_opcode_write = SCSI_OPCODE_WRITE10;
|
||||
const char *residual = tdata->residuals_kind == SCSI_RESIDUAL_OVERFLOW ? "overflow" : "underflow";
|
||||
const char *residual = tdata->residual_type == SCSI_RESIDUAL_OVERFLOW ? "overflow" : "underflow";
|
||||
|
||||
switch (tdata->cdb_size) {
|
||||
case 10:
|
||||
@@ -138,20 +139,20 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
CU_ASSERT(ok);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify residual %s flag is set", residual);
|
||||
if (task->residual_status != tdata->residuals_kind) {
|
||||
if (task->residual_status != tdata->residual_type) {
|
||||
logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
|
||||
"%s flag", residual);
|
||||
}
|
||||
CU_ASSERT_EQUAL(task->residual_status, tdata->residuals_kind);
|
||||
CU_ASSERT_EQUAL(task->residual_status, tdata->residual_type);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify we got %zu bytes of residual %s",
|
||||
tdata->residuals_amount, residual);
|
||||
if (task->residual != tdata->residuals_amount) {
|
||||
tdata->residual, residual);
|
||||
if (task->residual != tdata->residual) {
|
||||
logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
|
||||
"amount of residual. Expected %zu but got %zu.",
|
||||
tdata->residuals_amount, task->residual);
|
||||
tdata->residual, task->residual);
|
||||
}
|
||||
CU_ASSERT_EQUAL(task->residual, tdata->residuals_amount);
|
||||
CU_ASSERT_EQUAL(task->residual, tdata->residual);
|
||||
scsi_free_scsi_task(task);
|
||||
task = NULL;
|
||||
|
||||
@@ -181,7 +182,7 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
|
||||
if (status.status == SCSI_STATUS_GOOD) {
|
||||
|
||||
switch (tdata->residuals_kind) {
|
||||
switch (tdata->residual_type) {
|
||||
case SCSI_RESIDUAL_OVERFLOW:
|
||||
logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL "
|
||||
"then we only write iSCSI EDTL amount of data");
|
||||
@@ -190,6 +191,8 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL "
|
||||
"then we only write SCSI TL amount of data");
|
||||
break;
|
||||
case SCSI_RESIDUAL_NO_RESIDUAL:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that the first %d bytes were "
|
||||
@@ -233,7 +236,7 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
truncation point should not be overwritten */
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that the last %ld bytes were NOT "
|
||||
"overwritten and still contain 'a'", tdata->residuals_amount);
|
||||
"overwritten and still contain 'a'", tdata->residual);
|
||||
for (i = expected_write_size; i < max_len; i++) {
|
||||
if (scratch[i] != 'a') {
|
||||
logging(LOG_NORMAL, "Data was overwritten "
|
||||
|
||||
@@ -20,21 +20,24 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "scsi-lowlevel.h"
|
||||
|
||||
struct residuals_test_data {
|
||||
size_t cdb_size; /* The size of CDB in bytes */
|
||||
size_t cdb_size; /* CDB size in bytes */
|
||||
|
||||
unsigned int xfer_len; /* The number of logical blocks of
|
||||
data that shall be transferred */
|
||||
/*
|
||||
* Value of the CDB TRANSFER LENGTH field. The unit of this field is one
|
||||
* logical block.
|
||||
*/
|
||||
unsigned int xfer_len;
|
||||
|
||||
unsigned int buf_len; /* Expected Data Transfer Length */
|
||||
unsigned int buf_len; /* Expected Data Transfer Length in bytes. */
|
||||
|
||||
unsigned int residuals_kind; /* Overflow or Underflow as in
|
||||
enum scsi_residual */
|
||||
enum scsi_residual residual_type; /* SCSI_RESIDUAL_UNDERFLOW or OVERFLOW */
|
||||
|
||||
size_t residuals_amount; /* The amount of residual data in bytes */
|
||||
size_t residual; /* Number of residual bytes */
|
||||
|
||||
const char *log_messages; /* Test case description */
|
||||
const char *description; /* Test case description */
|
||||
};
|
||||
|
||||
struct task_status {
|
||||
|
||||
Reference in New Issue
Block a user