test-http-payload.c revision 47baf5f9fe9a0bc50cdd74ab13c34489cc15a557
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomi/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomistatic enum payload_handling server_payload_handling =
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomistatic unsigned int client_ioloop_nesting = 0;
bcab95c672604588f1645e4a52e43f52ee567593Timo Sirainenstatic unsigned ioloop_nested_first = 0;
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomistatic unsigned ioloop_nested_last = 0;
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomistatic unsigned ioloop_nested_depth = 0;
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomi * Test files
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomi /* open the directory */
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomi /* read entries */
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomi const char *file;
if (errno != 0)
static void test_files_init(void)
static void test_files_deinit(void)
static struct istream *
int fd;
if (fd < 0) {
if (debug) {
switch (errno) {
case EFAULT:
case ENOENT:
case EISDIR:
case EACCES:
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;
if (!parallel_clients_global)
for (i = 0; i < parallel_clients; i++) {
if (!parallel_clients_global)
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();
read_server_partial = 0;
test_end();
static void (*const test_functions[])(void) = {
if (terminating != 0)
static void test_atexit(void)