Ejemplo n.º 1
0
    error = kaa_user_manager_create(&user_manager, status, channel_manager, logger);
    if (error || !user_manager) {
        return error;
    }

    kaa_attachment_status_listeners_t listeners = { NULL, &on_attached, &on_detached, &on_attach_success, &on_attach_failed };
    error = kaa_user_manager_set_attachment_listeners(user_manager, &listeners);
    if (error) {
        return error;
    }

    return 0;
}

int test_deinit(void)
{
    kaa_user_manager_destroy(user_manager);
    kaa_channel_manager_destroy(channel_manager);
    kaa_status_destroy(status);
    kaa_log_destroy(logger);

    return 0;
}

KAA_SUITE_MAIN(Log, test_init, test_deinit
       ,
       KAA_TEST_CASE(specified_user_verifier, test_specified_user_verifier)
       KAA_TEST_CASE(process_success_response, test_success_response)
       KAA_TEST_CASE(process_failed_response, test_failed_response)
        )
Ejemplo n.º 2
0
    return 0;
}



int test_deinit(void)
{
    kaa_channel_manager_destroy(channel_manager);
    kaa_status_destroy(status);
    kaa_log_destroy(logger);

    return 0;
}

KAA_SUITE_MAIN(Log, test_init, test_deinit,
        KAA_TEST_CASE(create_request, test_create_request)
        KAA_TEST_CASE(process_response, test_response)
        KAA_TEST_CASE(process_timeout, test_timeout)
        KAA_TEST_CASE(decline_timeout, test_decline_timeout)
        KAA_TEST_CASE(max_parallel_uploads_with_log_sync, test_max_parallel_uploads_with_log_sync)
        KAA_TEST_CASE(max_parallel_uploads_with_sync_all, test_max_parallel_uploads_with_sync_all)
        KAA_RUN_TEST(log_setters, set_strategy_invalid_parameters)
        KAA_RUN_TEST(log_setters, set_strategy_valid_parameters)
        KAA_RUN_TEST(log_setters, set_storage_invalid_parameters)
        KAA_RUN_TEST(log_setters, set_storage_valid_parameters)
        KAA_RUN_TEST(log_callback_basic, valid_parameters)
        KAA_RUN_TEST(log_callback_basic, invalid_parameters)
        KAA_RUN_TEST(log_callback_basic, valid_parameters)
        KAA_RUN_TEST(log_callback_with_storage, on_success_called)
        KAA_RUN_TEST(log_callback_with_storage, on_fail_called)
        KAA_RUN_TEST(log_callback_with_storage, on_fail_and_success_called)
Ejemplo n.º 3
0
    uint32_t read_extension_payload_length = 0;

    error_code = kaa_platform_message_read_extension_header(
            reader, &read_extension_type, &read_extension_options, &read_extension_payload_length);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    ASSERT_EQUAL(read_extension_type, extension_type);
    ASSERT_EQUAL(read_extension_options, extension_options);
    ASSERT_EQUAL(read_extension_payload_length, extension_payload_length);

    kaa_platform_message_reader_destroy(reader);
}

KAA_SUITE_MAIN(PlatformUtils, NULL, NULL
        ,
        KAA_TEST_CASE(get_aligned_size, test_get_aligned_size)
        KAA_TEST_CASE(create_destroy_writer, test_create_destroy_writer)
        KAA_TEST_CASE(raw_write, test_write)
        KAA_TEST_CASE(raw_aligned_write, test_aligned_write)
        KAA_TEST_CASE(buffer_overflow_write, test_write_buffer_overflow)
        KAA_TEST_CASE(write_protocol_message_header, test_write_protocol_message_header)
        KAA_TEST_CASE(write_extension_header, test_write_extension_header)
        KAA_TEST_CASE(create_destroy_writer, test_create_destroy_reader)
        KAA_TEST_CASE(raw_read, test_read)
        KAA_TEST_CASE(raw_read_aligned, test_read_aligned)
        KAA_TEST_CASE(read_eof, test_read_eof)
        KAA_TEST_CASE(read_protocol_message_header, test_read_protocol_message_header)
        KAA_TEST_CASE(read_extension_header, test_read_extension_header)
)

Ejemplo n.º 4
0
    /* Add channel will fail due to absent access point, but it is expected */
    kaa_channel_manager_add_transport_channel(channel_manager, &channel, NULL);

    error = kaa_profile_manager_create(&profile_manager,
                                       status, channel_manager, logger);
    if (error || !profile_manager) {
        return error;
    }

    return 0;
}

