-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathChannelBootstrapTest.cpp
40 lines (32 loc) · 1.49 KB
/
ChannelBootstrapTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/Api.h>
#include <aws/testing/aws_test_harness.h>
#include <future>
#include <utility>
static int s_TestClientBootstrapResourceSafety(struct aws_allocator *allocator, void *)
{
{
Aws::Crt::ApiHandle apiHandle(allocator);
Aws::Crt::Io::EventLoopGroup eventLoopGroup(0, allocator);
ASSERT_TRUE(eventLoopGroup);
ASSERT_NOT_NULL(eventLoopGroup.GetUnderlyingHandle());
Aws::Crt::Io::DefaultHostResolver defaultHostResolver(eventLoopGroup, 8, 30, allocator);
ASSERT_TRUE(defaultHostResolver);
ASSERT_NOT_NULL(defaultHostResolver.GetUnderlyingHandle());
std::promise<void> bootstrapShutdownPromise;
std::future<void> bootstrapShutdownFuture = bootstrapShutdownPromise.get_future();
{
Aws::Crt::Io::ClientBootstrap clientBootstrap(eventLoopGroup, defaultHostResolver, allocator);
ASSERT_TRUE(clientBootstrap);
ASSERT_NOT_NULL(clientBootstrap.GetUnderlyingHandle());
clientBootstrap.EnableBlockingShutdown();
clientBootstrap.SetShutdownCompleteCallback([&]() { bootstrapShutdownPromise.set_value(); });
}
ASSERT_TRUE(std::future_status::ready == bootstrapShutdownFuture.wait_for(std::chrono::seconds(10)));
}
return AWS_ERROR_SUCCESS;
}
AWS_TEST_CASE(ClientBootstrapResourceSafety, s_TestClientBootstrapResourceSafety)