void assert_proto_server_fetch_single_read(LogProtoServer *proto, const gchar *expected_msg, gssize expected_msg_len) { const guchar *msg = NULL; gsize msg_len = 0; LogProtoStatus status; LogTransportAuxData aux; Bookmark bookmark; gboolean may_read = TRUE; start_grabbing_messages(); log_transport_aux_data_init(&aux); status = log_proto_server_fetch(proto, &msg, &msg_len, &may_read, &aux, &bookmark); assert_proto_server_status(proto, status, LPS_SUCCESS); if (expected_msg) { assert_nstring((const gchar *) msg, msg_len, expected_msg, expected_msg_len, "LogProtoServer expected message mismatch"); } else { assert_true(msg == NULL, "when single-read finds an incomplete message, msg must be NULL"); assert_true(aux.peer_addr == NULL, "returned saddr must be NULL on success"); } stop_grabbing_messages(); }
static gboolean _after_test(void) { gboolean uri_init_ok = afmongodb_dd_private_uri_init(mongodb); stop_grabbing_messages(); return uri_init_ok; }
LogProtoStatus proto_server_fetch(LogProtoServer *proto, const guchar **msg, gsize *msg_len) { Bookmark bookmark; LogTransportAuxData aux; GSockAddr *saddr; gboolean may_read = TRUE; LogProtoStatus status; start_grabbing_messages(); do { log_transport_aux_data_init(&aux); status = log_proto_server_fetch(proto, msg, msg_len, &may_read, &aux, &bookmark); } while (status == LPS_SUCCESS && *msg == NULL && may_read); saddr = aux.peer_addr; if (status == LPS_SUCCESS) { g_sockaddr_unref(saddr); } else { assert_true(saddr == NULL, "returned saddr must be NULL on failure"); } stop_grabbing_messages(); return status; }
int main(int argc, char **argv) { app_startup(); putenv("TZ=MET-1METDST"); tzset(); start_grabbing_messages(); test_condition_success(); test_reference_on_condition_cloned(); test_set_field_exist_and_set_literal_string(); test_set_field_not_exist_and_set_literal_string(); test_set_field_exist_and_set_template_string(); test_subst_field_exist_and_substring_substituted(); test_subst_field_exist_and_substring_substituted_with_template(); test_subst_field_exist_and_substring_substituted_only_once_without_global(); test_subst_field_exist_and_substring_substituted_every_occurence_with_global(); test_subst_field_exist_and_substring_substituted_when_regexp_matched(); test_set_field_honors_time_zone(); test_set_field_exist_and_group_set_literal_string(); test_set_field_exist_and_group_set_multiple_fields_with_glob_pattern_literal_string(); test_set_field_exist_and_group_set_multiple_fields_with_glob_question_mark_pattern_literal_string(); test_set_field_exist_and_group_set_multiple_fields_with_multiple_glob_pattern_literal_string(); test_set_field_exist_and_group_set_template_string(); test_set_field_exist_and_group_set_template_string_with_old_value(); test_set_field_invalid_template(); test_set_field_exist_and_group_set_when_condition_doesnt_match(); test_set_field_exist_and_group_set_when_condition_matches(); test_set_field_cloned(); stop_grabbing_messages(); }
Test(wildcard_source, test_invalid_monitor_method) { start_grabbing_messages(); cr_assert(!_parse_config("monitor-method(\"something else\"")); stop_grabbing_messages(); cr_assert(assert_grabbed_messages_contain_non_fatal("Invalid monitor-method", NULL)); reset_grabbed_messages(); }
Test(wildcard_source, test_base_dir_required_options) { start_grabbing_messages(); cr_assert(_parse_config("filename-pattern(/tmp)")); cr_assert(!cfg_init(configuration), "Config initialization should be failed"); stop_grabbing_messages(); cr_assert(assert_grabbed_messages_contain_non_fatal("base-dir option is required", NULL)); reset_grabbed_messages(); }
void assert_proto_server_fetch_ignored_eof(LogProtoServer *proto) { const guchar *msg = NULL; gsize msg_len = 0; LogProtoStatus status; LogTransportAuxData aux; gboolean may_read = TRUE; start_grabbing_messages(); log_transport_aux_data_init(&aux); status = log_proto_server_fetch(proto, &msg, &msg_len, &may_read, &aux); assert_proto_server_status(proto, status, LPS_SUCCESS); assert_true(msg == NULL, "when an EOF is ignored msg must be NULL"); assert_true(aux.peer_addr == NULL, "returned saddr must be NULL on success"); stop_grabbing_messages(); }