int test_deinit(void)
{
    kaa_profile_manager_destroy(profile_manager);
    kaa_channel_manager_destroy(channel_manager);
    kaa_status_destroy(status);
    kaa_log_destroy(logger);
    return 0;
}

KAA_SUITE_MAIN(Profile, test_init, test_deinit,
        KAA_TEST_CASE(profile_is_set, test_profile_is_set)
        KAA_TEST_CASE(profile_update, test_profile_update)
        KAA_TEST_CASE(profile_request, test_profile_sync_get_size)
        KAA_TEST_CASE(profile_sync_serialize, test_profile_sync_serialize)
        KAA_TEST_CASE(profile_handle_sync, test_profile_handle_sync)
        KAA_TEST_CASE(profile_force_sync, test_profile_force_sync)

)
        *fd = ACCESS_POINT_SOCKET_FD;
        return KAA_ERR_NONE;
    }

    return KAA_ERR_BADPARAM;
}

int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger)
        return error;


    return 0;
}

int test_deinit(void)
{
    kaa_log_destroy(logger);
    return 0;
}

KAA_SUITE_MAIN(Log, test_init, test_deinit,
        KAA_TEST_CASE(create_kaa_tcp_channel, test_create_kaa_tcp_channel)
        KAA_TEST_CASE(set_access_point_full_success_bootstrap, test_set_access_point_full_success_bootstrap)
        KAA_TEST_CASE(set_access_point_connecting_error, test_set_access_point_connecting_error)
        KAA_TEST_CASE(set_access_point_io_error, test_set_access_point_io_error)
        KAA_TEST_CASE(bootstrap_sync_success, test_bootstrap_sync_success)
        )
Ejemplo n.º 6
0
    ASSERT_EQUAL(err, KAA_ERR_NONE);

    uint64_t fake_ids[2] = { 22, 11 };
    err = kaa_subscribe_to_topics(context->notification_manager, fake_ids, 2, false);
    ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);

    err = kaa_unsubscribe_from_topics(context->notification_manager, fake_ids, 2, false);
    ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);

    uint64_t existing_ids[1] = { 22 };
    err = kaa_subscribe_to_topics(context->notification_manager, existing_ids, 1, false);
    ASSERT_EQUAL(err, KAA_ERR_NONE);

    err = kaa_unsubscribe_from_topics(context->notification_manager, existing_ids, 1, false);
    ASSERT_EQUAL(err, KAA_ERR_NONE);

    KAA_TRACE_OUT(context->logger);
}

KAA_SUITE_MAIN(Notification, test_init, test_deinit
#ifndef KAA_DISABLE_FEATURE_NOTIFICATION
       ,
       KAA_TEST_CASE(deserializing, test_deserializing)
       KAA_TEST_CASE(removing_and_adding_notifications_listeners, test_notification_listeners_adding_and_removing)
       KAA_TEST_CASE(removing_and_adding_topic_list_listeners, test_topic_list_listeners_adding_and_removing)
       KAA_TEST_CASE(topic_list_retrieving, test_retrieving_topic_list)
       KAA_TEST_CASE(serializing, test_serializing)
       KAA_TEST_CASE(subscriptions, test_subscriptions)
#endif
        )
Ejemplo n.º 7
0
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger) {
        return error;
    }

    error = kaa_status_create(&status);
    if (error || !status) {
        return error;
    }

    return 0;
}

int test_deinit(void)
{
    kaa_status_destroy(status);
    kaa_log_destroy(logger);

    return 0;
}



KAA_SUITE_MAIN(MetaExtension, test_init, test_deinit,
        KAA_TEST_CASE(meta_extension_get_size_failed, test_meta_extension_get_size_failed)
        KAA_TEST_CASE(meta_extension_get_size, test_meta_extension_get_size)
        KAA_TEST_CASE(meta_extension_serialize_failed, test_meta_extension_serialize_failed)
        KAA_TEST_CASE(meta_extension_serialize, test_meta_extension_serialize)
)
Ejemplo n.º 8
0

int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger) {
        return error;
    }

    return 0;
}

int test_deinit(void)
{
    kaa_log_destroy(logger);
    return 0;
}



KAA_SUITE_MAIN(MetaExtension, test_init, test_deinit,
        KAA_TEST_CASE(create_unlimited_storage, test_create_unlimited_storage)
        KAA_TEST_CASE(create_limited_storage, test_create_limited_storage)
        KAA_TEST_CASE(allocate_log_record_buffer, test_allocate_log_record_buffer)
        KAA_TEST_CASE(add_log_record, test_add_log_record)
        KAA_TEST_CASE(write_next_log_record, test_write_next_log_record)
        KAA_TEST_CASE(remove_by_bucket_id, test_remove_by_bucket_id)
        KAA_TEST_CASE(unmark_by_bucket_id, test_unmark_by_bucket_id)
        KAA_TEST_CASE(shrink_to_size, test_shrink_to_size)
)
Ejemplo n.º 9
0
    error = kaa_configuration_manager_create(&config_manager, NULL, status, logger);
    if (error || config_manager)
        return error;
