Merge pull request #263 from bvanassche/master
Various fixes for the libiscsi test tool
This commit is contained in:
@@ -406,6 +406,7 @@ void cscd_ident_inq(struct iscsi_context *iscsi,
|
||||
tgt_desig = desig;
|
||||
prev_type = desig->designator_type;
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -204,9 +204,9 @@ static int check_result(const char *opcode, struct scsi_device *sdev,
|
||||
return -2;
|
||||
}
|
||||
if (status == SCSI_STATUS_GOOD && task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] %s command failed with "
|
||||
"sense. %s(0x%02x)/%s(0x%04x)",
|
||||
opcode,
|
||||
logging(LOG_NORMAL,
|
||||
"[FAILED] %s command failed with status %d / sense key %s(0x%02x) / ASCQ %s(0x%04x)",
|
||||
opcode, task->status,
|
||||
scsi_sense_key_str(task->sense.key), task->sense.key,
|
||||
scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
|
||||
return -1;
|
||||
|
||||
@@ -33,6 +33,8 @@ struct tests_async_reset_state {
|
||||
uint32_t reset_ok;
|
||||
};
|
||||
|
||||
static int reconnect_succeeded;
|
||||
|
||||
static void
|
||||
test_async_write_cb(struct iscsi_context *iscsi __attribute__((unused)),
|
||||
int status, void *command_data,
|
||||
@@ -63,7 +65,9 @@ test_async_reset_cb(struct iscsi_context *iscsi __attribute__((unused)),
|
||||
struct tests_async_reset_state *state = private_data;
|
||||
|
||||
/* command_data NULL if a reconnect occured. see iscsi_reconnect_cb() */
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(command_data);
|
||||
reconnect_succeeded = command_data != NULL;
|
||||
if (!reconnect_succeeded)
|
||||
return;
|
||||
tmf_response = *(uint32_t *)command_data;
|
||||
|
||||
logging(LOG_VERBOSE, "LU RESET: TMF response %d for"
|
||||
@@ -150,6 +154,9 @@ test_async_lu_reset_simple(void)
|
||||
0xffffffff, 0,
|
||||
test_async_reset_cb, &state);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
CU_ASSERT_EQUAL(reconnect_succeeded, 1);
|
||||
if (!reconnect_succeeded)
|
||||
goto out;
|
||||
|
||||
logging(LOG_VERBOSE, "LU RESET queued");
|
||||
|
||||
@@ -191,6 +198,7 @@ test_async_lu_reset_simple(void)
|
||||
CU_FAIL("unexpected WRITE/RESET state");
|
||||
}
|
||||
|
||||
out:
|
||||
scsi_free_scsi_task(state.wtask);
|
||||
|
||||
/* Avoid that callbacks get invoked after this test finished */
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
void
|
||||
test_compareandwrite_miscompare(void)
|
||||
{
|
||||
int i;
|
||||
int i, n;
|
||||
unsigned j;
|
||||
int maxbl;
|
||||
|
||||
@@ -44,10 +44,16 @@ test_compareandwrite_miscompare(void)
|
||||
/* Assume we are not limited */
|
||||
maxbl = 256;
|
||||
}
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN. One Byte miscompare in the final block.");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"start of the LUN. One Byte miscompare in the final block.",
|
||||
n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
@@ -98,9 +104,9 @@ test_compareandwrite_miscompare(void)
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"end of the LUN");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"end of the LUN", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
|
||||
i, num_blocks - i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
void
|
||||
test_compareandwrite_simple(void)
|
||||
{
|
||||
int i;
|
||||
int i, n;
|
||||
unsigned j;
|
||||
int maxbl;
|
||||
|
||||
@@ -45,10 +45,16 @@ test_compareandwrite_simple(void)
|
||||
maxbl = 256;
|
||||
}
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
if (maxbl + 0U > num_blocks)
|
||||
maxbl = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"start of the LUN", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
@@ -97,9 +103,9 @@ test_compareandwrite_simple(void)
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"end of the LUN");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"end of the LUN", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
|
||||
i, num_blocks - i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
@@ -115,7 +121,7 @@ test_compareandwrite_simple(void)
|
||||
"BlockLimits.MaximumCompareAndWriteLength(%d). "
|
||||
"Command should fail with INVALID_FIELD_IN_CDB",
|
||||
i, maxbl);
|
||||
COMPAREANDWRITE(sd, 0,
|
||||
COMPAREANDWRITE(sd, num_blocks - i,
|
||||
scratch, 2 * i * block_size,
|
||||
block_size, 0, 0, 0, 0,
|
||||
EXPECT_INVALID_FIELD_IN_CDB);
|
||||
|
||||
@@ -32,15 +32,19 @@
|
||||
void
|
||||
test_compareandwrite_unwritten(void)
|
||||
{
|
||||
int i;
|
||||
int i, n;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN, 1 block at a time");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"start of the LUN, 1 block at a time", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
int caw_ret;
|
||||
unsigned char read_buf[block_size];
|
||||
|
||||
|
||||
@@ -69,6 +69,10 @@ test_extendedcopy_descr_limits(void)
|
||||
RECEIVE_COPY_RESULTS(&edl_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
|
||||
(void **)&opp, EXPECT_STATUS_GOOD);
|
||||
|
||||
CU_ASSERT_NOT_EQUAL(opp, NULL);
|
||||
if (!opp)
|
||||
return;
|
||||
|
||||
/* Allocate buffer to accommodate (MAX+1) target and
|
||||
* segment descriptors */
|
||||
alloc_len = XCOPY_DESC_OFFSET +
|
||||
|
||||
@@ -34,7 +34,7 @@ test_multipathio_compareandwrite(void)
|
||||
{
|
||||
int io_bl = 1; /* 1 block CAW IOs */
|
||||
int path;
|
||||
int i, ret;
|
||||
int i, n, ret;
|
||||
int maxbl;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
@@ -52,6 +52,10 @@ test_multipathio_compareandwrite(void)
|
||||
return;
|
||||
}
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Initialising data prior to COMPARE_AND_WRITE");
|
||||
|
||||
@@ -66,7 +70,7 @@ test_multipathio_compareandwrite(void)
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test multipath COMPARE_AND_WRITE");
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (i = 0; i <= n; i++) {
|
||||
|
||||
for (path = 0; path < mp_num_sds; path++) {
|
||||
logging(LOG_VERBOSE,
|
||||
|
||||
@@ -51,7 +51,7 @@ test_prin_report_caps_simple(void)
|
||||
int ret = 0;
|
||||
const unsigned long long key = rand_key();
|
||||
struct scsi_task *tsk;
|
||||
struct scsi_persistent_reserve_in_report_capabilities *rcaps;
|
||||
struct scsi_persistent_reserve_in_report_capabilities *rcaps = NULL;
|
||||
struct test_prin_report_caps_types *type;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
@@ -71,6 +71,10 @@ test_prin_report_caps_simple(void)
|
||||
|
||||
ret = prin_report_caps(sd, &tsk, &rcaps);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
CU_ASSERT_NOT_EQUAL(rcaps, NULL);
|
||||
|
||||
if (!rcaps)
|
||||
return;
|
||||
|
||||
logging(LOG_VERBOSE,
|
||||
"Checking PERSISTENT RESERVE IN REPORT CAPABILITIES fields.");
|
||||
|
||||
@@ -33,7 +33,7 @@ test_prout_clear_simple(void)
|
||||
uint32_t old_gen;
|
||||
const unsigned long long key = rand_key();
|
||||
struct scsi_task *tsk;
|
||||
struct scsi_persistent_reserve_in_read_keys *rk;
|
||||
struct scsi_persistent_reserve_in_read_keys *rk = NULL;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
|
||||
@@ -51,6 +51,9 @@ test_prout_clear_simple(void)
|
||||
|
||||
ret = prin_read_keys(sd, &tsk, &rk);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
CU_ASSERT_NOT_EQUAL(rk, NULL);
|
||||
if (!rk)
|
||||
goto out;
|
||||
|
||||
CU_ASSERT_NOT_EQUAL(rk->num_keys, 0);
|
||||
/* retain PR generation number to check for increments */
|
||||
@@ -78,11 +81,15 @@ test_prout_clear_simple(void)
|
||||
|
||||
ret = prin_read_keys(sd, &tsk, &rk);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
CU_ASSERT_NOT_EQUAL(rk, NULL);
|
||||
if (!rk)
|
||||
goto out;
|
||||
|
||||
CU_ASSERT_EQUAL(rk->num_keys, 0);
|
||||
/* generation incremented once for CLEAR (not for RESERVE) */
|
||||
CU_ASSERT_EQUAL(rk->prgeneration, old_gen + 1);
|
||||
|
||||
out:
|
||||
scsi_free_scsi_task(tsk);
|
||||
rk = NULL; /* freed with tsk */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user