Skip to content

Commit

Permalink
test: Fix pool test
Browse files Browse the repository at this point in the history
uv_run will not terminate until we call pool_fini, since the pool's
async handle will be active.

Signed-off-by: Cole Miller <[email protected]>
  • Loading branch information
cole-miller committed Aug 16, 2024
1 parent ab75812 commit 44ffe40
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/unit/ext/test_uv_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ static void loop_setup(struct fixture *f)

rc = uv_loop_init(&f->loop);
munit_assert_int(rc, ==, 0);

rc = pool_init(&f->pool, &f->loop, 4, POOL_QOS_PRIO_FAIR);
munit_assert_int(rc, ==, 0);
}

static void bottom_work_cb(pool_work_t *w)
Expand All @@ -39,8 +36,10 @@ static void bottom_after_work_cb(pool_work_t *w)
{
static int count = 0;

if (count == WORK_ITEMS_NR)
if (count == WORK_ITEMS_NR) {
pool_close(w->pool);
pool_fini(w->pool);
}

count++;
assert(w->type != WT_BAR);
Expand Down Expand Up @@ -80,7 +79,6 @@ static void threadpool_tear_down(void *data)
int rc;
struct fixture *f = data;

pool_fini(&f->pool);
rc = uv_loop_close(&f->loop);
munit_assert_int(rc, ==, 0);
free(f);
Expand All @@ -104,6 +102,9 @@ TEST_CASE(threadpool, sync, NULL)
struct fixture *f = data;
int rc;

rc = pool_init(&f->pool, &f->loop, 4, POOL_QOS_PRIO_FAIR);
munit_assert_int(rc, ==, 0);

pool_queue_work(&f->pool, &f->w, 0, WT_UNORD, work_cb, after_work_cb);

rc = uv_run(&f->loop, UV_RUN_DEFAULT);
Expand Down

0 comments on commit 44ffe40

Please sign in to comment.