diff options
author | Silvio <silvio.traversaro@iit.it> | 2017-03-05 16:16:16 +0100 |
---|---|---|
committer | Silvio <silvio.traversaro@iit.it> | 2017-03-05 16:22:50 +0100 |
commit | 540fa7a418c5a63557e3b36603a61a95bd296bed (patch) | |
tree | 43021bf84dca20b3557675ea49f20f0e0a1abe3d | |
parent | ad70f0eba0b3029d896d4ffbdf06a5e1793ee3dc (diff) | |
download | dlfcn-win32-540fa7a418c5a63557e3b36603a61a95bd296bed.tar.gz dlfcn-win32-540fa7a418c5a63557e3b36603a61a95bd296bed.tar.bz2 dlfcn-win32-540fa7a418c5a63557e3b36603a61a95bd296bed.zip |
Fix tests in Visual Studio 2015
For checking the loading of symbols from the global handle,
the printf symbol was loaded, but since Visual Studio 2015
printf is defined as a inline function.
To fix this, the test has been modified to load the symbol
of the fwrite function.
-rw-r--r-- | test.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -41,7 +41,6 @@ | |||
41 | RETURN_ERROR; \ | 41 | RETURN_ERROR; \ |
42 | } \ | 42 | } \ |
43 | } while( 0 ) | 43 | } while( 0 ) |
44 | |||
45 | 44 | ||
46 | /* This is what this test does: | 45 | /* This is what this test does: |
47 | * - Open library with RTLD_GLOBAL | 46 | * - Open library with RTLD_GLOBAL |
@@ -74,7 +73,7 @@ int main() | |||
74 | void *library; | 73 | void *library; |
75 | char *error; | 74 | char *error; |
76 | int (*function)( void ); | 75 | int (*function)( void ); |
77 | int (*printf_local)( const char * ); | 76 | size_t (*fwrite_local) ( const void *, size_t, size_t, FILE * ); |
78 | int (*nonexistentfunction)( void ); | 77 | int (*nonexistentfunction)( void ); |
79 | int ret; | 78 | int ret; |
80 | 79 | ||
@@ -108,8 +107,8 @@ int main() | |||
108 | else | 107 | else |
109 | printf( "SUCCESS\tGot global handle: %p\n", global ); | 108 | printf( "SUCCESS\tGot global handle: %p\n", global ); |
110 | 109 | ||
111 | printf_local = dlsym(global, "printf"); | 110 | fwrite_local = dlsym(global, "fwrite"); |
112 | if (!printf_local) | 111 | if (!fwrite_local) |
113 | { | 112 | { |
114 | error = dlerror(); | 113 | error = dlerror(); |
115 | printf("ERROR\tCould not get symbol from global handle: %s\n", | 114 | printf("ERROR\tCould not get symbol from global handle: %s\n", |
@@ -119,8 +118,10 @@ int main() | |||
119 | RETURN_ERROR; | 118 | RETURN_ERROR; |
120 | } | 119 | } |
121 | else | 120 | else |
122 | printf("SUCCESS\tGot symbol from global handle: %p\n", printf_local); | 121 | printf("SUCCESS\tGot symbol from global handle: %p\n", fwrite_local); |
123 | printf_local("Hello world from local printf!\n"); | 122 | char * hello_world = "Hello world from local fwrite!\n"; |
123 | fwrite_local(hello_world,sizeof(char),strlen(hello_world),stderr); | ||
124 | fflush(stderr); | ||
124 | 125 | ||
125 | function = dlsym( library, "function" ); | 126 | function = dlsym( library, "function" ); |
126 | if( !function ) | 127 | if( !function ) |
@@ -304,7 +305,7 @@ int main() | |||
304 | error ? error : "" ); | 305 | error ? error : "" ); |
305 | } | 306 | } |
306 | 307 | ||
307 | function = dlsym(global, "printf"); | 308 | function = dlsym(global, "fwrite"); |
308 | if (!function) | 309 | if (!function) |
309 | { | 310 | { |
310 | error = dlerror(); | 311 | error = dlerror(); |
@@ -316,6 +317,7 @@ int main() | |||
316 | } | 317 | } |
317 | else | 318 | else |
318 | printf("SUCCESS\tGot symbol from global handle: %p\n", function); | 319 | printf("SUCCESS\tGot symbol from global handle: %p\n", function); |
320 | |||
319 | 321 | ||
320 | ret = dlclose( library ); | 322 | ret = dlclose( library ); |
321 | if( ret ) | 323 | if( ret ) |