William Lallemand a647839954 DEBUG: init: add a way to register functions for unit tests
Doing unit tests with haproxy was always a bit difficult, some of the
function you want to test would depend on the buffer or trash buffer
initialisation of HAProxy, so building a separate main() for them is
quite hard.

This patch adds a way to register a function that can be called with the
"-U" parameter on the command line, will be executed just after
step_init_1() and will exit the process with its return value as an exit
code.

When using the -U option, every keywords after this option is passed to
the callback and could be used as a parameter, letting the capability to
handle complex arguments if required by the test.

HAProxy need to be built with DEBUG_UNIT to activate this feature.
2025-03-03 12:43:32 +01:00

71 lines
1.0 KiB
C

#ifndef _HAPROXY_INIT_T_H
#define _HAPROXY_INIT_T_H
#include <haproxy/list-t.h>
struct proxy;
struct server;
struct pre_check_fct {
struct list list;
int (*fct)();
};
struct post_check_fct {
struct list list;
int (*fct)();
};
struct post_proxy_check_fct {
struct list list;
int (*fct)(struct proxy *);
};
struct post_server_check_fct {
struct list list;
int (*fct)(struct server *);
};
struct per_thread_alloc_fct {
struct list list;
int (*fct)();
};
struct per_thread_init_fct {
struct list list;
int (*fct)();
};
struct post_deinit_fct {
struct list list;
void (*fct)();
};
struct proxy_deinit_fct {
struct list list;
void (*fct)(struct proxy *);
};
struct server_deinit_fct {
struct list list;
void (*fct)(struct server *);
};
struct per_thread_free_fct {
struct list list;
void (*fct)();
};
struct per_thread_deinit_fct {
struct list list;
void (*fct)();
};
struct unittest_fct {
struct list list;
const char *name;
int (*fct)(int argc, char **argv);
};
#endif /* _HAPROXY_INIT_T_H */