Skip to content

Commit

Permalink
Use managed thread in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfodagain committed Dec 29, 2023
1 parent d615464 commit 8e44180
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/secure_tunnel_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ struct aws_secure_tunnel_mock_test_fixture {
int error_code;
} on_send_message_complete_result;

struct aws_thread host_resolver_thread;
bool host_resolver_thread_executed;
};

Expand Down Expand Up @@ -1078,15 +1077,16 @@ int aws_websocket_client_connect_fail_in_another_thread_fn(
test_fixture->websocket_function_table->on_incoming_frame_payload_fn = options->on_incoming_frame_payload;
test_fixture->websocket_function_table->on_incoming_frame_complete_fn = options->on_incoming_frame_complete;

if (aws_thread_init(&test_fixture->host_resolver_thread, test_fixture->allocator)) {
struct aws_thread host_resolver_thread;
if (aws_thread_init(&host_resolver_thread, test_fixture->allocator)) {
AWS_LOGF_ERROR(AWS_LS_HTTP_WEBSOCKET_SETUP, "id=static: Failed to initialize thread.");
return aws_raise_error(AWS_ERROR_HTTP_UNKNOWN);
}

struct aws_thread_options thread_options = *aws_default_thread_options();
thread_options.name = aws_byte_cursor_from_c_str("HostResolver");
thread_options.join_strategy = AWS_TJS_MANAGED;

if (aws_thread_launch(&test_fixture->host_resolver_thread, s_host_resolver_thread, test_fixture, &thread_options) !=
if (aws_thread_launch(&host_resolver_thread, s_host_resolver_thread, test_fixture, &thread_options) !=
AWS_OP_SUCCESS) {
AWS_LOGF_ERROR(AWS_LS_HTTP_WEBSOCKET_SETUP, "id=static: Failed to launch thread.");
return aws_raise_error(AWS_ERROR_HTTP_UNKNOWN);
Expand Down Expand Up @@ -1145,9 +1145,6 @@ static int s_secure_tunneling_fail_ws_in_another_thread_test_fn(struct aws_alloc
s_wait_for_connection_failed(&test_fixture);
ASSERT_SUCCESS(aws_secure_tunnel_stop(secure_tunnel));

ASSERT_SUCCESS(aws_thread_join(&test_fixture.host_resolver_thread));
aws_thread_clean_up(&test_fixture.host_resolver_thread);

ASSERT_TRUE(test_fixture.host_resolver_thread_executed);

aws_secure_tunnel_mock_test_clean_up(&test_fixture);
Expand Down

0 comments on commit 8e44180

Please sign in to comment.