test-http-payload.c revision 58e3ba77673e6069a366dbe96d3467dcaacc54fe
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic enum payload_handling server_payload_handling =
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic unsigned int client_ioloop_nesting = 0;
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic unsigned ioloop_nested_first = 0;
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic unsigned ioloop_nested_last = 0;
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic unsigned ioloop_nested_depth = 0;
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic void test_files_read_dir(const char *path)
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen /* open the directory */
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen /* read entries */
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen /* Close the directory */
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainenstatic void test_files_init(void)
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainen /* initialize file array */
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainen /* obtain all filenames */
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic void test_files_deinit(void)
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic struct istream *
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen unsigned int *status_r, const char **reason_r)
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen return i_stream_create_fd_autoclose(&fd, 40960);
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainen * Test server
c4267cf4c40fb1f866b5958ff122ef836b8c5dfbTimo Sirainenstatic const struct http_server_callbacks http_callbacks;
const char *path)
unsigned int status;
if (debug) {
if (blocking) {
if (debug) {
switch (res) {
if (debug) {
const char *path)
size = 0;
if (size == 0) {
("/tmp/test-http-server", 0);
if (blocking) {
if (read_server_partial > 0) {
if (debug) {
if (debug) {
switch (server_payload_handling) {
if (read_server_partial > 0) {
case PAYLOAD_HANDLING_FORWARD:
case PAYLOAD_HANDLING_HANDLER:
static struct client_request *
return creq;
if (debug) {
int fd;
static void test_server_deinit(void)
struct test_client_request {
unsigned int files_idx;
static struct test_client_request *
test_client_request_new(void)
return tcreq;
for (i = 0; i < parallel_clients; i++) {
static void test_client_download_continue(void);
const char **paths;
unsigned int count;
if (debug) {
if (ret == 0) {
if (debug) {
fsize = 0;
} else if (debug) {
const char **paths;
const char *path;
const char *reason;
if (debug) {
if (debug) {
if (debug) {
if (debug) {
if (read_client_partial == 0) {
static void test_client_download_continue(void)
const char *const *paths;
unsigned int count;
if (debug) {
client_files_last++) {
if (debug) {
static void test_client_echo_continue(void);
const char **paths;
unsigned int count;
if (debug) {
if (ret == 0) {
if (debug) {
fsize = 0;
} else if (debug) {
const char **paths;
const char *path;
if (debug) {
if (debug) {
if (read_server_partial > 0) {
if (debug) {
static void test_client_echo_continue(void)
const char **paths;
if (debug) {
client_files_last++) {
if (debug) {
if (debug) {
if (debug) {
if (i == ioloop_nested_last)
} else if (client_ioloop_nesting > 0 &&
if (debug) {
for (i = 0; i < parallel_clients; i++)
for (i = 0; i < parallel_clients; i++)
if (debug) {
static void test_client_deinit(void)
for (i = 0; i < parallel_clients; i++)
static void test_open_server_fd(void)
static void test_server_kill(void)
static void test_run_client_server(
if (server_pid == 0) {
hostpid_init();
if (debug)
ioloop_nested_depth = 0;
if (debug)
ioloop_nested_depth = 0;
static void test_run_sequential(
static void test_run_pipeline(
static void test_run_parallel(
static void test_download_server_nonblocking(void)
read_server_partial = 0;
test_end();
static void test_download_server_blocking(void)
read_server_partial = 0;
test_end();
static void test_echo_server_nonblocking(void)
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
static void test_echo_server_blocking(void)
read_server_partial = 0;
test_end();
static void test_echo_server_nonblocking_sync(void)
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
static void test_echo_server_blocking_sync(void)
read_server_partial = 0;
test_end();
static void test_echo_server_nonblocking_partial(void)
test_end();
test_end();
test_end();
test_end();
test_end();
test_end();
static void test_echo_server_blocking_partial(void)
test_end();
test_end();
static void test_download_client_partial(void)
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
static void test_download_client_nested_ioloop(void)
read_server_partial = 0;
read_client_partial = 0;
test_end();
static void (*const test_functions[])(void) = {
if (terminating != 0)
static void test_atexit(void)