test: add forgotten test "Open library again (without closing it first) with RTLD_GLOBAL"
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
diff --git a/test.c b/test.c
index 8977fbc..b8f6c9e 100644
--- a/test.c
+++ b/test.c
@@ -49,7 +49,6 @@
* - Get symbol from library through library object <- works
* - Run function if it worked
* - Get symbol from library through global object <- fails
- * - Run function if it worked
* - Open library again (without closing it first) with RTLD_GLOBAL
* - Get symbol from library through global object <- works
* - Close library
@@ -167,6 +166,33 @@ int main()
else
printf( "SUCCESS\tDid not get local symbol from global handle.\n" );
+ library = dlopen( "testdll.dll", RTLD_GLOBAL );
+ if( !library )
+ {
+ error = dlerror( );
+ printf( "ERROR\tCould not open library globally without closing it first: %s\n", error ? error : "" );
+ CLOSE_LIB;
+ CLOSE_GLOBAL;
+ RETURN_ERROR;
+ }
+ else
+ printf( "SUCCESS\tOpened library globally without closing it first: %p\n", library );
+
+ function = dlsym( global, "function" );
+ if( !function )
+ {
+ error = dlerror( );
+ printf( "ERROR\tCould not get symbol from global handle: %s\n",
+ error ? error : "" );
+ CLOSE_LIB;
+ CLOSE_GLOBAL;
+ RETURN_ERROR;
+ }
+ else
+ printf( "SUCCESS\tGot symbol from global handle: %p\n", function );
+
+ RUNFUNC;
+
ret = dlclose( library );
if( ret )
{