From 9d4b38bf5907641b79d939d3b126f62e349e0fbf Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Fri, 18 Aug 2023 18:09:42 -0700 Subject: [PATCH] revert test --- tests/v5/mqtt5_to_mqtt3_adapter_tests.c | 32 ++++++++++--------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/tests/v5/mqtt5_to_mqtt3_adapter_tests.c b/tests/v5/mqtt5_to_mqtt3_adapter_tests.c index 49a85336..8c85e884 100644 --- a/tests/v5/mqtt5_to_mqtt3_adapter_tests.c +++ b/tests/v5/mqtt5_to_mqtt3_adapter_tests.c @@ -30,6 +30,7 @@ enum aws_mqtt3_lifecycle_event_type { AWS_MQTT3_LET_DISCONNECTION_COMPLETE, AWS_MQTT3_LET_CONNECTION_SUCCESS, AWS_MQTT3_LET_CONNECTION_FAILURE, + AWS_MQTT3_LET_TERMINATION, }; struct aws_mqtt3_lifecycle_event { @@ -166,11 +167,6 @@ static bool s_aws_mqtt3_operation_event_equals( } struct aws_mqtt5_to_mqtt3_adapter_test_fixture { - - bool connection_terminated; - - size_t connection_terminated_count; - struct aws_mqtt5_client_mock_test_fixture mqtt5_fixture; struct aws_mqtt_client_connection *connection; @@ -294,18 +290,6 @@ static void s_wait_for_n_adapter_operation_events( aws_mutex_unlock(&fixture->lock); } -static bool s_is_termination_callback_invoked(void *context) { - struct aws_mqtt5_to_mqtt3_adapter_test_fixture *fixture = context; - return fixture->connection_terminated; -} - -static void s_wait_for_termination_callback(struct aws_mqtt5_to_mqtt3_adapter_test_fixture *fixture) { - aws_mutex_lock(&fixture->lock); - aws_condition_variable_wait_pred(&fixture->signal, &fixture->lock, s_is_termination_callback_invoked, fixture); - aws_mutex_unlock(&fixture->lock); - aws_condition_variable_notify_all(&fixture->signal); -} - struct n_lifeycle_event_wait_context { struct aws_mqtt5_to_mqtt3_adapter_test_fixture *fixture; enum aws_mqtt3_lifecycle_event_type type; @@ -460,10 +444,18 @@ static void s_aws_mqtt5_to_mqtt3_adapter_test_fixture_closed_handler( static void s_aws_mqtt5_to_mqtt3_adapter_test_fixture_termination_handler(void *userdata) { struct aws_mqtt5_to_mqtt3_adapter_test_fixture *fixture = userdata; + + /* record the event */ + struct aws_mqtt3_lifecycle_event event; + AWS_ZERO_STRUCT(event); + + event.type = AWS_MQTT3_LET_TERMINATION; + aws_high_res_clock_get_ticks(&event.timestamp); + aws_mutex_lock(&fixture->lock); - fixture->connection_terminated_count += 1; - fixture->connection_terminated = true; + aws_array_list_push_back(&fixture->lifecycle_events, &event); aws_mutex_unlock(&fixture->lock); + aws_condition_variable_notify_all(&fixture->signal); } static void s_aws_mqtt5_to_mqtt3_adapter_test_fixture_interrupted_handler( @@ -650,7 +642,7 @@ int aws_mqtt5_to_mqtt3_adapter_test_fixture_init( void aws_mqtt5_to_mqtt3_adapter_test_fixture_clean_up(struct aws_mqtt5_to_mqtt3_adapter_test_fixture *fixture) { aws_mqtt_client_connection_release(fixture->connection); - s_wait_for_termination_callback(fixture); + s_wait_for_n_adapter_lifecycle_events(fixture, AWS_MQTT3_LET_TERMINATION, 1); aws_mqtt5_client_mock_test_fixture_clean_up(&fixture->mqtt5_fixture);