31 unsigned char *stack_buff =
new unsigned char[128 * 1024];
38 copp::stack_context test_move_alloc;
40 copp::allocator::stack_allocator_memory alloc_created(stack_buff, 128 * 1024);
41 copp::allocator::stack_allocator_memory alloc(alloc_created);
43 alloc_created.allocate(test_move_alloc, 64 * 1024);
46 test_context_base_coroutine_context_test_type::ptr_t co =
47 test_context_base_coroutine_context_test_type::create(&runner, alloc);
52 CASE_EXPECT_EQ(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_NOT_RUNNING, co->yield());
63 CASE_EXPECT_EQ(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_NOT_READY, co->resume());
64 CASE_EXPECT_EQ(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_ALREADY_EXIST, co->yield());
69 copp::stack_context test_move_alloc;
71 copp::allocator::stack_allocator_memory alloc_created;
72 alloc_created.attach(stack_buff, 128 * 1024);
73 copp::allocator::stack_allocator_memory alloc;
74 alloc = alloc_created;
76 alloc_created.allocate(test_move_alloc, 64 * 1024);
79 test_context_base_coroutine_context_test_type::ptr_t co =
80 test_context_base_coroutine_context_test_type::create(&runner, alloc);
85 CASE_EXPECT_EQ(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_NOT_RUNNING, co->yield());
96 CASE_EXPECT_EQ(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_NOT_READY, co->resume());
97 CASE_EXPECT_EQ(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_ALREADY_EXIST, co->yield());
135CASE_TEST(coroutine, coroutine_context_container_create_failed) {
136 unsigned char *stack_buff =
new unsigned char[128 * 1024];
140 copp::stack_context test_move_alloc;
142 copp::allocator::stack_allocator_memory alloc_created(stack_buff, 128 * 1024);
143 copp::allocator::stack_allocator_memory alloc(alloc_created);
145 alloc_created.allocate(test_move_alloc, 64 * 1024);
148 test_context_base_coroutine_context_test_type::ptr_t co =
149 test_context_base_coroutine_context_test_type::create(&runner, alloc, 32 * 1024, 16 * 1024, 16 * 1024);
157 unsigned char *stack_buff =
new unsigned char[128 * 1024];
159 copp::coroutine_context *placement_new_addr =
reinterpret_cast<copp::coroutine_context *
>(stack_buff + 112 * 1024);
162 copp::stack_context callee_stack;
163 callee_stack.sp =
reinterpret_cast<void *
>(stack_buff + 120 * 1024);
164 callee_stack.size = 120 * 1024;
167 copp::coroutine_context::create(
nullptr, std::move(runner), callee_stack, 4096, 4096));
171 copp::stack_context callee_stack;
172 callee_stack.sp =
reinterpret_cast<void *
>(stack_buff + 120 * 1024);
173 callee_stack.size = 120 * 1024;
176 copp::coroutine_context::create(placement_new_addr, std::move(runner), callee_stack, 4096, 4095));
180 copp::stack_context callee_stack;
181 callee_stack.sp =
reinterpret_cast<void *
>(stack_buff + 120 * 1024);
182 callee_stack.size = 120 * 1024;
185 copp::coroutine_context::create(placement_new_addr, std::move(runner), callee_stack, 4095, 4096));
189 copp::stack_context callee_stack;
190 callee_stack.sp =
nullptr;
191 callee_stack.size = 120 * 1024;
194 copp::coroutine_context::create(placement_new_addr, std::move(runner), callee_stack, 4096, 4096));
198 copp::stack_context callee_stack;
199 callee_stack.sp =
reinterpret_cast<void *
>(stack_buff + 120 * 1024);
200 callee_stack.size = 8192;
203 copp::coroutine_context::create(placement_new_addr, std::move(runner), callee_stack, 4096, 4096));
207 copp::stack_context callee_stack;
208 callee_stack.sp =
reinterpret_cast<void *
>(stack_buff + 120 * 1024);
209 callee_stack.size = 120 * 1024;
211 copp::coroutine_context *placement_invalid_addr =
212 reinterpret_cast<copp::coroutine_context *
>(stack_buff + 116 * 1024);
213 CASE_EXPECT_EQ(copp::COPP_EC_ARGS_ERROR, copp::coroutine_context::create(placement_invalid_addr, std::move(runner),
214 callee_stack, 4096, 4096));
static int g_test_coroutine_base_status
copp::coroutine_context_container< copp::allocator::stack_allocator_memory > test_context_base_coroutine_context_test_type