Merge from TNG.
[ira/wip.git] / testsuite / nsswitch / nss_winbind_syms.c
1 /*
2  * Test required functions are exported from the libnss_winbind.so library
3  */
4
5 #include <stdio.h>
6 #include <dlfcn.h>
7
8 /* Symbol list to check */
9
10 static char *symlist[] = {
11     "_nss_winbind_getgrent_r",
12     "_nss_winbind_endgrent",
13     "_nss_winbind_endpwent",
14     "_nss_winbind_getgrgid_r",
15     "_nss_winbind_getgrnam_r",
16     "_nss_winbind_getpwent_r",
17     "_nss_winbind_getpwnam_r",
18     "_nss_winbind_getpwuid_r",
19     "_nss_winbind_setgrent",
20     "_nss_winbind_setpwent",
21     NULL
22 };
23
24 /* Main function */
25
26 int main(int argc, char **argv)
27 {
28     void *handle, *sym;
29     int i, y;
30
31     /* Open library */
32
33     if (argc != 2) {
34         printf("FAIL: usage '%s sharedlibname'\n", argv[0]);
35         return 1;
36     }
37
38     handle = dlopen(argv[1], RTLD_NOW);
39
40     if (handle == NULL) {
41         printf("FAIL: could not dlopen library: %s\n", dlerror());
42         return 1;
43     }
44
45     /* Read symbols */
46
47     for (i = 0; symlist[i] != NULL; i++) {
48         sym = dlsym(handle, symlist[i]);
49         if (sym == NULL) {
50             printf("FAIL: could not resolve symbol '%s': %s\n",
51                    symlist[i], dlerror());
52             return 1;
53         } else {
54             printf("loaded symbol '%s' ok\n", symlist[i]);
55         }
56     }
57
58     /* Clean up */
59
60     dlclose(handle);
61     return 0;
62 }