6 int main(int argc
, char* argv
[])
8 #if defined(__FreeBSD__)
9 // workaround for Bugzilla 14824
10 void *druntime
= dlopen(argv
[1], RTLD_LAZY
); // load druntime
14 const size_t pathlen
= strrchr(argv
[0], '/') - argv
[0] + 1;
15 char *name
= malloc(pathlen
+ sizeof("plugin1.so"));
16 memcpy(name
, argv
[0], pathlen
);
17 memcpy(name
+pathlen
, "plugin1.so", sizeof("plugin1.so"));
19 void* plugin1
= dlopen(name
, RTLD_LAZY
);
20 name
[pathlen
+ sizeof("plugin1.so") - 5] = '2';
21 void* plugin2
= dlopen(name
, RTLD_LAZY
);
23 int (*plugin1_init
)() = dlsym(plugin1
, "plugin_init");
24 int (*plugin1_term
)() = dlsym(plugin1
, "plugin_term");
25 int (*runTests1
)() = dlsym(plugin1
, "runTests");
26 int (*plugin2_init
)() = dlsym(plugin2
, "plugin_init");
27 int (*plugin2_term
)() = dlsym(plugin2
, "plugin_term");
28 int (*runTests2
)() = dlsym(plugin2
, "runTests");
29 assert(plugin1_init());
31 assert(plugin2_init());
34 assert(plugin1_term());
35 assert(dlclose(plugin1
) == 0);
38 name
[pathlen
+ sizeof("plugin1.so") - 5] = '1';
39 plugin1
= dlopen(name
, RTLD_LAZY
);
40 plugin1_init
= dlsym(plugin1
, "plugin_init");
41 plugin1_term
= dlsym(plugin1
, "plugin_term");
42 runTests1
= dlsym(plugin1
, "runTests");
43 assert(plugin1_init());
47 assert(plugin2_term());
48 assert(dlclose(plugin2
) == 0);
51 assert(plugin1_term());
52 assert(dlclose(plugin1
) == 0);
56 #if defined(__FreeBSD__)