Created SILC Runtime Toolkit git repository Part II.
[runtime.git] / lib / silcutil / tests / test_silcdll.c
1 /* SilcDll tests */
2
3 #include "silcruntime.h"
4
5 int main(int argc, char **argv)
6 {
7   SilcBool success = FALSE;
8   SilcDll dll;
9   void *ptr;
10
11   if (argc > 1 && !strcmp(argv[1], "-d")) {
12     silc_log_debug(TRUE);
13     silc_log_quick(TRUE);
14     silc_log_debug_hexdump(TRUE);
15     silc_log_set_debug_string("*dll*,*errno*");
16   }
17
18   SILC_LOG_DEBUG(("Load shared object /lib/libc.so.6"));
19   dll = silc_dll_load("/lib/libc.so.6");
20   if (!dll)
21     dll = silc_dll_load("/lib64/libc.so.6");
22   if (!dll) {
23     SILC_LOG_DEBUG(("Cannot load: %s", silc_dll_error(dll)));
24     goto err;
25   }
26
27   SILC_LOG_DEBUG(("Get symbol 'fprintf'"));
28   ptr = silc_dll_getsym(dll, "fprintf");
29   if (!ptr)
30     goto err;
31   SILC_LOG_DEBUG(("Symbol address %p", ptr));
32
33   SILC_LOG_DEBUG(("Close shared object"));
34   silc_dll_close(dll);
35
36   success = TRUE;
37
38  err:
39   SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
40   fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
41
42   return !success;
43 }