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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
diff --git a/test.c b/test.c
index 878694e..e7124ae 100644
--- a/test.c
+++ b/test.c
@@ -41,7 +41,6 @@
RETURN_ERROR; \
} \
} while( 0 )
-
/* This is what this test does:
* - Open library with RTLD_GLOBAL
@@ -74,7 +73,7 @@ int main()
void *library;
char *error;
int (*function)( void );
- int (*printf_local)( const char * );
+ size_t (*fwrite_local) ( const void *, size_t, size_t, FILE * );
int (*nonexistentfunction)( void );
int ret;
@@ -108,8 +107,8 @@ int main()
else
printf( "SUCCESS\tGot global handle: %p\n", global );
- printf_local = dlsym(global, "printf");
- if (!printf_local)
+ fwrite_local = dlsym(global, "fwrite");
+ if (!fwrite_local)
{
error = dlerror();
printf("ERROR\tCould not get symbol from global handle: %s\n",
@@ -119,8 +118,10 @@ int main()
RETURN_ERROR;
}
else
- printf("SUCCESS\tGot symbol from global handle: %p\n", printf_local);
- printf_local("Hello world from local printf!\n");
+ printf("SUCCESS\tGot symbol from global handle: %p\n", fwrite_local);
+ char * hello_world = "Hello world from local fwrite!\n";
+ fwrite_local(hello_world,sizeof(char),strlen(hello_world),stderr);
+ fflush(stderr);
function = dlsym( library, "function" );
if( !function )
@@ -304,7 +305,7 @@ int main()
error ? error : "" );
}
- function = dlsym(global, "printf");
+ function = dlsym(global, "fwrite");
if (!function)
{
error = dlerror();
@@ -316,6 +317,7 @@ int main()
}
else
printf("SUCCESS\tGot symbol from global handle: %p\n", function);
+
ret = dlclose( library );
if( ret )