xref: /netbsd-src/external/bsd/pam-u2f/dist/tests/dlsym_check.c (revision 540ca2718c85d7b6631d382e3e93f4dc91e51282)
1 /*
2  *  Copyright (C) 2014-2022 Yubico AB - See COPYING
3  */
4 
5 #undef NDEBUG
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <assert.h>
9 #include <dlfcn.h>
10 
11 int main(void) {
12   char *path;
13   void *module;
14 
15   assert((path = getenv("PAM_U2F_MODULE")) != NULL);
16   assert((module = dlopen(path, RTLD_NOW)) != NULL);
17   assert(dlsym(module, "pam_sm_authenticate") != NULL);
18   assert(dlsym(module, "pam_sm_setcred") != NULL);
19   assert(dlsym(module, "nonexistent") == NULL);
20   assert(dlclose(module) == 0);
21 
22   return 0;
23 }
24