diff options
author | Justin Erenkrantz <jerenkrantz@apache.org> | 2002-06-24 07:01:19 +0000 |
---|---|---|
committer | Justin Erenkrantz <jerenkrantz@apache.org> | 2002-06-24 07:01:19 +0000 |
commit | 6768ef5becaf51f482251066d231e6c71fb0412c (patch) | |
tree | c6cc7be7f2f40522eba235ca019f4d8f8da4e9fb /test/testdso.c | |
parent | ea6d7ab6e44189f6ab51218fe1963a7ea6eced9e (diff) | |
download | apr-6768ef5becaf51f482251066d231e6c71fb0412c.tar.gz |
Correct shared library support on Darwin to not fatally error out when
a shared library does not exist.
This does retain the Mach-O bundle and Mach-O dynamically linked shared
library support on Darwin.
Also improvements relating to testdso:
- Get testdso to actually link.
- Add support for a second DSO to load in testdso.
- Build mod_test.slo and libmod_test.slo with and without the -module
option. This checks that both types of dynamic libraries can be
loaded.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63521 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testdso.c')
-rw-r--r-- | test/testdso.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/test/testdso.c b/test/testdso.c index 4231dcb04..512f7298e 100644 --- a/test/testdso.c +++ b/test/testdso.c @@ -65,22 +65,27 @@ #endif #ifdef NETWARE -#define LIB_NAME "mod_test.nlm" +# define LIB_NAME "mod_test.nlm" #else -# ifndef BEOS -# define LIB_NAME ".libs/mod_test.so" -# else +# ifdef BEOS # define LIB_NAME "mod_test.so" +# else +# ifdef DARWIN +# define LIB_NAME ".libs/mod_test.so" +# define LIB_NAME2 ".libs/libmod_test.dylib" +# else +# define LIB_NAME ".libs/mod_test.so" +# define LIB_NAME2 ".libs/libmod_test.so" +# endif # endif #endif -int main (int argc, char ** argv) +void test_shared_library(const char *libname, apr_pool_t *pool) { apr_dso_handle_t *h = NULL; apr_dso_handle_sym_t func1 = NULL; apr_dso_handle_sym_t func2 = NULL; apr_status_t status; - apr_pool_t *cont; void (*function)(void); void (*function1)(int); int *retval; @@ -88,19 +93,11 @@ int main (int argc, char ** argv) getcwd(filename, 256); strcat(filename, "/"); - strcat(filename, LIB_NAME); - - apr_initialize(); - atexit(apr_terminate); - - if (apr_pool_create(&cont, NULL) != APR_SUCCESS) { - fprintf(stderr, "Couldn't allocate context."); - exit(-1); - } + strcat(filename, libname); fprintf(stdout,"Trying to load DSO now....................."); fflush(stdout); - if ((status = apr_dso_load(&h, filename, cont)) != APR_SUCCESS){ + if ((status = apr_dso_load(&h, filename, pool)) != APR_SUCCESS){ char my_error[256]; apr_strerror(status, my_error, sizeof(my_error)); fprintf(stderr, "%s!\n", my_error); @@ -161,6 +158,26 @@ int main (int argc, char ** argv) exit (-1); } fprintf(stdout,"OK\n"); - +} + +int main (int argc, char ** argv) +{ + apr_pool_t *pool; + + apr_initialize(); + atexit(apr_terminate); + + if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + fprintf(stderr, "Couldn't allocate context."); + exit(-1); + } + + fprintf(stdout,"=== Checking module library ===\n"); + test_shared_library(LIB_NAME, pool); +#ifdef LIB_NAME2 + fprintf(stdout,"=== Checking non-module library ===\n"); + test_shared_library(LIB_NAME2, pool); +#endif + return 0; } |