]> git.kaiwu.me - haproxy.git/commit
DEBUG: init: add a way to register functions for unit tests
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 28 Feb 2025 20:44:35 +0000 (21:44 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 3 Mar 2025 11:43:32 +0000 (12:43 +0100)
commita6478399547259dbfb8241d8c0077722f77ed2be
tree4aac7dde8c854ab965fe6dfc369854699fe8a79d
parent4dc0ba233ef7fcdd77dba6edb12a32b8347c7acb
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.
Makefile
include/haproxy/debug.h
include/haproxy/init-t.h
include/haproxy/init.h
src/debug.c
src/haproxy.c