Test that dlerror() returns non-NULL error for failed calls
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/test.c b/test.c
index 814aca1..d99fd52 100644
--- a/test.c
+++ b/test.c
@@ -201,11 +201,14 @@ int main()
CLOSE_GLOBAL;
RETURN_ERROR;
}
- else {
- error = dlerror( );
- printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n",
- error ? error : "" );
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
+ RETURN_ERROR;
}
+ else
+ printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n", error );
function = dlsym( global, "function" );
if( !function )
@@ -231,11 +234,14 @@ int main()
CLOSE_GLOBAL;
RETURN_ERROR;
}
- else {
- error = dlerror( );
- printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n",
- error ? error : "" );
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
+ RETURN_ERROR;
}
+ else
+ printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", error );
ret = dlclose( library );
if( ret )
@@ -293,11 +299,14 @@ int main()
CLOSE_GLOBAL;
RETURN_ERROR;
}
- else {
- error = dlerror( );
- printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n",
- error ? error : "" );
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
+ RETURN_ERROR;
}
+ else
+ printf( "SUCCESS\tCould not get nonexistent symbol from library handle: %s\n", error );
function = dlsym( global, "function" );
if( function )
@@ -321,11 +330,14 @@ int main()
CLOSE_GLOBAL;
RETURN_ERROR;
}
- else {
- error = dlerror( );
- printf( "SUCCESS\tDid not get nonexistent local symbol from global handle: %s\n",
- error ? error : "" );
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
+ RETURN_ERROR;
}
+ else
+ printf( "SUCCESS\tDid not get nonexistent local symbol from global handle: %s\n", error );
library = dlopen( "testdll.dll", RTLD_GLOBAL );
if( !library )
@@ -363,10 +375,15 @@ int main()
CLOSE_GLOBAL;
RETURN_ERROR;
}
- else {
- error = dlerror( );
- printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n",
- error ? error : "" );
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlsym for nonexistent symbol\n" );
+ RETURN_ERROR;
+ }
+ else
+ {
+ printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", error );
/* Test that the second call to dlerror() returns null as in the specs
See https://github.com/dlfcn-win32/dlfcn-win32/issues/34 */