Apply %restore_fcommon macro for Address Sanitizer
[platform/upstream/nettle.git] / testsuite / dlopen-test.c
1 #include "testutils.h"
2 #include "version.h"
3
4 #if HAVE_DLFCN_H
5 #include <dlfcn.h>
6 #endif
7
8 int
9 main (int argc UNUSED, char **argv UNUSED)
10 {
11 #if HAVE_LIBDL
12   void *handle = dlopen ("../libnettle.so", RTLD_NOW);
13   int (*get_version)(void);
14   if (!handle)
15     {
16       fprintf (stderr, "dlopen failed: %s\n", dlerror());
17       FAIL ();
18     }
19
20   get_version = (int(*)(void)) dlsym (handle, "nettle_version_minor");
21   if (!get_version)
22     {
23       fprintf (stderr, "dlsym failed: %s\n", dlerror());
24       FAIL ();
25     }
26   if (get_version() != NETTLE_VERSION_MINOR)
27     {
28       fprintf (stderr, "unexpected nettle version\n");
29       FAIL ();
30     }
31   return EXIT_SUCCESS;
32 #else
33   SKIP();
34 #endif
35 }