]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: init: Add a macro to register unit tests
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 4 Mar 2025 16:46:18 +0000 (17:46 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 4 Mar 2025 17:18:10 +0000 (18:18 +0100)
Add a new macro, REGISTER_UNITTEST(), that will automatically make sure
we call hap_register_unittest(), instead of having to create a function
that will do so.

include/haproxy/init.h

index ca059e3760c3556b77ecc75be141b7ffcf2b5523..382e7a142cf3849b93a22ff19168cc7adb70b80d 100644 (file)
@@ -35,8 +35,12 @@ void hap_register_per_thread_free(void (*fct)());
 
 #ifdef DEBUG_UNIT
 void hap_register_unittest(const char *name, int (*fct)());
+/* Simplified way to register a unit test */
+#define REGISTER_UNITTEST(name, fct) \
+       INITCALL2(STG_REGISTER, hap_register_unittest, name, (fct))
 #else
 #define hap_register_unittest(a,b) ({})
+#define REGISTER_UNITTEST(name, fct)
 #endif
 
 /* simplified way to declare a pre-check callback in a file */