test: Fix inaccurate mock of poller behavior

This exposes that one of the tests was not expecting
the correct behavior, so also fix that.

Change-Id: Idb73b3ea74950b2e6f959a40e5740375cb76b8c7
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/417364
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Ben Walker 2018-06-29 13:43:29 -07:00 committed by Jim Harris
parent f443bd40e4
commit 2fac05e919
2 changed files with 1 additions and 32 deletions

View File

@ -226,7 +226,7 @@ poll_thread(uintptr_t thread_id)
poller = TAILQ_FIRST(&thread->pollers);
TAILQ_REMOVE(&thread->pollers, poller, tailq);
while (g_current_time_in_us >= poller->next_expiration_in_us) {
if (g_current_time_in_us >= poller->next_expiration_in_us) {
if (poller->fn) {
poller->fn(poller->arg);
}

View File

@ -315,22 +315,11 @@ poller_run_done(void *ctx)
return -1;
}
static int
poller_run_times_done(void *ctx)
{
int *poller_run_times = ctx;
(*poller_run_times)++;
return -1;
}
static void
basic_poller(void)
{
struct spdk_poller *poller = NULL;
bool poller_run = false;
int poller_run_times = 0;
setup_test();
@ -370,26 +359,6 @@ basic_poller(void)
spdk_poller_unregister(&poller);
CU_ASSERT(poller == NULL);
reset_time();
/* Register a poller with 1000us wait time and test multiple execution */
poller = spdk_poller_register(poller_run_times_done, &poller_run_times, 1000);
CU_ASSERT(poller != NULL);
poll_threads();
CU_ASSERT(poller_run_times == 0);
increment_time(1000);
poll_threads();
CU_ASSERT(poller_run_times == 1);
poller_run_times = 0;
increment_time(2000);
poll_threads();
CU_ASSERT(poller_run_times == 2);
spdk_poller_unregister(&poller);
CU_ASSERT(poller == NULL);
teardown_test();
}