summaryrefslogtreecommitdiff
path: root/tests/library/test_loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/library/test_loader.c')
-rw-r--r--tests/library/test_loader.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/library/test_loader.c b/tests/library/test_loader.c
index 0eef9f2..6fd5d2e 100644
--- a/tests/library/test_loader.c
+++ b/tests/library/test_loader.c
@@ -21,6 +21,12 @@
#include <stdio.h> /* for fprintf */
#include <assert.h> /* for assert */
+#ifdef _WIN32
+#define LIBRARY_NAME "testlib.dll"
+#else
+#define LIBRARY_NAME "./testlib.so.0.0.0"
+#endif
+
int main( void ) {
wolf_library_p library;
wolf_error_t error;
@@ -32,7 +38,7 @@ int main( void ) {
int res = 0;
/* open the libray */
- library = wolf_library_load( "./testlib.so.0.0.0", &error );
+ 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 ) );
@@ -44,9 +50,18 @@ int main( void ) {
* http://en.wikipedia.org/wiki/Dynamic_loading
*/
symbol = wolf_library_get_func( library, "multiply_by_two", &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 ) );
+ return EXIT_FAILURE;
+ }
+#if !defined _WIN32
alias.obj = symbol;
func = alias.func;
-
+#else
+ func = (multiply_by_two_func)symbol;
+#endif
+
/* call it */
res = func( 7 );
assert( res == 14 );