コード例 #1
0
ファイル: test_logproto.c プロジェクト: Achint08/syslog-ng
static void
test_log_proto_base(void)
{
  LogProtoServer *proto;

  assert_gint(log_proto_get_char_size_for_fixed_encoding("iso-8859-2"), 1, NULL);
  assert_gint(log_proto_get_char_size_for_fixed_encoding("ucs-4"), 4, NULL);

  log_proto_server_options_set_encoding(&proto_server_options, "ucs-4");
  proto = log_proto_binary_record_server_new(
            log_transport_mock_records_new(
              /* ucs4, terminated by record size */
              "\x00\x00\x00\xe1\x00\x00\x00\x72\x00\x00\x00\x76\x00\x00\x00\xed"      /* |...á...r...v...í| */
              "\x00\x00\x00\x7a\x00\x00\x00\x74\x00\x00\x01\x71\x00\x00\x00\x72", 32, /* |...z...t...ű...r|  */
              LTM_EOF),
            get_inited_proto_server_options(), 32);

  /* check if error state is not forgotten unless reset_error is called */
  proto->status = LPS_ERROR;
  assert_proto_server_status(proto, proto->status , LPS_ERROR);
  assert_proto_server_fetch_failure(proto, LPS_ERROR, NULL);

  log_proto_server_reset_error(proto);
  assert_proto_server_fetch(proto, "árvíztűr", -1);
  assert_proto_server_status(proto, proto->status, LPS_SUCCESS);

  log_proto_server_free(proto);
  log_proto_server_options_destroy(&proto_server_options);
}
コード例 #2
0
ファイル: proto_lib.c プロジェクト: jbfuzier/syslog-ng
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();
}
コード例 #3
0
ファイル: proto_lib.c プロジェクト: jbfuzier/syslog-ng
void
assert_proto_server_fetch(LogProtoServer *proto, const gchar *expected_msg, gssize expected_msg_len)
{
    const guchar *msg = NULL;
    gsize msg_len = 0;
    LogProtoStatus status;

    status = proto_server_fetch(proto, &msg, &msg_len);

    assert_proto_server_status(proto, status, LPS_SUCCESS);
    assert_nstring((const gchar *) msg, msg_len, expected_msg, expected_msg_len, "LogProtoServer expected message mismatch");
}
コード例 #4
0
ファイル: proto_lib.c プロジェクト: jbfuzier/syslog-ng
void
assert_proto_server_fetch_failure(LogProtoServer *proto, LogProtoStatus expected_status, const gchar *error_message)
{
    const guchar *msg = NULL;
    gsize msg_len = 0;
    LogProtoStatus status;

    status = proto_server_fetch(proto, &msg, &msg_len);

    assert_proto_server_status(proto, status, expected_status);
    if (error_message)
        assert_grabbed_messages_contain(error_message, "expected error message didn't show up");
}
コード例 #5
0
ファイル: proto_lib.c プロジェクト: algernon/syslog-ng-old
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();
}