tststatic.c 591 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. static int
  5. do_test (void)
  6. {
  7. void *handle;
  8. int (*test) (int);
  9. int res;
  10. handle = dlopen ("modstatic.so", RTLD_LAZY);
  11. if (handle == NULL)
  12. {
  13. printf ("%s\n", dlerror ());
  14. exit(1);
  15. }
  16. test = dlsym (handle, "test");
  17. if (test == NULL)
  18. {
  19. printf ("%s\n", dlerror ());
  20. exit(1);
  21. }
  22. res = test (2);
  23. if (res != 4)
  24. {
  25. printf ("Got %i, expected 4\n", res);
  26. exit (1);
  27. }
  28. dlclose (handle);
  29. return 0;
  30. }
  31. #define TEST_FUNCTION do_test ()
  32. #include "../test-skeleton.c"