]>
Commit | Line | Data |
---|---|---|
f36c39aa LP |
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | ||
3 | #include "alloc-util.h" | |
4 | #include "static-destruct.h" | |
5 | #include "tests.h" | |
6 | ||
7 | static int foo = 0; | |
8 | static int bar = 0; | |
9 | static int baz = 0; | |
10 | static char* memory = NULL; | |
11 | ||
12 | static void test_destroy(int *b) { | |
13 | (*b)++; | |
14 | } | |
15 | ||
16 | STATIC_DESTRUCTOR_REGISTER(foo, test_destroy); | |
17 | STATIC_DESTRUCTOR_REGISTER(bar, test_destroy); | |
18 | STATIC_DESTRUCTOR_REGISTER(bar, test_destroy); | |
19 | STATIC_DESTRUCTOR_REGISTER(baz, test_destroy); | |
20 | STATIC_DESTRUCTOR_REGISTER(baz, test_destroy); | |
21 | STATIC_DESTRUCTOR_REGISTER(baz, test_destroy); | |
22 | STATIC_DESTRUCTOR_REGISTER(memory, freep); | |
23 | ||
24 | int main(int argc, char *argv[]) { | |
25 | test_setup_logging(LOG_INFO); | |
26 | ||
27 | assert_se(memory = strdup("hallo")); | |
28 | ||
29 | assert_se(foo == 0 && bar == 0 && baz == 0); | |
30 | static_destruct(); | |
31 | assert_se(foo == 1 && bar == 2 && baz == 3); | |
32 | ||
33 | return EXIT_SUCCESS; | |
34 | } |