aboutsummaryrefslogtreecommitdiff
path: root/libphobos/testsuite/libphobos.shared/load_linkdep.d
blob: 5f5dcf220cfeb451208968426f4d48c28fd2d7a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import core.runtime;
import core.stdc.string;
import core.sys.posix.dlfcn;

extern(C) alias RunDepTests = int function();

void main(string[] args)
{
    auto name = args[0] ~ '\0';
    const pathlen = strrchr(name.ptr, '/') - name.ptr + 1;
    name = name[0 .. pathlen] ~ "liblinkdep.so";

    auto h = Runtime.loadLibrary(name);
    assert(h);
    auto runDepTests = cast(RunDepTests)dlsym(h, "runDepTests");
    assert(runDepTests());
    assert(Runtime.unloadLibrary(h));
}