test-program-client-net.c revision 3f67fea2e5a12390d280315c37c80302a9dab683
/* Copyright (c) 2002-2016 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 "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.\n"
"Praesent vehicula ac leo vel placerat. Nullam placerat \n"
"volutpat leo, sed ultricies felis pulvinar quis. Nam \n"
"tempus, augue ut tempor cursus, neque felis commodo lacus, \n"
"sit amet tincidunt arcu justo vel augue. Proin dapibus \n"
"vulputate maximus. Mauris congue lacus felis, sed varius \n"
"leo finibus sagittis. Cum sociis natoque penatibus et magnis \n"
"dis parturient montes, nascetur ridiculus mus. Aliquam \n"
"laoreet arcu a hendrerit consequat. Duis vitae erat tellus.";
static
struct program_client_settings pc_set = {
.client_connect_timeout_msecs = 5000,
.input_idle_timeout_msecs = 10000,
};
static
struct test_server {
struct test_client *client;
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
{
int cmp = -1;
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");
return -1;
break;
return 1;
i_panic("Cannot write to ostream-temp");
}
break;
}
return 0;
}
static
{
const char *arg;
/* return hello world */
}
}
static
{
const char *line = "";
return;
} else {
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 */
;
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");
int ret = -2;
const char *const args[] = {
};
struct program_client *pc =
if (ret == -2)
o_stream_unref(&os);
test_end();
}
static
void test_program_io(void) {
test_begin("test_program_io (async)");
int ret = -2;
const char *const args[] = {
"test_program_io", NULL
};
struct program_client *pc =
if (ret == -2)
i_stream_unref(&is);
o_stream_unref(&os);
test_end();
}
static
void test_program_failure(void) {
test_begin("test_program_failure");
int ret = -2;
const char *const args[] = {
"test_program_failure", NULL
};
struct program_client *pc =
if (ret == -2)
test_assert(ret == 0);
o_stream_unref(&os);
test_end();
}
static
void test_program_noreply(void) {
test_begin("test_program_noreply");
int ret = -2;
const char *const args[] = {
};
struct program_client *pc =
if (ret == -2)
test_end();
}
static
void test_program_refused(void) {
test_begin("test_program_refused");
int ret = -2;
const char *const args[] = {
};
i_fatal("Cannot convert addresses");
}
struct program_client *pc =
if (ret == -2)
test_end();
}
int main(void)
{
void (*tests[])(void) = {
};
}