diff options
author | Timothy Gu <timothygu99@gmail.com> | 2014-02-10 03:35:19 +0000 |
---|---|---|
committer | Timothy Gu <timothygu99@gmail.com> | 2014-02-10 03:35:19 +0000 |
commit | 043b3358a91a5e9bef707fd3720f60552e0b9569 (patch) | |
tree | 327f38c90d1505e2b8afd98c55e1b1129c81972e | |
parent | f1642131d79a4854164c47ca8abb4821aa74682c (diff) | |
download | dlfcn-win32-043b3358a91a5e9bef707fd3720f60552e0b9569.tar.gz dlfcn-win32-043b3358a91a5e9bef707fd3720f60552e0b9569.tar.bz2 dlfcn-win32-043b3358a91a5e9bef707fd3720f60552e0b9569.zip |
test: add forgotten test
"Open library again (without closing it first) with RTLD_GLOBAL"
-rw-r--r-- | test.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -49,7 +49,6 @@ | |||
49 | * - Get symbol from library through library object <- works | 49 | * - Get symbol from library through library object <- works |
50 | * - Run function if it worked | 50 | * - Run function if it worked |
51 | * - Get symbol from library through global object <- fails | 51 | * - Get symbol from library through global object <- fails |
52 | * - Run function if it worked | ||
53 | * - Open library again (without closing it first) with RTLD_GLOBAL | 52 | * - Open library again (without closing it first) with RTLD_GLOBAL |
54 | * - Get symbol from library through global object <- works | 53 | * - Get symbol from library through global object <- works |
55 | * - Close library | 54 | * - Close library |
@@ -167,6 +166,33 @@ int main() | |||
167 | else | 166 | else |
168 | printf( "SUCCESS\tDid not get local symbol from global handle.\n" ); | 167 | printf( "SUCCESS\tDid not get local symbol from global handle.\n" ); |
169 | 168 | ||
169 | library = dlopen( "testdll.dll", RTLD_GLOBAL ); | ||
170 | if( !library ) | ||
171 | { | ||
172 | error = dlerror( ); | ||
173 | printf( "ERROR\tCould not open library globally without closing it first: %s\n", error ? error : "" ); | ||
174 | CLOSE_LIB; | ||
175 | CLOSE_GLOBAL; | ||
176 | RETURN_ERROR; | ||
177 | } | ||
178 | else | ||
179 | printf( "SUCCESS\tOpened library globally without closing it first: %p\n", library ); | ||
180 | |||
181 | function = dlsym( global, "function" ); | ||
182 | if( !function ) | ||
183 | { | ||
184 | error = dlerror( ); | ||
185 | printf( "ERROR\tCould not get symbol from global handle: %s\n", | ||
186 | error ? error : "" ); | ||
187 | CLOSE_LIB; | ||
188 | CLOSE_GLOBAL; | ||
189 | RETURN_ERROR; | ||
190 | } | ||
191 | else | ||
192 | printf( "SUCCESS\tGot symbol from global handle: %p\n", function ); | ||
193 | |||
194 | RUNFUNC; | ||
195 | |||
170 | ret = dlclose( library ); | 196 | ret = dlclose( library ); |
171 | if( ret ) | 197 | if( ret ) |
172 | { | 198 | { |