Commit aee3f681 authored by Nagy Tibor's avatar Nagy Tibor

Add tests for constructors and destructors

parent f516ff72
......@@ -3,7 +3,9 @@ EXPECT_BINS=\
args \
arpainet \
assert \
constructor \
ctype \
destructor \
dirent/scandir \
error \
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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment