about summary refs log tree commit diff
path: root/test/test-dlopen.c
blob: e45245367e37f7b3cf3ae7ee6b1dfb982840d9b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <dlfcn.h>
#include <stdlib.h>

int main(int argc, char **argv) {

  if (!getenv("TEST_DLOPEN_TARGET"))
    return 1;
  void* lib = dlopen(getenv("TEST_DLOPEN_TARGET"), RTLD_LAZY);
  if (!lib) {
    perror(dlerror());
    return 2;
  }
  int (*func)(int, char**) = dlsym(lib, "main_exported");
  if (!func)
    return 3;
  
  return func(argc, argv);

}