Skip to content
Snippets Groups Projects
Commit 3b98b2ee authored by Craig Tiller's avatar Craig Tiller
Browse files

Add a test of an allocation blocked from scavenging

parent 12b925d2
No related branches found
No related tags found
No related merge requests found
...@@ -190,6 +190,45 @@ static void test_scavenge(void) { ...@@ -190,6 +190,45 @@ static void test_scavenge(void) {
destroy_user(&usr2); destroy_user(&usr2);
} }
static void test_scavenge_blocked(void) {
gpr_log(GPR_INFO, "** test_scavenge_blocked **");
grpc_buffer_pool *p = grpc_buffer_pool_create();
grpc_buffer_pool_resize(p, 1024);
grpc_buffer_user usr1;
grpc_buffer_user usr2;
grpc_buffer_user_init(&usr1, p);
grpc_buffer_user_init(&usr2, p);
bool done;
{
done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_buffer_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_buffer_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_buffer_user_free(&exec_ctx, &usr1, 1024);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_buffer_user_free(&exec_ctx, &usr2, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
grpc_buffer_pool_unref(p);
destroy_user(&usr1);
destroy_user(&usr2);
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_init(); grpc_init();
...@@ -201,6 +240,7 @@ int main(int argc, char **argv) { ...@@ -201,6 +240,7 @@ int main(int argc, char **argv) {
test_simple_async_alloc(); test_simple_async_alloc();
test_async_alloc_blocked_by_size(); test_async_alloc_blocked_by_size();
test_scavenge(); test_scavenge();
test_scavenge_blocked();
grpc_shutdown(); grpc_shutdown();
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment