summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2010-05-24 20:53:46 +0200
committerAndreas Baumann <abaumann@yahoo.com>2010-05-24 20:53:46 +0200
commitb13ddadad16b2b39ad00cef1ceb19c865335c0ae (patch)
tree19c3eb931a063be970a86b9f92c4c7b2bdf7e218 /tests
parent3d2c90ecdce024eb883d6359ea0881ea766c4abe (diff)
downloadwolfbones-b13ddadad16b2b39ad00cef1ceb19c865335c0ae.tar.gz
wolfbones-b13ddadad16b2b39ad00cef1ceb19c865335c0ae.tar.bz2
better error handling in library loader
Diffstat (limited to 'tests')
-rw-r--r--tests/library/test_loader.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/library/test_loader.c b/tests/library/test_loader.c
index bda32b3..75f968b 100644
--- a/tests/library/test_loader.c
+++ b/tests/library/test_loader.c
@@ -26,6 +26,7 @@
#else
#define LIBRARY_NAME "./testlib.so.0.0.0"
#endif
+#define LIBRARY_FUNC "multiply_by_two2"
int main( void ) {
wolf_library_p library;
@@ -39,16 +40,22 @@ int main( void ) {
/* open the libray */
library = wolf_library_load( LIBRARY_NAME, &error );
if( error != WOLF_OK ) {
- fprintf( stderr, "Error %d loading the library: %s\n",
- error, wolf_library_errmsg( error, library, errbuf, 512 ) );
+ fprintf( stderr, "Error %d (%s) loading library '%s':\n",
+ error, wolf_error_msg( error, errbuf, 512 ), LIBRARY_NAME );
+ fprintf( stderr, "Internal loader error: %s\n",
+ wolf_library_error_msg( library, errbuf, 512 ) );
+ (void)wolf_library_unload( library );
return EXIT_FAILURE;
}
/* fetch a known function symbol (multiply_by_two) */
- symbol = wolf_library_get_func( library, "multiply_by_two", &error );
+ symbol = wolf_library_get_func( library, LIBRARY_FUNC, &error );
if( error != WOLF_OK ) {
- fprintf( stderr, "Error %d fetching a function from the library: %s\n",
- error, wolf_library_errmsg( error, library, errbuf, 512 ) );
+ fprintf( stderr, "Error %d (%s) fetching function '%s' from the library\n",
+ error, wolf_error_msg( error, errbuf, 512 ), LIBRARY_FUNC );
+ fprintf( stderr, "Internal loader error: %s\n",
+ wolf_library_error_msg( library, errbuf, 512 ) );
+ (void)wolf_library_unload( library );
return EXIT_FAILURE;
}
WOLF_LIBRARY_FUNC_CAST( symbol, multiply_by_two_func, func );
@@ -60,8 +67,10 @@ int main( void ) {
/* close library */
error = wolf_library_unload( library );
if( error != WOLF_OK ) {
- fprintf( stderr, "Error %d unloading the library: %s\n",
- error, wolf_library_errmsg( error, library, errbuf, 512 ) );
+ fprintf( stderr, "Error %d (%s) unloading the library\n",
+ error, wolf_error_msg( error, errbuf, 512 ) );
+ fprintf( stderr, "Internal loader error: %s\n",
+ wolf_library_error_msg( library, errbuf, 512 ) );
return EXIT_FAILURE;
}