Changed pre/post hooks to use the weak symbol mechanism
This commit is contained in:
parent
5a04df5554
commit
f605f26001
3 changed files with 16 additions and 10 deletions
|
@ -39,8 +39,8 @@ struct criterion_test {
|
|||
const struct criterion_test_extra_data *data;
|
||||
};
|
||||
|
||||
extern void (*criterion_pre_tests)(void);
|
||||
extern void (*criterion_post_tests)(void);
|
||||
extern __attribute__ ((weak)) void criterion_init(void);
|
||||
extern __attribute__ ((weak)) void criterion_fini(void);
|
||||
|
||||
# define SECTION_(Name) __attribute__((section(Name)))
|
||||
# define IDENTIFIER_(Category, Name, Suffix) \
|
||||
|
@ -48,7 +48,7 @@ extern void (*criterion_post_tests)(void);
|
|||
# define TEST_PROTOTYPE_(Category, Name) \
|
||||
void IDENTIFIER_(Category, Name, impl)(void)
|
||||
|
||||
# define test(Category, Name, Args...) \
|
||||
# define Test(Category, Name, Args...) \
|
||||
TEST_PROTOTYPE_(Category, Name); \
|
||||
struct criterion_test_extra_data IDENTIFIER_(Category, Name, extra) = { \
|
||||
.sentinel_ = 0, \
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "criterion.h"
|
||||
|
||||
test(misc, simple) {
|
||||
Test(misc, simple) {
|
||||
}
|
||||
|
||||
test(misc, failing) {
|
||||
Test(misc, failing) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*void criterion_init(void) {
|
||||
puts("criterion_init");
|
||||
}*/
|
||||
|
||||
void criterion_fini(void) {
|
||||
puts("criterion_fini");
|
||||
}
|
||||
|
|
|
@ -61,11 +61,8 @@ void run_all(void) {
|
|||
map_tests(run_test);
|
||||
}
|
||||
|
||||
void (*criterion_pre_tests)(void) = NULL;
|
||||
void (*criterion_post_tests)(void) = NULL;
|
||||
|
||||
int main(void) {
|
||||
(criterion_pre_tests ?: nothing)();
|
||||
(criterion_init ?: nothing)();
|
||||
run_all();
|
||||
(criterion_post_tests ?: nothing)();
|
||||
(criterion_fini ?: nothing)();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue