diff --git a/test-tool/test_async_abort_simple.c b/test-tool/test_async_abort_simple.c index 82abb9f..7235d47 100644 --- a/test-tool/test_async_abort_simple.c +++ b/test-tool/test_async_abort_simple.c @@ -55,6 +55,7 @@ test_async_write_cb(struct iscsi_context *iscsi __attribute__((unused)), } } +#if 0 static void test_async_abort_cb(struct iscsi_context *iscsi __attribute__((unused)), int status, void *command_data, @@ -86,13 +87,19 @@ test_async_abort_cb(struct iscsi_context *iscsi __attribute__((unused)), } CU_ASSERT_NOT_EQUAL(status, SCSI_STATUS_CHECK_CONDITION); } +#endif + +extern void +test_async_reset_cb(struct iscsi_context *iscsi __attribute__((unused)), + int status, void *command_data, + void *private_data); void test_async_abort_simple(void) { int ret; struct tests_async_abort_state state = { NULL, 0, 0, 0, 0 }; - int blocks_per_io = 8; + int blocks_per_io = 32768; unsigned char *buf; uint64_t timeout_sec; @@ -146,6 +153,17 @@ test_async_abort_simple(void) } logging(LOG_VERBOSE, "dispatched"); + /* + * queue reset. TMF req should be sent to the target. + */ + ret = iscsi_task_mgmt_async(sd->iscsi_ctx, + state.wtask->lun, ISCSI_TM_LUN_RESET, + 0xffffffff, 0, + test_async_reset_cb, &state); + CU_ASSERT_EQUAL(ret, 0); + + logging(LOG_VERBOSE, "LU RESET queued"); +#if 0 /* * queue abort - shouldn't cancel the dispatched task. TMF req should * be sent to the target. @@ -154,6 +172,7 @@ test_async_abort_simple(void) state.wtask->lun, ISCSI_TM_ABORT_TASK, state.wtask->itt, state.wtask->cmdsn, test_async_abort_cb, &state); + CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "ABORT queued: (RefCmdSN=0x%x, " @@ -200,6 +219,28 @@ test_async_abort_simple(void) } else { CU_FAIL("unexpected WRITE/ABORT state"); } +#endif + logging(LOG_VERBOSE, "Keeping connection alive to observe target state..."); + timeout_sec = test_get_clock_sec() + 3600; /* keep alive for up to an hour */ + while (test_get_clock_sec() <= timeout_sec) { + struct pollfd pfd; + + pfd.fd = iscsi_get_fd(sd->iscsi_ctx); + pfd.events = iscsi_which_events(sd->iscsi_ctx); + + ret = poll(&pfd, 1, 1000); + if (ret < 0) { + break; + } + + if (ret > 0) { + ret = iscsi_service(sd->iscsi_ctx, pfd.revents); + if (ret < 0) { + logging(LOG_NORMAL, "Connection dropped or service failed."); + break; + } + } + } /* Avoid that callbacks get invoked after this test finished */ iscsi_logout_sync(sd->iscsi_ctx); diff --git a/test-tool/test_async_lu_reset_simple.c b/test-tool/test_async_lu_reset_simple.c index 57a4ec4..e03fb0b 100644 --- a/test-tool/test_async_lu_reset_simple.c +++ b/test-tool/test_async_lu_reset_simple.c @@ -56,7 +56,7 @@ test_async_write_cb(struct iscsi_context *iscsi __attribute__((unused)), } } -static void +void test_async_reset_cb(struct iscsi_context *iscsi __attribute__((unused)), int status, void *command_data, void *private_data)