/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file
*/
#include "lib.h"
#include "test-lib.h"
#include "mempool.h"
#include "buffer.h"
#include "str.h"
#include "array.h"
#include "istream.h"
#include "ostream.h"
#include "istream-dot.h"
#include "ostream-dot.h"
#include "net.h"
#include "iostream-temp.h"
#include "program-client.h"
#include <unistd.h>
static const char *pclient_test_io_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\n"
"Praesent vehicula ac leo vel placerat. Nullam placerat \r\n"
"volutpat leo, sed ultricies felis pulvinar quis. Nam \r\n"
"tempus, augue ut tempor cursus, neque felis commodo lacus, \r\n"
"sit amet tincidunt arcu justo vel augue. Proin dapibus \r\n"
"vulputate maximus. Mauris congue lacus felis, sed varius \r\n"
"leo finibus sagittis. Cum sociis natoque penatibus et magnis \r\n"
"dis parturient montes, nascetur ridiculus mus. Aliquam \r\n"
"laoreet arcu a hendrerit consequat. Duis vitae erat tellus.";
static
.client_connect_timeout_msecs = 5000,
.input_idle_timeout_msecs = 10000,
};
static
struct test_server {
int listen_fd;
unsigned int io_loop_ref;
} test_globals;
struct test_client {
int fd;
enum {
} state;
};
static
void test_program_io_loop_run(void)
{
if (test_globals.io_loop_ref++ == 0)
}
static
void test_program_io_loop_stop(void)
{
if (--test_globals.io_loop_ref == 0)
}
static
{
}
static
{
const char *arg;
case CLIENT_STATE_INIT:
if (cmp == 0) {
} else
return -1;
break;
case CLIENT_STATE_VERSION:
cmp = 0;
test_assert(cmp == 0);
if (cmp == 0)
else
return -1;
break;
case CLIENT_STATE_ARGS:
return 0;
}
break;
case CLIENT_STATE_BODY:
iostream_temp_create_named(".dovecot.test.", 0,
"test_program_input body");
i_stream_unref(&is);
return -1;
break;
-1);
return 1;
i_panic("Cannot write to ostream-temp");
}
break;
}
return 0;
}
static
{
const char *const *args;
unsigned int count;
test_assert(count > 0);
if (count > 0) {
/* return hello world */
"%s %s\r\n.\n+\n",
o_stream_unref(&os);
}
} else
}
}
static
{
int ret = 0;
return;
} else {
if (ret != 0) break;
}
ret == 0))
return;
}
/* incur short delay to make sure the client did not disconnect
prematurely */
i_warning("Client prematurely disconnected");
else
}
}
static
{
int fd;
if (fd < 0)
i_fatal("Failed to accept connection: %m");
}
static
void test_program_setup(void) {
test_begin("test_program_setup");
/* create listener */
test_globals.port = 0;
if (test_globals.listen_fd < 0)
i_fatal("Cannot create TCP listener: %m");
test_end();
}
static
void test_program_teardown(void)
{
test_begin("test_program_teardown");
test_end();
}
static
{
}
static
void test_program_success(void) {
test_begin("test_program_success");
const char *const args[] = {
};
if (ret == -2)
o_stream_unref(&os);
test_end();
}
static
void test_program_io(void) {
test_begin("test_program_io (async)");
const char *const args[] = {
"test_program_io", NULL
};
if (ret == -2)
i_stream_unref(&is);
o_stream_unref(&os);
test_end();
}
static
void test_program_failure(void) {
test_begin("test_program_failure");
const char *const args[] = {
"test_program_failure", NULL
};
if (ret == -2)
test_assert(ret == 0);
o_stream_unref(&os);
test_end();
}
static
void test_program_noreply(void) {
test_begin("test_program_noreply");
const char *const args[] = {
};
if (ret == -2)
test_end();
}
static
void test_program_refused(void) {
test_begin("test_program_refused");
const char *const args[] = {
};
i_fatal("Cannot convert addresses");
}
if (ret == -2)
test_end();
}
int main(void)
{
void (*tests[])(void) = {
};
}