test-program-client-unix.c revision 0a017e924aa2490f6a54096d11e534b2a7554ebe
/* 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 *TEST_SOCKET = "/tmp/program-client-test.sock";
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 = 1000,
.input_idle_timeout_secs = 5000,
.gid = -1,
.uid = -1,
};
static
struct test_server {
struct test_client *client;
int listen_fd;
} test_globals;
struct test_client {
int fd;
enum {
} state;
};
static
{
}
static
{
int cmp;
const char *arg;
case CLIENT_STATE_INIT:
if (cmp == 0) {
} else
return -1;
break;
case CLIENT_STATE_VERSION:
if (cmp == 0)
else
return -1;
break;
case CLIENT_STATE_ARGS:
return 0;
}
break;
case CLIENT_STATE_BODY:
return -1;
i_debug("waiting for input");
break;
return 1;
i_panic("Cannot write to ostream-temp");
}
break;
}
return 0;
}
static
{
const char *arg;
/* return hello world */
}
}
static
{
char *line;
} else {
return;
}
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 unix listener: %m");
test_end();
}
static
void test_program_teardown(void)
{
test_begin("test_program_teardown");
if (test_globals.client)
test_end();
}
static
{
}
static
void test_program_success(void) {
test_begin("test_program_success");
int ret;
const char *const args[] = {
};
struct program_client *pc =
o_stream_unref(&os);
test_end();
}
static
void test_program_io(void) {
test_begin("test_program_io (async)");
int ret;
const char *const args[] = {
"test_program_io", NULL
};
struct program_client *pc =
i_stream_unref(&is);
o_stream_unref(&os);
test_end();
}
static
void test_program_failure(void) {
test_begin("test_program_failure");
int ret;
const char *const args[] = {
"test_program_failure", NULL
};
struct program_client *pc =
test_assert(ret == 0);
o_stream_unref(&os);
test_end();
}
static
void test_program_noreply(void) {
test_begin("test_program_noreply");
int ret;
const char *const args[] = {
};
struct program_client *pc =
test_end();
}
int main(void)
{
void (*tests[])(void) = {
};
}