#endif
    return 0;
}



int test_deinit(void)
{
#ifndef KAA_DISABLE_FEATURE_CONFIGURATION
    kaa_status_destroy(status);
    kaa_configuration_manager_destroy(config_manager);
#endif
    kaa_log_destroy(logger);

    return 0;
}



KAA_SUITE_MAIN(Log, test_init, test_deinit
#ifndef KAA_DISABLE_FEATURE_CONFIGURATION
       ,
       KAA_TEST_CASE(create_request, test_create_request)
       KAA_TEST_CASE(process_response, test_response)
#endif
        )
Ejemplo n.º 10
0
    ASSERT_EQUAL(strcmp("my_token", status->endpoint_access_token), 0);

    ASSERT_EQUAL(status->event_seq_n, 10);
    ASSERT_TRUE(status->is_attached);
    ASSERT_TRUE(status->is_registered);
    ASSERT_TRUE(status->is_updated);

    ASSERT_EQUAL(memcmp(test_ep_key_hash, status->endpoint_public_key_hash, SHA_1_DIGEST_LENGTH), 0);
    ASSERT_EQUAL(memcmp(test_profile_hash, status->profile_hash, SHA_1_DIGEST_LENGTH), 0);

    kaa_status_destroy(status);
}

int status_test_init(void)
{
    kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    remove(KAA_STATUS_STORAGE);
    return 0;
}

int test_deinit(void)
{
    kaa_log_destroy(logger);
    return 0;
}

KAA_SUITE_MAIN(Status, status_test_init, test_deinit,
        KAA_TEST_CASE(create, test_create_status)
        KAA_TEST_CASE(persistence, test_status_persistense)
)
Ejemplo n.º 11
0
    for (size_t i = 8; i < sizeof(kaasync_buf); i++) {
        ASSERT_EQUAL((uint8_t)kaasync_buf[i], 0xEA);
    }
}

int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger) {
        return error;
    }

    return 0;
}

int test_deinit(void)
{
    kaa_log_destroy(logger);
    return 0;
}

KAA_SUITE_MAIN(Log, test_init, test_deinit
       ,
       KAA_TEST_CASE(kaatcp_connect, test_kaatcp_connect)
       KAA_TEST_CASE(kaatcp_connect, test_kaatcp_connect_without_key)
       KAA_TEST_CASE(kaatcp_disconnect, test_kaatcp_disconnect)
       KAA_TEST_CASE(kaatcp_kaasync, test_kaatcp_kaasync)
       KAA_TEST_CASE(kaatcp_ping, test_kaatcp_ping)
       KAA_TEST_CASE(get_request_kaasync, test_get_request_kaasync_over_buff)
)
Ejemplo n.º 12
0
    ASSERT_NULL(kaa_deque_iterator_previous(it));
    ASSERT_NULL(kaa_deque_iterator_next(it));

    kaa_deque_push_back_data(deque, "data1");
    kaa_deque_first(deque, &it);

    ASSERT_NOT_NULL(kaa_deque_iterator_get_data(it));
    ASSERT_NULL(kaa_deque_iterator_previous(it));
    ASSERT_NOT_NULL(kaa_deque_iterator_next(it));

    kaa_deque_last(deque, &it);
    ASSERT_NOT_NULL(kaa_deque_iterator_get_data(it));
    ASSERT_NOT_NULL(kaa_deque_iterator_previous(it));
    ASSERT_NULL(kaa_deque_iterator_next(it));
    kaa_deque_destroy(deque, NULL);
}

KAA_SUITE_MAIN(Deque, NULL, NULL
               ,
               KAA_TEST_CASE(create, test_kaa_deque_create)
               KAA_TEST_CASE(destroy, test_kaa_deque_destroy)
               KAA_TEST_CASE(first_last, test_kaa_deque_first_last)
               KAA_TEST_CASE(pop_front_back, test_kaa_deque_pop_front_back)
               KAA_TEST_CASE(push_back, test_kaa_deque_push_back)
               KAA_TEST_CASE(push_front, test_kaa_deque_push_front)
               KAA_TEST_CASE(size, test_kaa_deque_size)
               KAA_TEST_CASE(merge_move, test_kaa_deque_merge_move)
               KAA_TEST_CASE(iterator_api, test_kaa_deque_iterator_api)

              )
