diff --git a/ompi/debuggers/Makefile.am b/ompi/debuggers/Makefile.am index 7577891e12..2f440ad82f 100644 --- a/ompi/debuggers/Makefile.am +++ b/ompi/debuggers/Makefile.am @@ -19,6 +19,8 @@ noinst_LTLIBRARIES = libdebuggers.la libompi_debugger_canary.la pkglib_LTLIBRARIES = libompi_dbg_msgq.la +check_PROGRAMS = dlopen_test +TESTS = $(check_PROGRAMS) # This is not quite in the Automake spirit, but we have to do it. # Since the totalview portion of the library must be built with -g, we @@ -36,6 +38,11 @@ headers = \ ompi_common_dll_defs.h \ msgq_interface.h ompi_msgq_dll_defs.h +# Simple checks to ensure that the DSOs are functional + +dlopen_test_SOURCES = dlopen_test.c +dlopen_test_LDADD = $(top_builddir)/opal/libltdl/libltdlc.la + libdebuggers_la_SOURCES = \ $(headers) \ ompi_debuggers.c diff --git a/ompi/debuggers/dlopen_test.c b/ompi/debuggers/dlopen_test.c new file mode 100644 index 0000000000..6cda3d30bf --- /dev/null +++ b/ompi/debuggers/dlopen_test.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include +#include "opal/libltdl/ltdl.h" + +int main(int argc, char *argv[]) +{ + char *filename = "./libompi_dbg_msgq"; + lt_dlhandle dlhandle; + +#if OPAL_HAVE_LTDL_ADVISE + lt_dladvise dladvise; +#endif + + if (lt_dlinit() != 0) { + printf("Failed to lt_dlinit\n"); + return 1; + } + + printf("Trying to lt_dlopen file with dladvise_local: %s\n", filename); + +#if OPAL_HAVE_LTDL_ADVISE + if (lt_dladvise_init(&dladvise) || + lt_dladvise_ext(&dladvise) || + lt_dladvise_local(&dladvise)) { + printf("lt_dladvise failed to initialize properly\n"); + return 1; + } + dlhandle = lt_dlopenadvise(filename, dladvise); + lt_dladvise_destroy(&dladvise); +#else + dlhandle = lt_dlopenext(filename); +#endif + if (NULL != dlhandle) { + lt_dlclose(dlhandle); + printf("File opened with dladvise_local, all passed\n"); + return 0; + } + + printf("Failed to open with dladvise_local: %s\n", lt_dlerror()); + printf("Retrying with dladvise_global\n"); + +#if OPAL_HAVE_LTDL_ADVISE + if (lt_dladvise_init(&dladvise) || + lt_dladvise_ext(&dladvise) || + lt_dladvise_global(&dladvise)) { + printf("lt_dladvise failed to initialize properly\n"); + return 1; + } + dlhandle = lt_dlopenadvise(filename, dladvise); + lt_dladvise_destroy(&dladvise); +#else + dlhandle = lt_dlopenext(filename); +#endif + if (NULL != dlhandle) { + lt_dlclose(dlhandle); + printf("File opened with dladvise_global\n"); + return 1; + } + printf("File failed to opene with dladvise_global: %s\n", lt_dlerror()); + + return 2; +}