test-http-client-errors.c revision fd54a8a6c420c61db635e45129203c7ee645d999
919N/A#include "istream-chain.h"
919N/A#include "time-util.h"
919N/A#include "connection.h"
919N/A#include "test-common.h"
919N/A#include "http-url.h"
919N/A#include "http-request.h"
919N/A#include "http-client.h"
98N/Astruct server_connection {
98N/Atypedef bool (*test_client_init_t)
1551N/Atypedef void (*test_dns_init_t)(void);
98N/Astatic unsigned int server_pids_count = 0;
98N/Astatic unsigned int server_index;
static void test_client_deinit(void);
static void test_run_client_server(
unsigned int server_tests_count,
struct _host_lookup_failed {
unsigned int count;
if (debug)
return TRUE;
static void test_host_lookup_failed(void)
test_end();
struct _connection_refused {
unsigned int count;
if (debug)
if (debug)
return TRUE;
static void test_connection_refused(void)
NULL);
test_end();
NULL);
test_end();
struct _connection_timed_out {
unsigned int count;
if (debug)
return TRUE;
static void test_connection_timed_out(void)
test_end();
static const char *resp =
"Location: http://localhost:4444\r\n"
static const char *resp =
"Location: unix:/var/run/dovecot/auth-master\r\n"
"Location: http://%s:%u/friep.txt\r\n"
if (debug)
return TRUE;
static void test_invalid_redirect(void)
NULL);
test_end();
NULL);
test_end();
NULL);
test_end();
"Location: http://%s:%u/frml.txt\r\n"
if (debug)
return TRUE;
static void test_unseekable_redirect(void)
NULL);
test_end();
if (debug)
return TRUE;
static void test_unseekable_retry(void)
NULL);
test_end();
static const char *resp =
if (debug)
return TRUE;
static void test_broken_payload(void)
NULL);
test_end();
if (server_read_max == 0) {
if (ret < 0) {
struct _connection_lost_ctx {
unsigned int count;
struct _connection_lost_request_ctx {
if (debug)
if (debug)
static const char payload[] =
return TRUE;
static void test_connection_lost(void)
server_read_max = 0;
NULL);
test_end();
NULL);
test_end();
NULL);
test_end();
NULL);
test_end();
static const char *resp =
struct _connection_lost_100_ctx {
unsigned int count;
if (debug)
static const char payload[] =
return TRUE;
static void test_connection_lost_100(void)
server_read_max = 0;
NULL);
test_end();
static const char *resp =
struct _connection_lost_sub_ioloop_ctx {
unsigned int count;
if (debug)
if (debug)
static const char payload[] =
return TRUE;
static void test_connection_lost_sub_ioloop(void)
server_read_max = 0;
NULL);
test_end();
static const char *resp =
struct _early_success_ctx {
unsigned int count;
if (debug)
T_BEGIN {
} T_END;
return TRUE;
static void test_early_success(void)
NULL);
test_end();
static const char *resp =
struct _bad_response_ctx {
unsigned int count;
if (debug)
return TRUE;
static void test_bad_response(void)
NULL);
test_end();
struct _request_timed_out_ctx {
unsigned int count;
if (debug)
return TRUE;
static void test_request_timed_out(void)
NULL);
test_end();
NULL);
test_end();
NULL);
test_end();
NULL);
test_end();
static const char *resp =
struct _request_aborted_early_ctx {
if (debug)
return TRUE;
static void test_request_aborted_early(void)
NULL);
test_end();
static const char *resp =
struct _request_failed_blocking_ctx {
if (debug)
return FALSE;
static void test_request_failed_blocking(void)
NULL);
test_end();
static const char *resp =
struct _client_deinit_early_ctx {
if (debug)
return TRUE;
static void test_client_deinit_early(void)
NULL);
test_end();
struct _client_retry_with_delay_ctx {
unsigned int retries;
if (debug)
if (debug)
return TRUE;
static void test_retry_with_delay(void)
NULL);
test_end();
struct _dns_service_failure {
unsigned int count;
if (debug)
return TRUE;
static void test_dns_service_failure(void)
test_end();
static void test_dns_dns_timeout(void)
test_server_run(0);
struct _dns_timeout {
unsigned int count;
if (debug)
return TRUE;
static void test_dns_timeout(void)
NULL, 0,
test_end();
static void test_dns_dns_lookup_failure(void)
test_server_run(0);
struct _dns_lookup_failure {
unsigned int count;
if (debug)
return TRUE;
static void test_dns_lookup_failure(void)
NULL, 0,
test_end();
static unsigned int count = 0;
const char *line;
if (debug)
if (count == 0) {
count++;
static void test_dns_dns_lookup_ttl(void)
test_server_run(0);
struct _dns_lookup_ttl {
unsigned int count;
if (debug)
if (debug)
return TRUE;
static void test_dns_lookup_ttl(void)
test_end();
static unsigned int seq = 0;
static const char *resp =
struct _peer_reuse_failure {
if (debug)
if (debug)
return TRUE;
static void test_peer_reuse_failure(void)
NULL);
test_end();
static void (*test_functions[])(void) = {
static void test_client_deinit(void)
int fd;
if (debug)
return fd;
static void test_servers_kill_all(void)
if (server_pids_count > 0) {
for (i = 0; i < server_pids_count; i++) {
server_pids_count = 0;
static void test_run_client_server(
unsigned int server_tests_count,
server_pids_count = 0;
if (server_tests_count > 0) {
for (i = 0; i < server_tests_count; i++)
for (i = 0; i < server_tests_count; i++)
for (i = 0; i < server_tests_count; i++) {
if (server_pids[i] == 0) {
server_pids_count = 0;
hostpid_init();
if (debug)
server_test(i);
if (debug)
int fd;
if (dns_pid == 0) {
hostpid_init();
if (debug)
dns_test();
if (terminating != 0)
static void test_atexit(void)