test-common.c revision 7379a9d8a1c10e452d3d319e23ea900a358bac44
/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-internal.h"
#include "test-common.h"
#include <stdio.h>
#include <stdlib.h>
#define OUT_NAME_ALIGN 70
static char *test_prefix;
static bool test_success;
static unsigned int failure_count;
static unsigned int total_count;
struct test_istream {
struct istream_private istream;
unsigned int skip_diff;
bool allow_eof;
};
{
unsigned int new_skip_diff;
return -2;
/* we seeked past the end of file. */
ret = 0;
} else {
/* move around the buffer */
}
if (ret > 0)
return ret;
return 0;
else {
return -1;
}
}
bool mark ATTR_UNUSED)
{
}
{
struct test_istream *tstream;
}
{
struct test_istream *tstream =
}
{
struct test_istream *tstream =
}
{
struct test_istream *tstream =
}
void test_begin(const char *name)
{
test_success = TRUE;
}
{
}
void test_end(void)
{
}
{
}
{
int i = 0;
if (test_prefix != NULL) {
i += strlen(test_prefix);
if (*name != '\0') {
putchar(':');
i++;
}
putchar(' ');
i++;
}
if (*name != '\0') {
putchar(' ');
}
for (; i < OUT_NAME_ALIGN; i++)
putchar('.');
if (success)
else {
}
putchar('\n');
total_count++;
}
static void
{
#ifdef DEBUG
/* ignore "Growing memory pool" and "Growing data stack"
warnings */
return;
}
#endif
}
void test_init(void)
{
test_prefix = NULL;
failure_count = 0;
total_count = 0;
lib_init();
}
int test_deinit(void)
{
return failure_count == 0 ? 0 : 1;
}
void test_run_funcs(void (*test_functions[])(void))
{
unsigned int i;
for (i = 0; test_functions[i] != NULL; i++) {
T_BEGIN {
test_functions[i]();
} T_END;
}
}
int test_run(void (*test_functions[])(void))
{
test_init();
return test_deinit();
}