aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2019-05-23 20:24:05 +0200
committerPali Rohár <pali.rohar@gmail.com>2019-05-23 20:24:05 +0200
commitf6f6dd2dcff42b0f7c0cee047f1e9862412a3f02 (patch)
tree1238b932e00ab1c027b11ddd41a1ff48360c2490
parent207311ceba4f8e2ebab27ead6e07dfecef392383 (diff)
downloaddlfcn-win32-f6f6dd2dcff42b0f7c0cee047f1e9862412a3f02.tar.gz
dlfcn-win32-f6f6dd2dcff42b0f7c0cee047f1e9862412a3f02.tar.bz2
dlfcn-win32-f6f6dd2dcff42b0f7c0cee047f1e9862412a3f02.zip
Test that dlerror() returns non-NULL error for failed calls
-rw-r--r--test.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/test.c b/test.c
index 814aca1..d99fd52 100644
--- a/test.c
+++ b/test.c
@@ -201,11 +201,14 @@ int main()
201 CLOSE_GLOBAL; 201 CLOSE_GLOBAL;
202 RETURN_ERROR; 202 RETURN_ERROR;
203 } 203 }
204 else { 204 error = dlerror( );
205 error = dlerror( ); 205 if( !error )
206 printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n", 206 {
207 error ? error : "" ); 207 printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
208 RETURN_ERROR;
208 } 209 }
210 else
211 printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n", error );
209 212
210 function = dlsym( global, "function" ); 213 function = dlsym( global, "function" );
211 if( !function ) 214 if( !function )
@@ -231,11 +234,14 @@ int main()
231 CLOSE_GLOBAL; 234 CLOSE_GLOBAL;
232 RETURN_ERROR; 235 RETURN_ERROR;
233 } 236 }
234 else { 237 error = dlerror( );
235 error = dlerror( ); 238 if( !error )
236 printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", 239 {
237 error ? error : "" ); 240 printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
241 RETURN_ERROR;
238 } 242 }
243 else
244 printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", error );
239 245
240 ret = dlclose( library ); 246 ret = dlclose( library );
241 if( ret ) 247 if( ret )
@@ -293,11 +299,14 @@ int main()
293 CLOSE_GLOBAL; 299 CLOSE_GLOBAL;
294 RETURN_ERROR; 300 RETURN_ERROR;
295 } 301 }
296 else { 302 error = dlerror( );
297 error = dlerror( ); 303 if( !error )
298 printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n", 304 {
299 error ? error : "" ); 305 printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
306 RETURN_ERROR;
300 } 307 }
308 else
309 printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n", error );
301 310
302 function = dlsym( global, "function" ); 311 function = dlsym( global, "function" );
303 if( function ) 312 if( function )
@@ -321,11 +330,14 @@ int main()
321 CLOSE_GLOBAL; 330 CLOSE_GLOBAL;
322 RETURN_ERROR; 331 RETURN_ERROR;
323 } 332 }
324 else { 333 error = dlerror( );
325 error = dlerror( ); 334 if( !error )
326 printf( "SUCCESS\tDid not get nonexistent local symbol from global handle: %s\n", 335 {
327 error ? error : "" ); 336 printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
337 RETURN_ERROR;
328 } 338 }
339 else
340 printf( "SUCCESS\tDid not get nonexistent local symbol from global handle: %s\n", error );
329 341
330 library = dlopen( "testdll.dll", RTLD_GLOBAL ); 342 library = dlopen( "testdll.dll", RTLD_GLOBAL );
331 if( !library ) 343 if( !library )
@@ -363,10 +375,15 @@ int main()
363 CLOSE_GLOBAL; 375 CLOSE_GLOBAL;
364 RETURN_ERROR; 376 RETURN_ERROR;
365 } 377 }
366 else { 378 error = dlerror( );
367 error = dlerror( ); 379 if( !error )
368 printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", 380 {
369 error ? error : "" ); 381 printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
382 RETURN_ERROR;
383 }
384 else
385 {
386 printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", error );
370 387
371 /* Test that the second call to dlerror() returns null as in the specs 388 /* Test that the second call to dlerror() returns null as in the specs
372 See https://github.com/dlfcn-win32/dlfcn-win32/issues/34 */ 389 See https://github.com/dlfcn-win32/dlfcn-win32/issues/34 */