static void test_log_proto_text_server_is_not_fetching_input_as_long_as_there_is_an_eol_in_buffer(void) { LogProtoServer *proto; accumulate_seq = 0; proto = construct_test_proto_with_accumulator( accumulator_delay_lines, log_transport_mock_records_new( /* should the LogProto instance read ahead, it gets an * EIO error */ "foo\n" "bar\n" "baz\n" "booz\n", -1, LTM_INJECT_ERROR(EIO), LTM_EOF)); assert_proto_server_fetch(proto, "foo", -1); assert_proto_server_fetch(proto, "bar", -1); assert_proto_server_fetch(proto, "baz", -1); assert_proto_server_fetch(proto, "booz", -1); assert_proto_server_fetch_failure(proto, LPS_ERROR, NULL); log_proto_server_free(proto); }
static void test_log_proto_text_server_multi_read_not_allowed(void) { /* FIXME: */ #if 0 LogProtoServer *proto; proto = construct_test_proto( log_transport_mock_records_new( "foobar\n", -1, /* no EOL, proto implementation would read another chunk */ "foobaz", -1, LTM_INJECT_ERROR(EIO), LTM_EOF)); ((LogProtoBufferedServer *) proto)->no_multi_read = TRUE; assert_proto_server_fetch_single_read(proto, "foobar", -1); /* because of EAGAIN */ assert_proto_server_fetch_single_read(proto, NULL, -1); /* because of NOMREAD, partial lines are returned as empty */ assert_proto_server_fetch_single_read(proto, NULL, -1); /* because of EAGAIN */ assert_proto_server_fetch_single_read(proto, NULL, -1); /* error was detected by this time, partial line is returned before the error */ assert_proto_server_fetch_single_read(proto, "foobaz", -1); /* finally the error is returned too */ assert_proto_server_fetch_failure(proto, LPS_ERROR, NULL); log_proto_server_free(proto); #endif }
static void test_log_proto_text_server_io_error_before_eof(void) { LogProtoServer *proto; proto = construct_test_proto( log_transport_mock_stream_new( "01234567", -1, LTM_INJECT_ERROR(EIO), LTM_EOF)); assert_proto_server_fetch(proto, "01234567", -1); assert_proto_server_fetch_failure(proto, LPS_ERROR, NULL); log_proto_server_free(proto); }
Test(log_proto, test_log_proto_framed_server_io_error) { LogProtoServer *proto; proto_server_options.max_msg_size = 32; proto = log_proto_framed_server_new( log_transport_mock_stream_new( "32 0123456789ABCDEF0123456789ABCDEF", -1, LTM_INJECT_ERROR(EIO), LTM_EOF), get_inited_proto_server_options()); assert_proto_server_fetch(proto, "0123456789ABCDEF0123456789ABCDEF", -1); assert_proto_server_fetch_failure(proto, LPS_ERROR, "Error reading RFC6587 style framed data"); log_proto_server_free(proto); }
static void test_log_proto_text_server_eol_before_eof(void) { LogProtoServer *proto; proto = construct_test_proto( log_transport_mock_records_new( /* eol before EOF */ "01234\n567\n890\n", -1, LTM_INJECT_ERROR(EIO), LTM_EOF)); assert_proto_server_fetch(proto, "01234", -1); assert_proto_server_fetch(proto, "567", -1); assert_proto_server_fetch(proto, "890", -1); assert_proto_server_fetch_failure(proto, LPS_ERROR, NULL); log_proto_server_free(proto); }
static void test_log_proto_text_server_multi_read(void) { LogProtoServer *proto; proto = construct_test_proto( log_transport_mock_records_new( "foobar\n", -1, /* no EOL, proto implementation would read another chunk */ "foobaz", -1, LTM_INJECT_ERROR(EIO), LTM_EOF)); assert_proto_server_fetch(proto, "foobar", -1); assert_proto_server_fetch(proto, "foobaz", -1); assert_proto_server_fetch_failure(proto, LPS_ERROR, NULL); log_proto_server_free(proto); }
Test(log_proto, test_log_proto_framed_server_multi_read) { LogProtoServer *proto; proto_server_options.max_msg_size = 32; proto = log_proto_framed_server_new( log_transport_mock_records_new( "7 foobar\n", -1, /* no EOL, proto implementation would read another chunk */ "6 fooba", -1, LTM_INJECT_ERROR(EIO), LTM_EOF), get_inited_proto_server_options()); assert_proto_server_fetch(proto, "foobar\n", -1); /* with multi-read, we get the injected failure at the 2nd fetch */ assert_proto_server_fetch_failure(proto, LPS_ERROR, "Error reading RFC6587 style framed data"); log_proto_server_free(proto); /* NOTE: LPBS_NOMREAD is not implemented for framed protocol */ }