test-http-payload.c revision b7f1ebf921c26dda1599cf03a6f4002f49edd057
b9f30617c2c96d54acbc4f85ed17b939c4f28916Timo Sirainen/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainenstatic enum payload_handling server_payload_handling =
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainenstatic unsigned int client_ioloop_nesting = 0;
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainenstatic unsigned ioloop_nested_first = 0;
9f0f2de10e4ea0c99052bf4b2bef8179f2536228Timo Sirainenstatic unsigned ioloop_nested_last = 0;
9f0f2de10e4ea0c99052bf4b2bef8179f2536228Timo Sirainenstatic unsigned ioloop_nested_depth = 0;
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenstatic void test_files_read_dir(const char *path)
50e20db49f29917fe9adcf1b56b11badf28bd0e4Timo Sirainen /* open the directory */
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen /* read entries */
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainen /* Close the directory */
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainenstatic void test_files_init(void)
a8284e999d091cd29210fa75ecdc8076376a7345Timo Sirainen /* initialize file array */
a8284e999d091cd29210fa75ecdc8076376a7345Timo Sirainen /* obtain all filenames */
a8284e999d091cd29210fa75ecdc8076376a7345Timo Sirainenstatic void test_files_deinit(void)
a8284e999d091cd29210fa75ecdc8076376a7345Timo Sirainenstatic struct istream *
a8284e999d091cd29210fa75ecdc8076376a7345Timo Sirainen unsigned int *status_r, const char **reason_r)
return NULL;
struct client {
struct client_request {
const char *path;
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 test_echo_client_shared(void)
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
read_server_partial = 0;
test_end();
static void (*const test_functions[])(void) = {
if (terminating != 0)
static void test_atexit(void)