diff --git a/examples/iscsi-dd.c b/examples/iscsi-dd.c index 2639eae..f02f22e 100644 --- a/examples/iscsi-dd.c +++ b/examples/iscsi-dd.c @@ -406,6 +406,7 @@ void cscd_ident_inq(struct iscsi_context *iscsi, tgt_desig = desig; prev_type = desig->designator_type; } + /* fall through */ default: continue; } diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 67f36f2..958dce9 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -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; diff --git a/test-tool/test_async_lu_reset_simple.c b/test-tool/test_async_lu_reset_simple.c index e957a5c..0a9b1cb 100644 --- a/test-tool/test_async_lu_reset_simple.c +++ b/test-tool/test_async_lu_reset_simple.c @@ -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 */ diff --git a/test-tool/test_compareandwrite_miscompare.c b/test-tool/test_compareandwrite_miscompare.c index d3dfec5..19a0c25 100644 --- a/test-tool/test_compareandwrite_miscompare.c +++ b/test-tool/test_compareandwrite_miscompare.c @@ -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); diff --git a/test-tool/test_compareandwrite_simple.c b/test-tool/test_compareandwrite_simple.c index 513aa18..b4b840e 100644 --- a/test-tool/test_compareandwrite_simple.c +++ b/test-tool/test_compareandwrite_simple.c @@ -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); diff --git a/test-tool/test_compareandwrite_unwritten.c b/test-tool/test_compareandwrite_unwritten.c index 6bd6a2c..71ea8d7 100644 --- a/test-tool/test_compareandwrite_unwritten.c +++ b/test-tool/test_compareandwrite_unwritten.c @@ -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]; diff --git a/test-tool/test_extendedcopy_descr_limits.c b/test-tool/test_extendedcopy_descr_limits.c index 5f092c6..22e278f 100644 --- a/test-tool/test_extendedcopy_descr_limits.c +++ b/test-tool/test_extendedcopy_descr_limits.c @@ -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 + diff --git a/test-tool/test_multipathio_compareandwrite.c b/test-tool/test_multipathio_compareandwrite.c index 7378acc..f14da9f 100644 --- a/test-tool/test_multipathio_compareandwrite.c +++ b/test-tool/test_multipathio_compareandwrite.c @@ -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, diff --git a/test-tool/test_prin_report_caps.c b/test-tool/test_prin_report_caps.c index 167730a..705cfb5 100644 --- a/test-tool/test_prin_report_caps.c +++ b/test-tool/test_prin_report_caps.c @@ -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."); diff --git a/test-tool/test_prout_clear_simple.c b/test-tool/test_prout_clear_simple.c index a78f6d2..8bcfe47 100644 --- a/test-tool/test_prout_clear_simple.c +++ b/test-tool/test_prout_clear_simple.c @@ -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 */ }