1 #include <string.h>
2 #include <dlfcn.h>
3 #include "test.h"
4 
main(int argc, char *argv[])5 int main(int argc, char *argv[])
6 {
7 	void *h;
8 	char *(*f)(void);
9 	char *s;
10 	char buf[512];
11 
12 	t_pathrel(buf, sizeof buf, argv[0], "libtls_init_dso.so");
13 	h = dlopen(buf, RTLD_NOW|RTLD_GLOBAL);
14 	if (!h)
15 		t_error("dlopen failed: %s\n", dlerror());
16 	f = dlsym(h, "gettls");
17 	if (!f)
18 		t_error("dlsym failed: %s\n", dlerror());
19 	s = f();
20 	if (!s)
21 		t_error("tls was not initialized at dlopen\n");
22 	if (strcmp(s, "foobar")!=0)
23 		t_error("tls was not initialized correctly at dlopen (got \"%s\", want \"foobar\"\n", s);
24 
25 	return t_status;
26 }
27