#ifndef TEST_TEST_H
#define TEST_TEST_H
/**
* @file
*
* General test-related functionality
*/
#include "assert.h"
#include "util.h"
#include "../log.h"
#include <event2/event.h>
#include <string.h>
#include <stdbool.h>
#include <setjmp.h>
/**
* Global test-running state
*/
extern struct test_ctx {
/** The event_base that we have setup */
struct event_base *ev_base;
/** Failure jump point */
jmp_buf jmp_fail;
/**
* Command-line options for running the tests
*/
struct test_options {
/** Don't stop running tests if one fails */
bool force;
} options;
} _test_ctx;
/**
* Flags for tests
*/
enum test_flag {
/** Do not run this test by default */
TEST_OPTIONAL = 0x01,
/** This test is expected to fail */
TEST_WILL_FAIL = 0x02,
};
/**
* Test results. These all function as process exit codes.
*/
enum test_result {
/** The test ran sucesfully */
TEST_PASS = 0,
/** The test failed */
TEST_FAIL = 1,
/** The test error'd out */
TEST_ERROR = 2,
/** No tests run */
TEST_EMPTY = 3,
};
/**
* Test stats
*/
struct test_stats {
/** How many tests were defined */
size_t tests;
/** How many tests were actually run */
size_t run;
/** How many of those passed */
size_t pass;
/** How many of those failed */
size_t fail;
/** How many of those error'd */
size_t error;
};
/**
* Global list of test definitions
*/
extern const struct test {
/** Test name */
const char *name;
/** Test func */
void (*func) (void);
/** Flags from enum test_flag */
int flags;
} _tests[];
#endif