Skip to content
Snippets Groups Projects
Commit aee3f681 authored by Nagy Tibor's avatar Nagy Tibor
Browse files

Add tests for constructors and destructors

parent f516ff72
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,9 @@ EXPECT_BINS=\ ...@@ -3,7 +3,9 @@ EXPECT_BINS=\
args \ args \
arpainet \ arpainet \
assert \ assert \
constructor \
ctype \ ctype \
destructor \
dirent/scandir \ dirent/scandir \
error \ error \
fcntl/create \ fcntl/create \
......
#include <stdio.h>
__attribute__((constructor))
void constructor_no_priority(void) {
puts("constructor (no priority)");
}
#define TEST(__priority) \
__attribute__((constructor(__priority))) \
void constructor_priority_##__priority(void) { \
puts("constructor ("#__priority")"); \
}
TEST(101);
TEST(102);
TEST(103);
TEST(104);
int main(int argc, char *argv[]) {
puts("main");
}
#include <stdio.h>
__attribute__((destructor))
void destructor_no_priority(void) {
puts("destructor (no priority)");
}
#define TEST(__priority) \
__attribute__((destructor(__priority))) \
void destructor_priority_##__priority(void) { \
puts("destructor ("#__priority")"); \
}
TEST(101);
TEST(102);
TEST(103);
TEST(104);
int main(int argc, char *argv[]) {
puts("main");
}
constructor (101)
constructor (102)
constructor (103)
constructor (104)
constructor (no priority)
main
main
destructor (no priority)
destructor (104)
destructor (103)
destructor (102)
destructor (101)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment