Made windows dynamically resolve the section limits at runtime
This commit is contained in:
parent
e093954b56
commit
0d7033cfd5
5 changed files with 41 additions and 14 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
# include <stdbool.h>
|
||||
# include <stddef.h>
|
||||
# include "common.h"
|
||||
|
||||
struct criterion_test_extra_data {
|
||||
int sentinel_;
|
||||
|
|
|
@ -208,3 +208,17 @@ bool is_current_process(s_proc_handle *proc) {
|
|||
return proc->pid == getpid();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VANILLA_WIN32
|
||||
void *get_win_section_start(const char *section) {
|
||||
char symbol[64];
|
||||
sprintf(symbol, "g_%s_section_start", section);
|
||||
return (void*) GetProcAddress(GetModuleHandle(NULL), symbol);
|
||||
}
|
||||
|
||||
void *get_win_section_end(const char *section) {
|
||||
char symbol[64];
|
||||
sprintf(symbol, "g_%s_section_end", section);
|
||||
return (void*) GetProcAddress(GetModuleHandle(NULL), symbol);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -53,4 +53,14 @@ void wait_process(s_proc_handle *handle, int *status);
|
|||
s_proc_handle *get_current_process();
|
||||
bool is_current_process(s_proc_handle *proc);
|
||||
|
||||
# ifdef VANILLA_WIN32
|
||||
void *get_win_section_start(const char *section);
|
||||
void *get_win_section_end(const char *section);
|
||||
# define GET_SECTION_START(Name) get_win_section_start(Name)
|
||||
# define GET_SECTION_END(Name) get_win_section_end(Name)
|
||||
# else
|
||||
# define GET_SECTION_START(Name) SECTION_START(Name)
|
||||
# define GET_SECTION_END(Name) SECTION_END(Name)
|
||||
# endif
|
||||
|
||||
#endif /* !POSIX_COMPAT_H_ */
|
||||
|
|
17
src/report.c
17
src/report.c
|
@ -31,19 +31,20 @@
|
|||
#include "criterion/ordered-set.h"
|
||||
#include "report.h"
|
||||
#include "config.h"
|
||||
#include "posix-compat.h"
|
||||
|
||||
#ifdef HAVE_PCRE
|
||||
#include "extmatch.h"
|
||||
#endif
|
||||
|
||||
#define IMPL_CALL_REPORT_HOOKS(Kind) \
|
||||
IMPL_SECTION_LIMITS(f_report_hook, crit_ ## Kind); \
|
||||
void call_report_hooks_##Kind(void *data) { \
|
||||
for (f_report_hook *hook = SECTION_START(crit_ ## Kind); \
|
||||
hook < SECTION_END(crit_ ## Kind); \
|
||||
++hook) { \
|
||||
(*hook)(data); \
|
||||
} \
|
||||
#define IMPL_CALL_REPORT_HOOKS(Kind) \
|
||||
IMPL_SECTION_LIMITS(f_report_hook, crit_ ## Kind); \
|
||||
void call_report_hooks_##Kind(void *data) { \
|
||||
for (f_report_hook *hook = GET_SECTION_START(crit_ ## Kind); \
|
||||
hook < GET_SECTION_END(crit_ ## Kind); \
|
||||
++hook) { \
|
||||
(*hook)(data); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define IMPL_REPORT_HOOK(Type) \
|
||||
|
|
13
src/runner.h
13
src/runner.h
|
@ -25,20 +25,21 @@
|
|||
# define CRITERION_RUNNER_H_
|
||||
|
||||
# include "criterion/types.h"
|
||||
# include "posix-compat.h"
|
||||
|
||||
DECL_SECTION_LIMITS(struct criterion_test, criterion_tests);
|
||||
DECL_SECTION_LIMITS(struct criterion_suite, crit_suites);
|
||||
|
||||
struct criterion_test_set *criterion_init(void);
|
||||
|
||||
# define FOREACH_TEST_SEC(Test) \
|
||||
for (struct criterion_test *Test = SECTION_START(criterion_tests); \
|
||||
Test < SECTION_END(criterion_tests); \
|
||||
# define FOREACH_TEST_SEC(Test) \
|
||||
for (struct criterion_test *Test = GET_SECTION_START(criterion_tests); \
|
||||
Test < GET_SECTION_END(criterion_tests); \
|
||||
++Test)
|
||||
|
||||
# define FOREACH_SUITE_SEC(Suite) \
|
||||
for (struct criterion_suite *Suite = SECTION_START(crit_suites); \
|
||||
Suite < SECTION_END(crit_suites); \
|
||||
# define FOREACH_SUITE_SEC(Suite) \
|
||||
for (struct criterion_suite *Suite = GET_SECTION_START(crit_suites); \
|
||||
Suite < GET_SECTION_END(crit_suites); \
|
||||
++Suite)
|
||||
|
||||
#endif /* !CRITERION_RUNNER_H_ */
|
||||
|
|
Loading…
Add table
Reference in a new issue