CELIX-289: Fixes for mocking issues and bugs
Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/aec12cd9 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/aec12cd9 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/aec12cd9 Branch: refs/heads/develop Commit: aec12cd9014aa0677599d01fd9e611d81eb563a9 Parents: 79f8239 Author: Pepijn Noltes <[email protected]> Authored: Mon Nov 9 13:47:27 2015 +0100 Committer: Pepijn Noltes <[email protected]> Committed: Mon Nov 9 13:47:27 2015 +0100 ---------------------------------------------------------------------- .../private/src/deployment_admin_activator.c | 2 +- deployment_admin/private/src/log.c | 2 +- examples/mongoose/private/src/mongoose.c | 5 +- framework/CMakeLists.txt | 213 ++--- framework/private/include/bundle_cache.h | 2 +- .../private/include/bundle_cache_private.h | 1 - .../private/include/bundle_context_private.h | 1 - .../private/include/bundle_revision_private.h | 1 - .../private/include/service_reference_private.h | 2 - .../include/service_registration_private.h | 2 +- .../test_bundle1/src/activator.c | 28 +- framework/private/mock/attribute_mock.c | 3 +- framework/private/mock/bundle_archive_mock.c | 9 +- framework/private/mock/bundle_cache_mock.c | 10 +- framework/private/mock/bundle_mock.c | 52 +- framework/private/mock/bundle_revision_mock.c | 2 +- framework/private/mock/capability_mock.c | 8 +- framework/private/mock/celix_log_mock.c | 41 + framework/private/mock/filter_mock.c | 5 +- framework/private/mock/framework_mock.c | 14 +- framework/private/mock/manifest_mock.c | 4 +- framework/private/mock/manifest_parser_mock.c | 12 +- framework/private/mock/module_mock.c | 32 +- framework/private/mock/requirement_mock.c | 16 +- .../private/mock/service_registration_mock.c | 4 +- framework/private/mock/version_mock.c | 44 +- framework/private/mock/version_range_mock.c | 10 +- framework/private/mock/wire_mock.c | 26 +- framework/private/src/bundle.c | 79 +- framework/private/src/bundle_archive.c | 13 +- framework/private/src/bundle_cache.c | 12 +- framework/private/src/bundle_context.c | 1 - framework/private/src/bundle_revision.c | 3 +- framework/private/src/celix_errorcodes.c | 2 +- framework/private/src/framework.c | 4 +- framework/private/src/module.c | 13 + framework/private/src/service_tracker.c | 4 +- framework/private/src/version_range.c | 7 +- framework/private/test/attribute_test.cpp | 39 +- framework/private/test/bundle_archive_test.cpp | 326 +++++++- framework/private/test/bundle_cache_test.cpp | 43 +- framework/private/test/bundle_context_test.cpp | 166 +++- framework/private/test/bundle_revision_test.cpp | 61 +- framework/private/test/bundle_test.cpp | 808 ++++++++++++++++--- framework/private/test/capability_test.cpp | 19 +- .../private/test/celix_errorcodes_test.cpp | 87 ++ framework/private/test/framework_test.cpp | 65 +- framework/private/test/manifest_test.cpp | 4 +- framework/private/test/module_test.cpp | 282 +++++++ framework/private/test/properties_test.cpp | 23 +- framework/private/test/requirement_test.cpp | 18 +- framework/private/test/resolver_test.cpp | 140 +++- .../private/test/service_reference_test.cpp | 1 + .../private/test/service_registration_test.cpp | 4 +- .../private/test/service_registry_test.cpp | 206 +++-- .../test/service_tracker_customizer_test.cpp | 22 +- framework/private/test/service_tracker_test.cpp | 197 ++++- framework/private/test/utils_test.cpp | 142 +++- framework/private/test/version_range_test.cpp | 168 ++-- framework/private/test/version_test.cpp | 199 +++-- framework/private/test/wire_test.cpp | 42 +- framework/public/include/bundle.h | 2 +- framework/public/include/bundle_archive.h | 4 +- framework/public/include/bundle_revision.h | 2 +- framework/public/include/service_reference.h | 2 + framework/public/include/service_registration.h | 2 +- framework/tst/CMakeLists.txt | 2 +- log_service/private/src/log.c | 10 +- log_service/public/src/log_helper.c | 4 +- .../private/include/endpoint_discovery_poller.h | 1 + .../private/src/endpoint_discovery_poller.c | 2 +- .../discovery_etcd/private/src/etcd_watcher.c | 2 +- .../dynamic_function_interface/CMakeLists.txt | 6 +- .../private/src/topology_manager.c | 3 + utils/CMakeLists.txt | 6 +- utils/public/include/celix_threads.h | 2 +- 76 files changed, 3053 insertions(+), 748 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/deployment_admin/private/src/deployment_admin_activator.c ---------------------------------------------------------------------- diff --git a/deployment_admin/private/src/deployment_admin_activator.c b/deployment_admin/private/src/deployment_admin_activator.c index 93fd6b5..9a3ce5f 100644 --- a/deployment_admin/private/src/deployment_admin_activator.c +++ b/deployment_admin/private/src/deployment_admin_activator.c @@ -64,7 +64,7 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) } celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { - celix_status_t status; + celix_status_t status = CELIX_SUCCESS; bundle_activator_pt activator = (bundle_activator_pt) userData; http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/deployment_admin/private/src/log.c ---------------------------------------------------------------------- diff --git a/deployment_admin/private/src/log.c b/deployment_admin/private/src/log.c index 98e757d..a5227ca 100644 --- a/deployment_admin/private/src/log.c +++ b/deployment_admin/private/src/log.c @@ -55,7 +55,7 @@ celix_status_t log_destroy(log_pt *log) { } celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties) { - celix_status_t status; + celix_status_t status = CELIX_SUCCESS; log_event_pt event = NULL; http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/examples/mongoose/private/src/mongoose.c ---------------------------------------------------------------------- diff --git a/examples/mongoose/private/src/mongoose.c b/examples/mongoose/private/src/mongoose.c index 045cd09..34eb2c6 100644 --- a/examples/mongoose/private/src/mongoose.c +++ b/examples/mongoose/private/src/mongoose.c @@ -41,6 +41,7 @@ #include <ctype.h> #include <limits.h> #include <stdio.h> +#include <sys/wait.h> #if defined(_WIN32) // Windows specific #includes and #defines #define _WIN32_WINNT 0x0400 // To make it link in VS2005 @@ -3622,10 +3623,10 @@ static void close_connection(struct mg_connection *conn) { } static void discard_current_request_from_buffer(struct mg_connection *conn) { - char *buffered; + //char *buffered; int buffered_len, body_len; - buffered = conn->buf + conn->request_len; + //buffered = conn->buf + conn->request_len; buffered_len = conn->data_len - conn->request_len; assert(buffered_len >= 0); http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 8af9586..bf60b9e 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -98,16 +98,23 @@ if (FRAMEWORK) private/test/attribute_test.cpp private/src/attribute.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(attribute_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) add_executable(bundle_archive_test + private/mock/celix_log_mock.c private/test/bundle_archive_test.cpp - private/mock/bundle_revision_mock.c + private/src/bundle_revision.c + private/src/manifest.c + private/src/miniunz.c + private/src/unzip.c + private/src/ioapi.c + private/src/properties.c private/src/bundle_archive.c private/src/celix_errorcodes.c - private/src/celix_log.c) - target_link_libraries(bundle_archive_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) + private/src/utils.c) + target_link_libraries(bundle_archive_test celix_utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${ZLIB_LIBRARY} pthread) + add_executable(bundle_cache_test private/test/bundle_cache_test.cpp @@ -115,27 +122,27 @@ if (FRAMEWORK) private/mock/properties_mock.c private/src/bundle_cache.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(bundle_cache_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(bundle_context_test private/test/bundle_context_test.cpp private/mock/bundle_mock.c private/mock/framework_mock.c private/src/bundle_context.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(bundle_context_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(bundle_revision_test private/test/bundle_revision_test.cpp private/mock/miniunz_mock.c private/mock/manifest_mock.c private/src/bundle_revision.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(bundle_revision_test ${ZLIB_LIBRARY} ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(bundle_test private/test/bundle_test.cpp private/mock/framework_mock.c @@ -147,29 +154,35 @@ if (FRAMEWORK) private/src/utils.c private/src/bundle.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(capability_test private/test/capability_test.cpp private/mock/attribute_mock.c private/mock/version_mock.c + private/src/utils.c private/src/capability.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(capability_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + + add_executable(celix_errorcodes_test + private/test/celix_errorcodes_test.cpp + private/src/celix_errorcodes.c) + target_link_libraries(celix_errorcodes_test ${CPPUTEST_LIBRARY}) + add_executable(filter_test private/test/filter_test.cpp private/mock/properties_mock.c private/src/filter.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(filter_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(framework_test private/test/framework_test.cpp - private/mock/properties_mock.c + #private/mock/properties_mock.c private/mock/resolver_mock.c private/mock/service_reference_mock.c private/mock/service_registry_mock.c @@ -183,8 +196,9 @@ if (FRAMEWORK) private/mock/bundle_cache_mock.c private/mock/manifest_mock.c private/src/utils.c + private/src/properties.c private/src/celix_errorcodes.c - private/src/celix_log.c + private/mock/celix_log_mock.c private/src/framework.c) target_link_libraries(framework_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${UUID} celix_utils pthread dl) @@ -198,18 +212,18 @@ if (FRAMEWORK) private/src/utils.c private/src/manifest_parser.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(manifest_parser_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(manifest_test private/test/manifest_test.cpp private/mock/properties_mock.c private/src/utils.c private/src/manifest.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(manifest_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(module_test private/test/module_test.cpp private/mock/bundle_mock.c @@ -221,56 +235,59 @@ if (FRAMEWORK) private/mock/wire_mock.c private/src/module.c) target_link_libraries(module_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(properties_test private/test/properties_test.cpp private/src/utils.c private/src/properties.c) target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - - + add_executable(requirement_test private/test/requirement_test.cpp private/mock/attribute_mock.c private/mock/capability_mock.c private/mock/version_range_mock.c private/src/requirement.c + private/src/utils.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(requirement_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(resolver_test private/test/resolver_test.cpp private/mock/bundle_mock.c private/mock/requirement_mock.c private/mock/capability_mock.c - private/mock/module_mock.c + private/mock/manifest_parser_mock.c private/mock/wire_mock.c + private/mock/version_mock.c + private/src/module.c private/src/resolver.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(resolver_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(service_reference_test private/test/service_reference_test.cpp private/mock/properties_mock.c private/mock/service_registration_mock.c private/mock/service_registry_mock.c private/src/service_reference.c + private/src/utils.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(service_reference_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - - add_executable(service_registration_test + + add_executable(service_registration_test private/test/service_registration_test.cpp private/mock/properties_mock.c private/mock/service_registry_mock.c private/src/service_registration.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(service_registration_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - - + + add_executable(service_registry_test private/test/service_registry_test.cpp private/mock/framework_mock.c @@ -281,17 +298,17 @@ if (FRAMEWORK) private/mock/properties_mock.c private/src/service_registry.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(service_registry_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(service_tracker_customizer_test private/test/service_tracker_customizer_test.cpp private/mock/service_reference_mock.c private/src/service_tracker_customizer.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(service_tracker_customizer_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(service_tracker_test private/test/service_tracker_test.cpp private/mock/bundle_context_mock.c @@ -299,87 +316,95 @@ if (FRAMEWORK) private/mock/service_tracker_customizer_mock.c private/src/service_tracker.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(service_tracker_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) add_executable(utils_test private/test/utils_test.cpp private/src/utils.c) target_link_libraries(utils_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread) - + add_executable(version_range_test private/test/version_range_test.cpp private/src/version_range.c private/mock/version_mock.c private/src/celix_errorcodes.c - private/src/celix_log.c) + private/mock/celix_log_mock.c) target_link_libraries(version_range_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY}) add_executable(version_test private/test/version_test.cpp private/src/version.c private/src/celix_errorcodes.c - private/src/celix_log.c) - target_link_libraries(version_test ${CPPUTEST_LIBRARY}) + private/mock/celix_log_mock.c) + target_link_libraries(version_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY}) add_executable(wire_test private/mock/requirement_mock.c private/mock/capability_mock.c private/mock/module_mock.c private/src/celix_errorcodes.c - private/src/celix_log.c + private/mock/celix_log_mock.c private/src/wire.c private/test/wire_test.cpp) target_link_libraries(wire_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY}) - set_target_properties(wire_test PROPERTIES COMPILE_FLAGS "-include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorMallocMacros.h -include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorNewMacros.h") - - add_test(NAME framework_test_1 COMMAND attribute_test) - add_test(NAME framework_test_2 COMMAND bundle_archive_test) - #ADD_TARGET_FOR_TEST(bundle_cache_test) - add_test(NAME framework_test_3 COMMAND bundle_context_test) - add_test(NAME framework_test_4 COMMAND bundle_revision_test) - add_test(NAME framework_test_5 COMMAND bundle_test) - add_test(NAME framework_test_6 COMMAND capability_test) - add_test(NAME framework_test_7 COMMAND filter_test) - add_test(NAME framework_test_8 COMMAND framework_test) - add_test(NAME framework_test_9 COMMAND manifest_parser_test) - add_test(NAME framework_test_10 COMMAND manifest_test) - add_test(NAME framework_test_11 COMMAND module_test) - add_test(NAME framework_test_12 COMMAND properties_test) - add_test(NAME framework_test_13 COMMAND requirement_test) - add_test(NAME framework_test_14 COMMAND resolver_test) - add_test(NAME framework_test_15 COMMAND service_reference_test) - add_test(NAME framework_test_16 COMMAND service_registration_test) - add_test(NAME framework_test_17 COMMAND service_registry_test) - add_test(NAME framework_test_18 COMMAND service_tracker_customizer_test) - add_test(NAME framework_test_19 COMMAND service_tracker_test) - add_test(NAME framework_test_20 COMMAND version_range_test) - add_test(NAME framework_test_21 COMMAND version_test) - add_test(NAME framework_test_22 COMMAND wire_test) + configure_file(private/resources-test/manifest_sections.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest_sections.txt [COPYONLY]) + configure_file(private/resources-test/manifest.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest.txt [COPYONLY]) + configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/framework/resources-test/properties.txt [COPYONLY]) + + #set_target_properties(wire_test PROPERTIES COMPILE_FLAGS "-include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorMallocMacros.h -include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorNewMacros.h") + + add_test(NAME attribute_test COMMAND attribute_test) + add_test(NAME bundle_archive_test COMMAND bundle_archive_test) + add_test(NAME bundle_cache_test COMMAND bundle_cache_test) + add_test(NAME bundle_context_test COMMAND bundle_context_test) + add_test(NAME bundle_revision_test COMMAND bundle_revision_test) + add_test(NAME bundle_test COMMAND bundle_test) + add_test(NAME capability_test COMMAND capability_test) + add_test(NAME celix_errorcodes_test COMMAND celix_errorcodes_test) + add_test(NAME filter_test COMMAND filter_test) + add_test(NAME framework_test COMMAND framework_test) + add_test(NAME manifest_parser_test COMMAND manifest_parser_test) + add_test(NAME manifest_test COMMAND manifest_test) + add_test(NAME module_test COMMAND module_test) + add_test(NAME properties_test COMMAND properties_test) + add_test(NAME requirement_test COMMAND requirement_test) + add_test(NAME resolver_test COMMAND resolver_test) + add_test(NAME service_reference_test COMMAND service_reference_test) + add_test(NAME service_registration_test COMMAND service_registration_test) + add_test(NAME service_registry_test COMMAND service_registry_test) + add_test(NAME service_tracker_customizer_test COMMAND service_tracker_customizer_test) + add_test(NAME service_tracker_test COMMAND service_tracker_test) + add_test(NAME utils_test COMMAND utils_test) + add_test(NAME version_range_test COMMAND version_range_test) + add_test(NAME version_test COMMAND version_test) + add_test(NAME wire_test COMMAND wire_test) - SETUP_TARGET_FOR_COVERAGE(version_test_c version_test ${CMAKE_BINARY_DIR}/coverage/version_test) - SETUP_TARGET_FOR_COVERAGE(version_range_test_c version_range_test ${CMAKE_BINARY_DIR}/coverage/version_range_test) - SETUP_TARGET_FOR_COVERAGE(service_tracker_test_c service_tracker_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_test) - SETUP_TARGET_FOR_COVERAGE(service_tracker_customizer_test_c service_tracker_customizer_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_customizer_test) - SETUP_TARGET_FOR_COVERAGE(service_registry_test_c service_registry_test ${CMAKE_BINARY_DIR}/coverage/service_registry_test) - SETUP_TARGET_FOR_COVERAGE(service_registration_test_c service_registration_test ${CMAKE_BINARY_DIR}/coverage/service_registration_test) - SETUP_TARGET_FOR_COVERAGE(service_reference_test_c service_reference_test ${CMAKE_BINARY_DIR}/coverage/service_reference_test) - SETUP_TARGET_FOR_COVERAGE(resolver_test_c resolver_test ${CMAKE_BINARY_DIR}/coverage/resolver_test) - SETUP_TARGET_FOR_COVERAGE(requirement_test_c requirement_test ${CMAKE_BINARY_DIR}/coverage/requirement_test) - SETUP_TARGET_FOR_COVERAGE(properties_test_c properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test) - SETUP_TARGET_FOR_COVERAGE(module_test_c module_test ${CMAKE_BINARY_DIR}/coverage/module_test) - SETUP_TARGET_FOR_COVERAGE(manifest_test_c manifest_test ${CMAKE_BINARY_DIR}/coverage/manifest_test) - SETUP_TARGET_FOR_COVERAGE(manifest_parser_test_c manifest_parser_test ${CMAKE_BINARY_DIR}/coverage/manifest_parser_test) - SETUP_TARGET_FOR_COVERAGE(framework_test_c framework_test ${CMAKE_BINARY_DIR}/coverage/framework_test) - SETUP_TARGET_FOR_COVERAGE(filter_test_c filter_test ${CMAKE_BINARY_DIR}/coverage/filter_test) - SETUP_TARGET_FOR_COVERAGE(capability_test_c capability_test ${CMAKE_BINARY_DIR}/coverage/capability_test) - SETUP_TARGET_FOR_COVERAGE(bundle_test_c bundle_test ${CMAKE_BINARY_DIR}/coverage/bundle_test) - SETUP_TARGET_FOR_COVERAGE(bundle_revision_test_c bundle_revision_test ${CMAKE_BINARY_DIR}/coverage/bundle_revision_test) - SETUP_TARGET_FOR_COVERAGE(bundle_context_test_c bundle_context_test ${CMAKE_BINARY_DIR}/coverage/bundle_context_test) - SETUP_TARGET_FOR_COVERAGE(bundle_cache_test_c bundle_cache_test ${CMAKE_BINARY_DIR}/coverage/bundle_cache_test) - SETUP_TARGET_FOR_COVERAGE(bundle_archive_test_c bundle_archive_test ${CMAKE_BINARY_DIR}/coverage/bundle_archive_test) - SETUP_TARGET_FOR_COVERAGE(attribute_test_c attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test) - SETUP_TARGET_FOR_COVERAGE(wire_test_c wire_test ${CMAKE_BINARY_DIR}/coverage/wire_test) + SETUP_TARGET_FOR_COVERAGE(attribute_test attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test/attribute_test) + SETUP_TARGET_FOR_COVERAGE(bundle_archive_test bundle_archive_test ${CMAKE_BINARY_DIR}/coverage/bundle_archive/bundle_archive_test) + SETUP_TARGET_FOR_COVERAGE(bundle_cache_test bundle_cache_test ${CMAKE_BINARY_DIR}/coverage/bundle_cache_test/bundle_cache_test) + SETUP_TARGET_FOR_COVERAGE(bundle_context_test bundle_context_test ${CMAKE_BINARY_DIR}/coverage/bundle_context_test/bundle_context_test) + SETUP_TARGET_FOR_COVERAGE(bundle_revision_test bundle_revision_test ${CMAKE_BINARY_DIR}/coverage/bundle_revision_test/bundle_revision_test) + SETUP_TARGET_FOR_COVERAGE(bundle_test bundle_test ${CMAKE_BINARY_DIR}/coverage/bundle_test/bundle_test) + SETUP_TARGET_FOR_COVERAGE(capability_test capability_test ${CMAKE_BINARY_DIR}/coverage/capability_test/capability_test) + SETUP_TARGET_FOR_COVERAGE(celix_errorcodes_test celix_errorcodes_test ${CMAKE_BINARY_DIR}/coverage/celix_errorcodes_test/celix_errorcodes_test) + SETUP_TARGET_FOR_COVERAGE(filter_test filter_test ${CMAKE_BINARY_DIR}/coverage/filter_test/filter_test) + SETUP_TARGET_FOR_COVERAGE(framework_test framework_test ${CMAKE_BINARY_DIR}/coverage/framework_test/framework_test) + SETUP_TARGET_FOR_COVERAGE(manifest_parser_test manifest_parser_test ${CMAKE_BINARY_DIR}/coverage/manifest_parser_test/manifest_parser_test) + SETUP_TARGET_FOR_COVERAGE(manifest_test manifest_test ${CMAKE_BINARY_DIR}/coverage/manifest_test/manifest_test) + SETUP_TARGET_FOR_COVERAGE(module_test module_test ${CMAKE_BINARY_DIR}/coverage/module_test/module_test) + SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test) + SETUP_TARGET_FOR_COVERAGE(requirement_test requirement_test ${CMAKE_BINARY_DIR}/coverage/requirement_test/requirement_test) + SETUP_TARGET_FOR_COVERAGE(resolver_test resolver_test ${CMAKE_BINARY_DIR}/coverage/resolver_test/resolver_test) + SETUP_TARGET_FOR_COVERAGE(service_reference_test service_reference_test ${CMAKE_BINARY_DIR}/coverage/service_reference_test/service_reference_test) + SETUP_TARGET_FOR_COVERAGE(service_registration_test service_registration_test ${CMAKE_BINARY_DIR}/coverage/service_registration_test/service_registration_test) + SETUP_TARGET_FOR_COVERAGE(service_registry_test service_registry_test ${CMAKE_BINARY_DIR}/coverage/service_registry_test/service_registry_test) + SETUP_TARGET_FOR_COVERAGE(service_tracker_customizer_test service_tracker_customizer_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_customizer_test/service_tracker_customizer_test) + SETUP_TARGET_FOR_COVERAGE(service_tracker_test service_tracker_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_test/service_tracker_test) + SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test) + SETUP_TARGET_FOR_COVERAGE(version_range_test version_range_test ${CMAKE_BINARY_DIR}/coverage/version_range_test/version_range_test) + SETUP_TARGET_FOR_COVERAGE(version_test version_test ${CMAKE_BINARY_DIR}/coverage/version_test/version_test) + SETUP_TARGET_FOR_COVERAGE(wire_test wire_test ${CMAKE_BINARY_DIR}/coverage/wire_test/wire_test) endif (ENABLE_TESTING AND FRAMEWORK_TESTS) endif (FRAMEWORK) http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/include/bundle_cache.h ---------------------------------------------------------------------- diff --git a/framework/private/include/bundle_cache.h b/framework/private/include/bundle_cache.h index 6a04ff8..0deab40 100644 --- a/framework/private/include/bundle_cache.h +++ b/framework/private/include/bundle_cache.h @@ -54,7 +54,7 @@ typedef struct bundleCache *bundle_cache_pt; * - CELIX_ILLEGAL_ARGUMENT If <code>bundle_cache</code> not is null. * - CELIX_ENOMEM If allocating memory for <code>bundle_cache</code> failed. */ -celix_status_t bundleCache_create(properties_pt configurationMap, framework_logger_pt logger, bundle_cache_pt *bundle_cache); +celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache); /** * Frees the bundle_cache memory allocated in bundleCache_create http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/include/bundle_cache_private.h ---------------------------------------------------------------------- diff --git a/framework/private/include/bundle_cache_private.h b/framework/private/include/bundle_cache_private.h index 635f194..69e26ee 100644 --- a/framework/private/include/bundle_cache_private.h +++ b/framework/private/include/bundle_cache_private.h @@ -33,7 +33,6 @@ struct bundleCache { properties_pt configurationMap; char * cacheDir; - framework_logger_pt logger; }; http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/include/bundle_context_private.h ---------------------------------------------------------------------- diff --git a/framework/private/include/bundle_context_private.h b/framework/private/include/bundle_context_private.h index b4ed842..3810cd0 100644 --- a/framework/private/include/bundle_context_private.h +++ b/framework/private/include/bundle_context_private.h @@ -37,7 +37,6 @@ struct bundleContext { #endif struct framework * framework; struct bundle * bundle; - framework_logger_pt logger; }; http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/include/bundle_revision_private.h ---------------------------------------------------------------------- diff --git a/framework/private/include/bundle_revision_private.h b/framework/private/include/bundle_revision_private.h index d52980b..cb1dcd8 100644 --- a/framework/private/include/bundle_revision_private.h +++ b/framework/private/include/bundle_revision_private.h @@ -35,7 +35,6 @@ struct bundleRevision { char *root; char *location; manifest_pt manifest; - framework_logger_pt logger; array_list_pt libraryHandles; }; http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/include/service_reference_private.h ---------------------------------------------------------------------- diff --git a/framework/private/include/service_reference_private.h b/framework/private/include/service_reference_private.h index 002fd87..b297c14 100644 --- a/framework/private/include/service_reference_private.h +++ b/framework/private/include/service_reference_private.h @@ -41,6 +41,4 @@ celix_status_t serviceReference_destroy(service_reference_pt *reference); celix_status_t serviceReference_invalidate(service_reference_pt reference); celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result); -celix_status_t serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration); - #endif /* SERVICE_REFERENCE_PRIVATE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/include/service_registration_private.h ---------------------------------------------------------------------- diff --git a/framework/private/include/service_registration_private.h b/framework/private/include/service_registration_private.h index 4c3e333..8f31a14 100644 --- a/framework/private/include/service_registration_private.h +++ b/framework/private/include/service_registration_private.h @@ -62,7 +62,7 @@ void serviceRegistration_invalidate(service_registration_pt registration); celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, void **service); celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, void **service); -celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties); + celix_status_t serviceRegistration_getRegistry(service_registration_pt registration, service_registry_pt *registry); celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle); celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, char **serviceName); http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/integration-test/test_bundle1/src/activator.c ---------------------------------------------------------------------- diff --git a/framework/private/integration-test/test_bundle1/src/activator.c b/framework/private/integration-test/test_bundle1/src/activator.c index 8e1005b..4d5261f 100644 --- a/framework/private/integration-test/test_bundle1/src/activator.c +++ b/framework/private/integration-test/test_bundle1/src/activator.c @@ -25,7 +25,6 @@ */ #include <stdlib.h> #include <stdio.h> -#include <apr_general.h> #include "bundle_activator.h" #include "bundle_context.h" @@ -38,27 +37,20 @@ struct userData { celix_status_t test_frameworkEvent(void *listener, framework_event_pt event); celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - apr_pool_t *pool; - celix_status_t status = bundleContext_getMemoryPool(context, &pool); - if (status == CELIX_SUCCESS) { - *userData = apr_palloc(pool, sizeof(struct userData)); - ((struct userData *)(*userData))->listener = NULL; - } else { - status = CELIX_START_ERROR; + *userData = calloc(1, sizeof(struct userData)); + if(*userData == NULL){ + return CELIX_ENOMEM; } return CELIX_SUCCESS; } celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { struct userData * activator = (struct userData *) userData; - apr_pool_t *pool; - bundleContext_getMemoryPool(context, &pool); - - activator->listener = apr_palloc(pool, sizeof(*activator->listener)); - activator->listener->handle = activator; - activator->listener->frameworkEvent = test_frameworkEvent; - bundleContext_addFrameworkListener(context, activator->listener); + activator->listener = calloc(1, sizeof(*activator->listener)); + activator->listener->handle = activator; + activator->listener->frameworkEvent = test_frameworkEvent; + bundleContext_addFrameworkListener(context, activator->listener); return CELIX_SUCCESS; } @@ -72,6 +64,12 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) } celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { + struct userData * activator = (struct userData *) userData; + if(activator->listener != NULL){ + free(activator->listener); + } + + free(activator); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/attribute_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/attribute_mock.c b/framework/private/mock/attribute_mock.c index 74c905a..c71d8da 100644 --- a/framework/private/mock/attribute_mock.c +++ b/framework/private/mock/attribute_mock.c @@ -36,7 +36,8 @@ celix_status_t attribute_create(char * key, char * value, attribute_pt *attribut } celix_status_t attribute_destroy(attribute_pt attribute) { - mock_c()->actualCall("attribute_destroy"); + mock_c()->actualCall("attribute_destroy") + ->withPointerParameters("attribute", attribute); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/bundle_archive_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/bundle_archive_mock.c b/framework/private/mock/bundle_archive_mock.c index 83e7ccf..d9b416c 100644 --- a/framework/private/mock/bundle_archive_mock.c +++ b/framework/private/mock/bundle_archive_mock.c @@ -27,9 +27,8 @@ #include "bundle_archive.h" -celix_status_t bundleArchive_create(framework_logger_pt logger, char * archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt *bundle_archive) { +celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt *bundle_archive) { mock_c()->actualCall("bundleArchive_create") - ->withPointerParameters("logger", logger) ->withStringParameters("archiveRoot", archiveRoot) ->withIntParameters("id", id) ->withStringParameters("location", location) @@ -38,9 +37,8 @@ celix_status_t bundleArchive_create(framework_logger_pt logger, char * archiveRo return mock_c()->returnValue().value.intValue; } -celix_status_t bundleArchive_createSystemBundleArchive(framework_logger_pt logger, bundle_archive_pt *bundle_archive) { +celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive) { mock_c()->actualCall("bundleArchive_createSystemBundleArchive") - ->withPointerParameters("logger", logger) ->withOutputParameter("bundle_archive", (void **) bundle_archive); return mock_c()->returnValue().value.intValue; } @@ -112,7 +110,8 @@ celix_status_t bundleArchive_setRefreshCount(bundle_archive_pt archive) { } celix_status_t bundleArchive_close(bundle_archive_pt archive) { - mock_c()->actualCall("bundleArchive_close"); + mock_c()->actualCall("bundleArchive_close") + ->withPointerParameters("archive", archive); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/bundle_cache_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/bundle_cache_mock.c b/framework/private/mock/bundle_cache_mock.c index 606dd4b..925245d 100644 --- a/framework/private/mock/bundle_cache_mock.c +++ b/framework/private/mock/bundle_cache_mock.c @@ -27,8 +27,8 @@ #include "bundle_cache.h" -celix_status_t bundleCache_create(properties_pt configurationMap, framework_logger_pt logger, bundle_cache_pt *bundle_cache) { - mock_c()->actualCall("bundle_getCurrentModule"); +celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache) { + mock_c()->actualCall("bundleCache_create"); return mock_c()->returnValue().value.intValue; } @@ -38,17 +38,17 @@ celix_status_t bundleCache_destroy(bundle_cache_pt *cache) { } celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives) { - mock_c()->actualCall("bundle_getCurrentModule"); + mock_c()->actualCall("bundleCache_getArchives"); return mock_c()->returnValue().value.intValue; } celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, char * location, char *inputFile, bundle_archive_pt *archive) { - mock_c()->actualCall("bundle_getCurrentModule"); + mock_c()->actualCall("bundleCache_createArchive"); return mock_c()->returnValue().value.intValue; } celix_status_t bundleCache_delete(bundle_cache_pt cache) { - mock_c()->actualCall("bundle_getCurrentModule"); + mock_c()->actualCall("bundleCache_delete"); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/bundle_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/bundle_mock.c b/framework/private/mock/bundle_mock.c index 7b304c3..9802f51 100644 --- a/framework/private/mock/bundle_mock.c +++ b/framework/private/mock/bundle_mock.c @@ -27,24 +27,34 @@ #include "bundle_private.h" -celix_status_t bundle_create(bundle_pt * bundle, framework_logger_pt logger) { +celix_status_t bundle_create(bundle_pt * bundle) { + mock_c()->actualCall("bundle_create"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_createFromArchive(bundle_pt * bundle, framework_pt framework, bundle_archive_pt archive) { + mock_c()->actualCall("bundle_createFromArchive") + ->withPointerParameters("bundle", bundle) + ->withPointerParameters("framework", framework) + ->withPointerParameters("archive", archive); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_destroy(bundle_pt bundle) { + mock_c()->actualCall("destroy"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle) { + mock_c()->actualCall("bundle_isSystembundle") + ->withPointerParameters("bundle", bundle) + ->withOutputParameter("systemBundle", systemBundle); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive) { + mock_c()->actualCall("bundle_getArchive"); return mock_c()->returnValue().value.intValue; } @@ -56,154 +66,190 @@ celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module) { } array_list_pt bundle_getModules(bundle_pt bundle) { + mock_c()->actualCall("bundle_getModules"); return mock_c()->returnValue().value.pointerValue; } void * bundle_getHandle(bundle_pt bundle) { + mock_c()->actualCall("bundle_getHandle"); return mock_c()->returnValue().value.pointerValue; } void bundle_setHandle(bundle_pt bundle, void * handle) { + mock_c()->actualCall("bundle_setHandle"); } activator_pt bundle_getActivator(bundle_pt bundle) { + mock_c()->actualCall("bundle_getActivator"); return mock_c()->returnValue().value.pointerValue; } celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) { + mock_c()->actualCall("bundle_setActivator"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context) { + mock_c()->actualCall("bundle_getContext"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context) { + mock_c()->actualCall("bundle_setContext"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getEntry(bundle_pt bundle, char * name, char **entry) { + mock_c()->actualCall("bundle_getEntry"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_start(bundle_pt bundle) { + mock_c()->actualCall("bundle_start"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_startWithOptions(bundle_pt bundle, int options) { + mock_c()->actualCall("bundle_startWithOptions"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_update(bundle_pt bundle, char *inputFile) { + mock_c()->actualCall("bundle_update"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_stop(bundle_pt bundle) { + mock_c()->actualCall("bundle_stop"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options) { + mock_c()->actualCall("bundle_stopWithOptions"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_uninstall(bundle_pt bundle) { + mock_c()->actualCall("bundle_uninstall"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state) { + mock_c()->actualCall("bundle_setState"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle) { + mock_c()->actualCall("bundle_setPersistentStateInactive"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle) { + mock_c()->actualCall("bundle_setPersistentStateUninstalled"); return mock_c()->returnValue().value.intValue; } void uninstallBundle(bundle_pt bundle) { + mock_c()->actualCall("uninstallBundle"); } celix_status_t bundle_revise(bundle_pt bundle, char * location, char *inputFile) { + mock_c()->actualCall("bundle_revise"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_addModule(bundle_pt bundle, module_pt module) { + mock_c()->actualCall("bundle_addModule"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_closeModules(bundle_pt bundle) { + mock_c()->actualCall("bundle_closeModules"); return mock_c()->returnValue().value.intValue; } // Service Reference Functions array_list_pt getUsingBundles(service_reference_pt reference) { + mock_c()->actualCall("getUsingBundles"); return mock_c()->returnValue().value.pointerValue; } int compareTo(service_reference_pt a, service_reference_pt b) { + mock_c()->actualCall("service_reference_pt"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state) { + mock_c()->actualCall("bundle_getState"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable) { + mock_c()->actualCall("bundle_isLockable"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread) { + mock_c()->actualCall("bundle_getLockingThread"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_lock(bundle_pt bundle, bool *locked) { + mock_c()->actualCall("bundle_lock"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked) { + mock_c()->actualCall("bundle_unlock"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_closeAndDelete(bundle_pt bundle) { + mock_c()->actualCall("bundle_closeAndDelete"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_close(bundle_pt bundle) { + mock_c()->actualCall("bundle_close"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_refresh(bundle_pt bundle) { + mock_c()->actualCall("bundle_refresh"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getBundleId(bundle_pt bundle, long *id) { + mock_c()->actualCall("bundle_getBundleId"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list) { + mock_c()->actualCall("bundle_getRegisteredServices"); return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) { - return mock_c()->returnValue().value.intValue; + mock_c()->actualCall("bundle_getServicesInUse"); + return mock_c()->returnValue().value.intValue; } celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) { - return mock_c()->returnValue().value.intValue; + mock_c()->actualCall("bundle_setFramework"); + return mock_c()->returnValue().value.intValue; } celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) { + mock_c()->actualCall("bundle_getFramework"); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/bundle_revision_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/bundle_revision_mock.c b/framework/private/mock/bundle_revision_mock.c index bbc62d7..847467c 100644 --- a/framework/private/mock/bundle_revision_mock.c +++ b/framework/private/mock/bundle_revision_mock.c @@ -27,7 +27,7 @@ #include "bundle_revision.h" -celix_status_t bundleRevision_create(framework_logger_pt logger, char *root, char *location, long revisionNr, char *inputFile, bundle_revision_pt *bundle_revision) { +celix_status_t bundleRevision_create(char *root, char *location, long revisionNr, char *inputFile, bundle_revision_pt *bundle_revision) { mock_c()->actualCall("bundleRevision_create"); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/capability_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/capability_mock.c b/framework/private/mock/capability_mock.c index c305e1f..83bd39b 100644 --- a/framework/private/mock/capability_mock.c +++ b/framework/private/mock/capability_mock.c @@ -38,7 +38,9 @@ celix_status_t capability_destroy(capability_pt capability) { } celix_status_t capability_getServiceName(capability_pt capability, char **serviceName) { - mock_c()->actualCall("capability_getServiceName"); + mock_c()->actualCall("capability_getServiceName") + ->withPointerParameters("capability", capability) + ->withOutputParameter("serviceName", serviceName); return mock_c()->returnValue().value.intValue; } @@ -50,7 +52,9 @@ celix_status_t capability_getVersion(capability_pt capability, version_pt *versi } celix_status_t capability_getModule(capability_pt capability, module_pt *module) { - mock_c()->actualCall("capability_getModule"); + mock_c()->actualCall("capability_getModule") + ->withPointerParameters("capability", capability) + ->withOutputParameter("module", module); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/celix_log_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/celix_log_mock.c b/framework/private/mock/celix_log_mock.c new file mode 100644 index 0000000..066077d --- /dev/null +++ b/framework/private/mock/celix_log_mock.c @@ -0,0 +1,41 @@ +/** + *Licensed to the Apache Software Foundation (ASF) under one + *or more contributor license agreements. See the NOTICE file + *distributed with this work for additional information + *regarding copyright ownership. The ASF licenses this file + *to you under the Apache License, Version 2.0 (the + *"License"); you may not use this file except in compliance + *with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + *Unless required by applicable law or agreed to in writing, + *software distributed under the License is distributed on an + *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + *specific language governing permissions and limitations + *under the License. + */ +/* + * celix_log_mock.c + * + * \date Oct, 5 2015 + * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> + * \copyright Apache License, Version 2.0 + */ +#include "CppUTestExt/MockSupport_c.h" + +#include "celix_log.h" + +void framework_log(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, char *fmsg, ...) { + mock_c()->actualCall("framework_log"); +} + +void framework_logCode(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, celix_status_t code, char *fmsg, ...) { + mock_c()->actualCall("framework_logCode")->withIntParameters("code", code); +} + +celix_status_t frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, char *msg) { + mock_c()->actualCall("frameworkLogger_log"); + return mock_c()->returnValue().value.intValue; +} http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/filter_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/filter_mock.c b/framework/private/mock/filter_mock.c index 5906932..8242b99 100644 --- a/framework/private/mock/filter_mock.c +++ b/framework/private/mock/filter_mock.c @@ -28,17 +28,20 @@ #include "filter.h" filter_pt filter_create(char * filterString) { + mock_c()->actualCall("filter_create"); return mock_c()->returnValue().value.pointerValue; } void filter_destroy(filter_pt filter) { - + mock_c()->actualCall("filter_destroy"); } celix_status_t filter_match(filter_pt filter, properties_pt properties, bool *result) { + mock_c()->actualCall("filter_match"); return mock_c()->returnValue().value.intValue; } celix_status_t filter_getString(filter_pt filter, char **filterStr) { + mock_c()->actualCall("filter_getString"); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/framework_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/framework_mock.c b/framework/private/mock/framework_mock.c index d027df9..c6fb2e9 100644 --- a/framework/private/mock/framework_mock.c +++ b/framework/private/mock/framework_mock.c @@ -28,8 +28,8 @@ #include "framework_private.h" celix_status_t framework_create(framework_pt *framework, properties_pt config) { - mock_c()->actualCall("framework_create"); - return mock_c()->returnValue().value.intValue; + mock_c()->actualCall("framework_create"); + return mock_c()->returnValue().value.intValue; } celix_status_t framework_destroy(framework_pt framework) { @@ -174,12 +174,18 @@ celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, } celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services) { - mock_c()->actualCall("fw_getBundleRegisteredServices"); + mock_c()->actualCall("fw_getBundleRegisteredServices") + ->withPointerParameters("framework", framework) + ->withPointerParameters("bundle", bundle) + ->withOutputParameter("services", (void **) services); return mock_c()->returnValue().value.intValue; } celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services) { - mock_c()->actualCall("fw_getBundleServicesInUse"); + mock_c()->actualCall("fw_getBundleServicesInUse") + ->withPointerParameters("framework", framework) + ->withPointerParameters("bundle", bundle) + ->withOutputParameter("services", (void **) services); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/manifest_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/manifest_mock.c b/framework/private/mock/manifest_mock.c index 9e783da..a74601c 100644 --- a/framework/private/mock/manifest_mock.c +++ b/framework/private/mock/manifest_mock.c @@ -65,11 +65,11 @@ celix_status_t manifest_read(manifest_pt manifest, char *filename) { } void manifest_write(manifest_pt manifest, char * filename) { - mock_c()->actualCall("bundle_getCurrentModule"); + mock_c()->actualCall("manifest_write"); } char * manifest_getValue(manifest_pt manifest, const char * name) { - mock_c()->actualCall("bundle_getCurrentModule"); + mock_c()->actualCall("manifest_getValue"); return (char *) mock_c()->returnValue().value.stringValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/manifest_parser_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/manifest_parser_mock.c b/framework/private/mock/manifest_parser_mock.c index 32d5cf6..dd55020 100644 --- a/framework/private/mock/manifest_parser_mock.c +++ b/framework/private/mock/manifest_parser_mock.c @@ -38,22 +38,26 @@ celix_status_t manifestParser_destroy(manifest_parser_pt manifest_parser) { } celix_status_t manifestParser_getSymbolicName(manifest_parser_pt parser, char **symbolicName) { - mock_c()->actualCall("manifestParser_getSymbolicName"); + mock_c()->actualCall("manifestParser_getSymbolicName") + ->withOutputParameter("symbolicName", (void**) symbolicName); return mock_c()->returnValue().value.intValue; } celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version) { - mock_c()->actualCall("manifestParser_getBundleVersion"); + mock_c()->actualCall("manifestParser_getBundleVersion") + ->withOutputParameter("version", (void**) version); return mock_c()->returnValue().value.intValue; } celix_status_t manifestParser_getCapabilities(manifest_parser_pt parser, linked_list_pt *capabilities) { - mock_c()->actualCall("manifestParser_getCapabilities"); + mock_c()->actualCall("manifestParser_getCapabilities") + ->withOutputParameter("capabilities", (void**) capabilities); return mock_c()->returnValue().value.intValue; } celix_status_t manifestParser_getRequirements(manifest_parser_pt parser, linked_list_pt *requirements) { - mock_c()->actualCall("bundle_getCurrentModule"); + mock_c()->actualCall("manifestParser_getCurrentRequirements") + ->withOutputParameter("requirements", (void**) requirements); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/module_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/module_mock.c b/framework/private/mock/module_mock.c index 189713f..36c70ca 100644 --- a/framework/private/mock/module_mock.c +++ b/framework/private/mock/module_mock.c @@ -56,7 +56,7 @@ int module_equals(void * module, void * compare) { } wire_pt module_getWire(module_pt module, char * serviceName) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getwire"); return mock_c()->returnValue().value.pointerValue; } @@ -74,71 +74,71 @@ celix_status_t module_getSymbolicName(module_pt module, char **symbolicName) { } char * module_getId(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getId"); return (char *) mock_c()->returnValue().value.stringValue; } linked_list_pt module_getWires(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getWires"); return mock_c()->returnValue().value.pointerValue; } void module_setWires(module_pt module, linked_list_pt wires) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_setWires"); } bool module_isResolved(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_isResolved"); return mock_c()->returnValue().value.intValue; } void module_setResolved(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_setResolved"); } bundle_pt module_getBundle(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getBundle"); return mock_c()->returnValue().value.pointerValue; } linked_list_pt module_getRequirements(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getRequirements"); return mock_c()->returnValue().value.pointerValue; } linked_list_pt module_getCapabilities(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getCapabilities"); return mock_c()->returnValue().value.pointerValue; } array_list_pt module_getDependentImporters(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getDependentImporters"); return mock_c()->returnValue().value.pointerValue; } void module_addDependentImporter(module_pt module, module_pt importer) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_addDependentImporter"); } void module_removeDependentImporter(module_pt module, module_pt importer) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_removeDependentImporter"); } array_list_pt module_getDependentRequirers(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getDependentRequirers"); return mock_c()->returnValue().value.pointerValue; } void module_addDependentRequirer(module_pt module, module_pt requirer) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_addDependentRequirer"); } void module_removeDependentRequirer(module_pt module, module_pt requirer) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_removeDependentRequirer"); } array_list_pt module_getDependents(module_pt module) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("module_getDependents"); return mock_c()->returnValue().value.pointerValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/requirement_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/requirement_mock.c b/framework/private/mock/requirement_mock.c index 4a12203..38de079 100644 --- a/framework/private/mock/requirement_mock.c +++ b/framework/private/mock/requirement_mock.c @@ -37,22 +37,30 @@ celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes } celix_status_t requirement_destroy(requirement_pt requirement) { - mock_c()->actualCall("requirement_destroy"); + mock_c()->actualCall("requirement_destroy") + ->withPointerParameters("requirement", requirement); return mock_c()->returnValue().value.intValue; } celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("requirement_getVersionRange") + ->withPointerParameters("requirement", requirement) + ->withOutputParameter("range", range); return mock_c()->returnValue().value.intValue; } celix_status_t requirement_getTargetName(requirement_pt requirement, char **targetName) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("requirement_getTargetName") + ->withPointerParameters("requirement", requirement) + ->withOutputParameter("targetName", targetName); return mock_c()->returnValue().value.intValue; } celix_status_t requirement_isSatisfied(requirement_pt requirement, capability_pt capability, bool *inRange) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("requirement_isSatisfied") + ->withPointerParameters("requirement", requirement) + ->withPointerParameters("capability", capability) + ->withOutputParameter("inRange", inRange); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/service_registration_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/service_registration_mock.c b/framework/private/mock/service_registration_mock.c index 88de184..e54be41 100644 --- a/framework/private/mock/service_registration_mock.c +++ b/framework/private/mock/service_registration_mock.c @@ -50,6 +50,8 @@ service_registration_pt serviceRegistration_createServiceFactory(service_registr } celix_status_t serviceRegistration_destroy(service_registration_pt registration) { + mock_c()->actualCall("serviceRegistration_destroy") + ->withPointerParameters("registration", registration); return mock_c()->returnValue().value.intValue; } @@ -84,7 +86,7 @@ celix_status_t serviceRegistration_ungetService(service_registration_pt registra mock_c()->actualCall("serviceRegistration_ungetService") ->withPointerParameters("registration", registration) ->withPointerParameters("bundle", bundle) - ->withPointerParameters("service", *service); + ->withOutputParameter("service", service); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/version_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/version_mock.c b/framework/private/mock/version_mock.c index ac83cd6..c965d4f 100644 --- a/framework/private/mock/version_mock.c +++ b/framework/private/mock/version_mock.c @@ -28,24 +28,32 @@ #include "version.h" celix_status_t version_createVersion(int major, int minor, int micro, char * qualifier, version_pt *version) { - mock_c()->actualCall("version_createVersion"); + mock_c()->actualCall("version_createVersion") + ->withIntParameters("major", major) + ->withIntParameters("minor", minor) + ->withIntParameters("micro", micro) + ->withStringParameters("qualifier", qualifier) + ->withOutputParameter("version", version); return mock_c()->returnValue().value.intValue; } celix_status_t version_destroy(version_pt version) { - mock_c()->actualCall("version_destroy"); + mock_c()->actualCall("version_destroy") + ->withPointerParameters("version", version); return mock_c()->returnValue().value.intValue; } celix_status_t version_clone(version_pt version, version_pt *clone) { - mock_c()->actualCall("version_clone"); + mock_c()->actualCall("version_clone") + ->withPointerParameters("version", version) + ->withOutputParameter("clone", clone); return mock_c()->returnValue().value.intValue; } celix_status_t version_createVersionFromString(char * versionStr, version_pt *version) { mock_c()->actualCall("version_createVersionFromString") - ->withStringParameters("versionStr", versionStr) - ->withOutputParameter("version", (void **) version); + ->withStringParameters("versionStr", versionStr) + ->withOutputParameter("version", (void **) version); return mock_c()->returnValue().value.intValue; } @@ -56,36 +64,46 @@ celix_status_t version_createEmptyVersion(version_pt *version) { } celix_status_t version_getMajor(version_pt version, int *major) { - mock_c()->actualCall("version_getMajor"); + mock_c()->actualCall("version_getMajor") + ->withPointerParameters("version", version) + ->withOutputParameter("major", major); return mock_c()->returnValue().value.intValue; } celix_status_t version_getMinor(version_pt version, int *minor) { - mock_c()->actualCall("version_getMinor"); + mock_c()->actualCall("version_getMinor") + ->withPointerParameters("version", version) + ->withOutputParameter("minor", minor); return mock_c()->returnValue().value.intValue; } celix_status_t version_getMicro(version_pt version, int *micro) { - mock_c()->actualCall("version_getMicro"); + mock_c()->actualCall("version_getMicro") + ->withPointerParameters("version", version) + ->withOutputParameter("micro", micro); return mock_c()->returnValue().value.intValue; } celix_status_t version_getQualifier(version_pt version, char **qualifier) { - mock_c()->actualCall("version_getQualifier"); + mock_c()->actualCall("version_getQualifier") + ->withPointerParameters("version", version) + ->withOutputParameter("qualifier", qualifier); return mock_c()->returnValue().value.intValue; } celix_status_t version_compareTo(version_pt version, version_pt compare, int *result) { mock_c()->actualCall("version_compareTo") - ->withPointerParameters("version", version) - ->withPointerParameters("compare", compare) - ->withOutputParameter("result", result); + ->withPointerParameters("version", version) + ->withPointerParameters("compare", compare) + ->withOutputParameter("result", result); return CELIX_SUCCESS; } celix_status_t version_toString(version_pt version, char **string) { - mock_c()->actualCall("version_toString"); + mock_c()->actualCall("version_toString") + ->withPointerParameters("version", version) + ->withOutputParameter("string", string); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/version_range_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/version_range_mock.c b/framework/private/mock/version_range_mock.c index b8762fa..14788d4 100644 --- a/framework/private/mock/version_range_mock.c +++ b/framework/private/mock/version_range_mock.c @@ -28,12 +28,18 @@ #include "version_range.h" celix_status_t versionRange_createVersionRange(version_pt low, bool isLowInclusive, version_pt high, bool isHighInclusive, version_range_pt *versionRange) { - mock_c()->actualCall("versionRange_createVersionRange"); + mock_c()->actualCall("versionRange_createVersionRange") + ->withPointerParameters("low", low) + ->withIntParameters("isLowInclusive", isLowInclusive) + ->withPointerParameters("high", high) + ->withIntParameters("isHighInclusive", isHighInclusive) + ->withOutputParameter("versionRange", versionRange); return mock_c()->returnValue().value.intValue; } celix_status_t versionRange_destroy(version_range_pt range) { - mock_c()->actualCall("versionRange_destroy"); + mock_c()->actualCall("versionRange_destroy") + ->withPointerParameters("range", range); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/mock/wire_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/wire_mock.c b/framework/private/mock/wire_mock.c index 2156154..017f861 100644 --- a/framework/private/mock/wire_mock.c +++ b/framework/private/mock/wire_mock.c @@ -29,32 +29,46 @@ celix_status_t wire_create(module_pt importer, requirement_pt requirement, module_pt exporter, capability_pt capability, wire_pt *wire) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("wire_create") + ->withPointerParameters("importer", importer) + ->withPointerParameters("requirement", requirement) + ->withPointerParameters("exporter", exporter) + ->withPointerParameters("capability", capability) + ->withOutputParameter("wire", wire); return mock_c()->returnValue().value.intValue; } celix_status_t wire_destroy(wire_pt wire) { - mock_c()->actualCall("wire_destroy"); + mock_c()->actualCall("wire_destroy") + ->withPointerParameters("wire", wire); return mock_c()->returnValue().value.intValue; } celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("wire_getCapability") + ->withPointerParameters("wire", wire) + ->withOutputParameter("capability", (void**) capability); return mock_c()->returnValue().value.intValue; } celix_status_t wire_getRequirement(wire_pt wire, requirement_pt *requirement) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("wire_getRequirement") + ->withPointerParameters("wire", wire) + ->withOutputParameter("requirement", (void**) requirement); return mock_c()->returnValue().value.intValue; } celix_status_t wire_getImporter(wire_pt wire, module_pt *importer) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("wire_getImporter") + ->withPointerParameters("wire", wire) + ->withOutputParameter("importer", (void**) importer); return mock_c()->returnValue().value.intValue; } celix_status_t wire_getExporter(wire_pt wire, module_pt *exporter) { - mock_c()->actualCall("requirement_create"); + mock_c()->actualCall("wire_getExporter") + ->withPointerParameters("wire", wire) + ->withOutputParameter("exporter", (void**) exporter); return mock_c()->returnValue().value.intValue; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/bundle.c ---------------------------------------------------------------------- diff --git a/framework/private/src/bundle.c b/framework/private/src/bundle.c index dacd9c5..366363c 100644 --- a/framework/private/src/bundle.c +++ b/framework/private/src/bundle.c @@ -34,7 +34,7 @@ celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module); celix_status_t bundle_closeRevisions(bundle_pt bundle); -celix_status_t bundle_create(bundle_pt * bundle, framework_logger_pt logger) { +celix_status_t bundle_create(bundle_pt * bundle) { celix_status_t status; bundle_archive_pt archive = NULL; @@ -42,7 +42,7 @@ celix_status_t bundle_create(bundle_pt * bundle, framework_logger_pt logger) { if (*bundle == NULL) { return CELIX_ENOMEM; } - status = bundleArchive_createSystemBundleArchive(logger, &archive); + status = bundleArchive_createSystemBundleArchive(&archive); if (status == CELIX_SUCCESS) { module_pt module; @@ -85,6 +85,8 @@ celix_status_t bundle_createFromArchive(bundle_pt * bundle, framework_pt framewo (*bundle)->archive = archive; (*bundle)->activator = NULL; (*bundle)->context = NULL; + (*bundle)->handle = NULL; + (*bundle)->manifest = NULL; (*bundle)->framework = framework; (*bundle)->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED; (*bundle)->modules = NULL; @@ -104,7 +106,7 @@ celix_status_t bundle_createFromArchive(bundle_pt * bundle, framework_pt framewo status = CELIX_FILE_IO_EXCEPTION; } - framework_logIfError(framework->logger, status, NULL, "Failed to create bundle"); + framework_logIfError(logger, status, NULL, "Failed to create bundle"); return status; } @@ -210,17 +212,14 @@ celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module) { status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision)); status = CELIX_DO_IF(status, bundleRevision_getManifest(revision, &headerMap)); if (status == CELIX_SUCCESS) { - long bundleId; + long bundleId = 0; status = bundleArchive_getId(bundle->archive, &bundleId); if (status == CELIX_SUCCESS) { int revision = 0; char moduleId[512]; - char *mId; snprintf(moduleId, sizeof(moduleId), "%ld.%d", bundleId, revision); - mId = strdup(moduleId); - *module = module_create(headerMap, mId, bundle); - free(mId); + *module = module_create(headerMap, moduleId, bundle); if (*module != NULL) { version_pt bundleVersion = module_getVersion(*module); @@ -262,7 +261,7 @@ celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to create module"); + framework_logIfError(logger, status, NULL, "Failed to create module"); return status; } @@ -285,7 +284,7 @@ celix_status_t bundle_startWithOptions(bundle_pt bundle, int options) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to start bundle"); + framework_logIfError(logger, status, NULL, "Failed to start bundle"); return status; } @@ -305,7 +304,7 @@ celix_status_t bundle_update(bundle_pt bundle, char *inputFile) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to update bundle"); + framework_logIfError(logger, status, NULL, "Failed to update bundle"); return status; } @@ -328,7 +327,7 @@ celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to stop bundle"); + framework_logIfError(logger, status, NULL, "Failed to stop bundle"); return status; } @@ -347,7 +346,7 @@ celix_status_t bundle_uninstall(bundle_pt bundle) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to uninstall bundle"); + framework_logIfError(logger, status, NULL, "Failed to uninstall bundle"); return status; } @@ -363,7 +362,7 @@ celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to set persistent state to inactive"); + framework_logIfError(logger, status, NULL, "Failed to set persistent state to inactive"); return status; } @@ -379,7 +378,7 @@ celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to set persistent state to uninstalled"); + framework_logIfError(logger, status, NULL, "Failed to set persistent state to uninstalled"); return status; } @@ -406,7 +405,7 @@ celix_status_t bundle_revise(bundle_pt bundle, char * location, char *inputFile) } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to revise bundle"); + framework_logIfError(logger, status, NULL, "Failed to revise bundle"); return status; } @@ -435,7 +434,7 @@ celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to check if bundle is the systembundle"); + framework_logIfError(logger, status, NULL, "Failed to check if bundle is the systembundle"); return status; } @@ -444,7 +443,7 @@ celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable) { celix_status_t status; status = celixThreadMutex_lock(&bundle->lock); - if (status != 0) { + if (status != CELIX_SUCCESS) { status = CELIX_BUNDLE_EXCEPTION; } else { bool equals; @@ -454,12 +453,12 @@ celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable) { } status = celixThreadMutex_unlock(&bundle->lock); - if (status != 0) { + if (status != CELIX_SUCCESS) { status = CELIX_BUNDLE_EXCEPTION; } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to check if bundle is lockable"); + framework_logIfError(logger, status, NULL, "Failed to check if bundle is lockable"); return status; } @@ -468,18 +467,18 @@ celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread) celix_status_t status; status = celixThreadMutex_lock(&bundle->lock); - if (status != 0) { + if (status != CELIX_SUCCESS) { status = CELIX_BUNDLE_EXCEPTION; } else { *thread = bundle->lockThread; status = celixThreadMutex_unlock(&bundle->lock); - if (status != 0) { + if (status != CELIX_SUCCESS) { status = CELIX_BUNDLE_EXCEPTION; } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to get locking thread"); + framework_logIfError(logger, status, NULL, "Failed to get locking thread"); return status; } @@ -503,7 +502,7 @@ celix_status_t bundle_lock(bundle_pt bundle, bool *locked) { celixThreadMutex_unlock(&bundle->lock); - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to lock bundle"); + framework_logIfError(logger, status, NULL, "Failed to lock bundle"); return status; } @@ -521,19 +520,21 @@ celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked) { status = thread_equalsSelf(bundle->lockThread, &equals); if (status == CELIX_SUCCESS) { if ((bundle->lockCount > 0) && !equals) { - return false; - } - bundle->lockCount--; - if (bundle->lockCount == 0) { - bundle->lockThread = celix_thread_default; + *unlocked = false; } - *unlocked = true; - } + else{ + bundle->lockCount--; + if (bundle->lockCount == 0) { + bundle->lockThread = celix_thread_default; + } + *unlocked = true; + } + } } celixThreadMutex_unlock(&bundle->lock); - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to unlock bundle"); + framework_logIfError(logger, status, NULL, "Failed to unlock bundle"); return status; } @@ -550,7 +551,7 @@ celix_status_t bundle_close(bundle_pt bundle) { bundleArchive_close(archive); } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to close bundle"); + framework_logIfError(logger, status, NULL, "Failed to close bundle"); return status; } @@ -567,7 +568,7 @@ celix_status_t bundle_closeAndDelete(bundle_pt bundle) { bundleArchive_closeAndDelete(archive); } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to close and delete bundle"); + framework_logIfError(logger, status, NULL, "Failed to close and delete bundle"); return status; } @@ -608,7 +609,7 @@ celix_status_t bundle_refresh(bundle_pt bundle) { } } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to refresh bundle"); + framework_logIfError(logger, status, NULL, "Failed to refresh bundle"); return status; } @@ -621,7 +622,7 @@ celix_status_t bundle_getBundleId(bundle_pt bundle, long *id) { status = bundleArchive_getId(archive, id); } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to get bundle id"); + framework_logIfError(logger, status, NULL, "Failed to get bundle id"); return status; } @@ -641,7 +642,7 @@ celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) { status = fw_getBundleServicesInUse(bundle->framework, bundle, list); - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to get in use services"); + framework_logIfError(logger, status, NULL, "Failed to get in use services"); return status; } @@ -655,7 +656,7 @@ celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) { status = CELIX_ILLEGAL_ARGUMENT; } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to set framework"); + framework_logIfError(logger, status, NULL, "Failed to set framework"); return status; } @@ -669,7 +670,7 @@ celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) { status = CELIX_ILLEGAL_ARGUMENT; } - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to get framework"); + framework_logIfError(logger, status, NULL, "Failed to get framework"); return status; } http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/bundle_archive.c ---------------------------------------------------------------------- diff --git a/framework/private/src/bundle_archive.c b/framework/private/src/bundle_archive.c index a676d6a..c1a23aa 100644 --- a/framework/private/src/bundle_archive.c +++ b/framework/private/src/bundle_archive.c @@ -45,7 +45,6 @@ struct bundleArchive { linked_list_pt revisions; long refreshCount; time_t lastModified; - framework_logger_pt logger; bundle_state_e persistentState; }; @@ -63,7 +62,7 @@ static celix_status_t bundleArchive_reviseInternal(bundle_archive_pt archive, bo static celix_status_t bundleArchive_readLastModified(bundle_archive_pt archive, time_t *time); static celix_status_t bundleArchive_writeLastModified(bundle_archive_pt archive); -celix_status_t bundleArchive_createSystemBundleArchive(framework_logger_pt logger, bundle_archive_pt *bundle_archive) { +celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive) { celix_status_t status = CELIX_SUCCESS; char *error = NULL; bundle_archive_pt archive; @@ -84,7 +83,6 @@ celix_status_t bundleArchive_createSystemBundleArchive(framework_logger_pt logge archive->archiveRootDir = NULL; archive->refreshCount = -1; archive->persistentState = OSGI_FRAMEWORK_BUNDLE_UNKNOWN; - archive->logger = logger; time(&archive->lastModified); *bundle_archive = archive; @@ -97,7 +95,7 @@ celix_status_t bundleArchive_createSystemBundleArchive(framework_logger_pt logge return status; } -celix_status_t bundleArchive_create(framework_logger_pt logger, char * archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt *bundle_archive) { +celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt *bundle_archive) { celix_status_t status = CELIX_SUCCESS; char *error = NULL; bundle_archive_pt archive; @@ -115,9 +113,8 @@ celix_status_t bundleArchive_create(framework_logger_pt logger, char * archiveRo archive->id = id; archive->location = strdup(location); archive->archiveRootDir = NULL; - archive->archiveRoot = archiveRoot; + archive->archiveRoot = strdup(archiveRoot); archive->refreshCount = -1; - archive->logger = logger; time(&archive->lastModified); status = bundleArchive_initialize(archive); @@ -177,7 +174,7 @@ celix_status_t bundleArchive_recreate(char * archiveRoot, bundle_archive_pt *bun } else { status = linkedList_create(&archive->revisions); if (status == CELIX_SUCCESS) { - archive->archiveRoot = archiveRoot; + archive->archiveRoot = strdup(archiveRoot); archive->archiveRootDir = NULL; archive->id = -1; archive->persistentState = -1; @@ -565,7 +562,7 @@ static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_pt bundle_revision_pt revision = NULL; sprintf(root, "%s/version%ld.%ld", archive->archiveRoot, refreshCount, revNr); - status = bundleRevision_create(logger, root, location, revNr, inputFile, &revision); + status = bundleRevision_create(root, location, revNr, inputFile, &revision); if (status == CELIX_SUCCESS) { *bundle_revision = revision; http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/bundle_cache.c ---------------------------------------------------------------------- diff --git a/framework/private/src/bundle_cache.c b/framework/private/src/bundle_cache.c index 0f1da80..6eaf5d0 100644 --- a/framework/private/src/bundle_cache.c +++ b/framework/private/src/bundle_cache.c @@ -37,7 +37,7 @@ static celix_status_t bundleCache_deleteTree(bundle_cache_pt cache, char * directory); -celix_status_t bundleCache_create(properties_pt configurationMap, framework_logger_pt logger, bundle_cache_pt *bundle_cache) { +celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache) { celix_status_t status; bundle_cache_pt cache; @@ -52,17 +52,15 @@ celix_status_t bundleCache_create(properties_pt configurationMap, framework_logg cacheDir = ".cache"; } cache->cacheDir = cacheDir; - cache->logger = logger; *bundle_cache = cache; status = CELIX_SUCCESS; } else { status = CELIX_ILLEGAL_ARGUMENT; } - - framework_logIfError(cache->logger, status, NULL, "Failed to create bundle cache"); } + framework_logIfError(logger, status, NULL, "Failed to create bundle cache"); return status; } @@ -123,7 +121,7 @@ celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *arc status = CELIX_FILE_IO_EXCEPTION; } - framework_logIfError(cache->logger, status, NULL, "Failed to get bundle archives"); + framework_logIfError(logger, status, NULL, "Failed to get bundle archives"); return status; } @@ -134,10 +132,10 @@ celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, char * if (cache && location) { snprintf(archiveRoot, sizeof(archiveRoot), "%s/bundle%ld", cache->cacheDir, id); - status = bundleArchive_create(cache->logger, strdup(archiveRoot), id, location, inputFile, bundle_archive); + status = bundleArchive_create(archiveRoot, id, location, inputFile, bundle_archive); } - framework_logIfError(cache->logger, status, NULL, "Failed to create archive"); + framework_logIfError(logger, status, NULL, "Failed to create archive"); return status; }
