diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 92cfdf8..4ba4e76 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.6) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) add_subdirectory(simple) add_subdirectory(simplecpu) diff --git a/example/simple/CMakeLists.txt b/example/simple/CMakeLists.txt index 8cc74a2..ee7c3a1 100644 --- a/example/simple/CMakeLists.txt +++ b/example/simple/CMakeLists.txt @@ -6,11 +6,13 @@ include_directories ("${PROJECT_SOURCE_DIR}/../../include") add_executable("pmda${PROJECT_NAME}" "${PROJECT_NAME}.cpp") add_executable("pmda${PROJECT_NAME}-noboost" "${PROJECT_NAME}.cpp") +add_library("pmda_${PROJECT_NAME}" SHARED "${PROJECT_NAME}.cpp") find_package(Boost COMPONENTS program_options REQUIRED) target_link_libraries("pmda${PROJECT_NAME}" pcp pcp_pmda ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries("pmda${PROJECT_NAME}-noboost" pcp pcp_pmda) +target_link_libraries("pmda_${PROJECT_NAME}" pcp pcp_pmda ${Boost_PROGRAM_OPTIONS_LIBRARY}) set_property( TARGET "pmda${PROJECT_NAME}-noboost" diff --git a/example/simple/simple.cpp b/example/simple/simple.cpp index b9287ce..1ab734d 100644 --- a/example/simple/simple.cpp +++ b/example/simple/simple.cpp @@ -255,7 +255,7 @@ class simple : public pcp::pmda { }; // DSO entry point. -extern "C" void trivial_init(pmdaInterface *interface) +extern "C" void simple_init(pmdaInterface *interface) { pcp::pmda::init_dso(interface); } diff --git a/example/simplecpu/CMakeLists.txt b/example/simplecpu/CMakeLists.txt index 8e80b6e..a5302e3 100644 --- a/example/simplecpu/CMakeLists.txt +++ b/example/simplecpu/CMakeLists.txt @@ -6,11 +6,13 @@ include_directories ("${PROJECT_SOURCE_DIR}/../../include") add_executable("pmda${PROJECT_NAME}" "${PROJECT_NAME}.cpp") add_executable("pmda${PROJECT_NAME}-noboost" "${PROJECT_NAME}.cpp") +add_library("pmda_${PROJECT_NAME}" SHARED "${PROJECT_NAME}.cpp") find_package(Boost COMPONENTS program_options REQUIRED) target_link_libraries("pmda${PROJECT_NAME}" pcp pcp_pmda ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries("pmda${PROJECT_NAME}-noboost" pcp pcp_pmda) +target_link_libraries("pmda_${PROJECT_NAME}" pcp pcp_pmda ${Boost_PROGRAM_OPTIONS_LIBRARY}) set_property( TARGET "pmda${PROJECT_NAME}-noboost" diff --git a/example/trivial/CMakeLists.txt b/example/trivial/CMakeLists.txt index 070f490..9e5068f 100644 --- a/example/trivial/CMakeLists.txt +++ b/example/trivial/CMakeLists.txt @@ -6,11 +6,13 @@ include_directories ("${PROJECT_SOURCE_DIR}/../../include") add_executable("pmda${PROJECT_NAME}" "${PROJECT_NAME}.cpp") add_executable("pmda${PROJECT_NAME}-noboost" "${PROJECT_NAME}.cpp") +add_library("pmda_${PROJECT_NAME}" SHARED "${PROJECT_NAME}.cpp") find_package(Boost COMPONENTS program_options REQUIRED) target_link_libraries("pmda${PROJECT_NAME}" pcp pcp_pmda ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries("pmda${PROJECT_NAME}-noboost" pcp pcp_pmda) +target_link_libraries("pmda_${PROJECT_NAME}" pcp pcp_pmda ${Boost_PROGRAM_OPTIONS_LIBRARY}) set_property( TARGET "pmda${PROJECT_NAME}-noboost" diff --git a/include/pcp-cpp/pmda.hpp b/include/pcp-cpp/pmda.hpp index 2735fb9..d310096 100644 --- a/include/pcp-cpp/pmda.hpp +++ b/include/pcp-cpp/pmda.hpp @@ -59,8 +59,12 @@ class pmda { static void init_dso(pmdaInterface * const interface) { try { - set_instance(new Agent); - get_instance()->initialize_pmda(*interface); + Agent * agent = new Agent; + set_instance(agent); //< @todo verify this returns NULL. + pmdaDSO(interface, PCP_CPP_PMDA_INTERFACE_VERSION, + const_cast(agent->get_pmda_name().c_str()), + const_cast(agent->get_help_text_pathname().c_str())); + agent->initialize_pmda(*interface); } catch (const std::exception &ex) { __pmNotifyErr(LOG_ERR, "%s", ex.what()); } diff --git a/test/functional/test.sh b/test/functional/test.sh index 22a9bdd..3407064 100755 --- a/test/functional/test.sh +++ b/test/functional/test.sh @@ -17,6 +17,8 @@ while IFS= read -d '' -r COMMAND; do echo "$DIFF_OUTPUT" exit $RC fi + else + echo -n '(no expectations) ' fi echo "OK" done < <(find "$TEST_DIR" -name 'test_*.command' -type f -print0) diff --git a/test/functional/test_simple_open_dso.command b/test/functional/test_simple_open_dso.command new file mode 100644 index 0000000..6376a2c --- /dev/null +++ b/test/functional/test_simple_open_dso.command @@ -0,0 +1,8 @@ +TEMP_DIR=`mktemp -d -t test_simple_open_dso-XXXXXXXXXX` +./pmdasimple --export-all "$TEMP_DIR" +if [ $? -ne 0 ]; then exit; fi +dbpmda -e -n "$TEMP_DIR/root" <