Ejemplo n.º 13
0
    KAA_TRACE_OUT(logger);
}

int test_init()
{
    srand(time(NULL));

    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger)
        return error;

    return 0;
}

int test_deinit(void)
{
    kaa_log_destroy(logger);

    return 0;
}

KAA_SUITE_MAIN(List, test_init, test_deinit
        ,
        KAA_TEST_CASE(list_create, test_list_create)
        KAA_TEST_CASE(list_push_front, test_list_push_front)
        KAA_TEST_CASE(list_push_back, test_list_push_back)
        KAA_TEST_CASE(list_for_each, test_list_for_each)

)
Ejemplo n.º 14
0
    kaa_list_node_t *it = kaa_list_begin(list);
    while (it) {
        ASSERT_EQUAL(*(int32_t *)kaa_list_get_data(kaa_list_begin(list)), number2);
        it = kaa_list_next(it);
    }

    kaa_list_destroy(list, NULL);
}

static int test_init(void)
{
    srand(time(NULL));
    return 0;
}

static int test_deinit(void)
{
    return 0;
}

KAA_SUITE_MAIN(List, test_init, test_deinit,
        KAA_TEST_CASE(list_create, test_list_create)
        KAA_TEST_CASE(list_push_front, test_list_push_front)
        KAA_TEST_CASE(list_push_back, test_list_push_back)
        KAA_TEST_CASE(list_for_each, test_list_for_each)
        KAA_TEST_CASE(list_sort, test_list_sort)
        KAA_TEST_CASE(list_sort, test_list_empty_sort)
        KAA_TEST_CASE(list_hash, test_list_hash)
)
Ejemplo n.º 15
0
    error = kaa_bootstrap_manager_create(&bootstrap_manager, &kaa_context);
    if (error || !bootstrap_manager) {
        return error;
    }
    kaa_context.bootstrap_manager = bootstrap_manager;

    return ext_log_upload_strategy_create(&kaa_context, &strategy, KAA_LOG_UPLOAD_VOLUME_STRATEGY);
}

int test_deinit(void)
{
    kaa_bootstrap_manager_destroy(bootstrap_manager);
    kaa_channel_manager_destroy(channel_manager);
    kaa_log_destroy(logger);
    ext_log_upload_strategy_destroy(strategy);

    return 0;
}



KAA_SUITE_MAIN(MetaExtension, test_init, test_deinit,
        KAA_TEST_CASE(create_strategy, test_create_strategy)
        KAA_TEST_CASE(set_upload_timeout, test_set_upload_timeout)
        KAA_TEST_CASE(upload_decision_by_volume, test_upload_decision_by_volume)
        KAA_TEST_CASE(upload_decision_by_count, test_upload_decision_by_count)
        KAA_TEST_CASE(upload_decision_by_timeout, test_upload_decision_by_timeout)
        KAA_TEST_CASE(noop_decision_on_failure, test_noop_decision_on_failure)
        KAA_TEST_CASE(upload_decision_on_failure, test_upload_decision_on_failure)
)
Ejemplo n.º 16
0
    if (error || !logger) {
        return error;
    }

    return 0;
}

int test_deinit(void)
{
    kaa_log_destroy(logger);
    return 0;
}

KAA_SUITE_MAIN(Log, test_init, test_deinit
       ,
       KAA_TEST_CASE(string_move_create, test_string_move_create)
       KAA_TEST_CASE(string_copy_create, test_string_copy_create)
       KAA_TEST_CASE(string_get_size, test_string_get_size)
       KAA_TEST_CASE(string_serialize, test_string_serialize)
       KAA_TEST_CASE(string_deserialize, test_string_deserialize)

       KAA_TEST_CASE(bytes_move_create, test_bytes_move_create)
       KAA_TEST_CASE(bytes_copy_create, test_bytes_copy_create)
       KAA_TEST_CASE(bytes_get_size, test_bytes_get_size)
       KAA_TEST_CASE(bytes_serialize, test_bytes_serialize)
       KAA_TEST_CASE(bytes_deserialize, test_bytes_deserialize)

       KAA_TEST_CASE(fixed_move_create, test_fixed_move_create)
       KAA_TEST_CASE(fixed_copy_create, test_fixed_copy_create)
       KAA_TEST_CASE(fixed_get_size, test_fixed_get_size)
       KAA_TEST_CASE(fixed_serialize, test_fixed_serialize)