This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/refactor_c_dep_man_service_trackers in repository https://gitbox.apache.org/repos/asf/celix.git
commit af00195123d94e4e0d068d568c7386663806ff0b Merge: 58ccb25 0870cd9 Author: Pepijn Noltes <[email protected]> AuthorDate: Mon Jan 4 18:44:37 2021 +0100 Merge branch 'master' into feature/refactor_c_dep_man_service_trackers # Conflicts: # bundles/pubsub/test/CMakeLists.txt # libs/framework/gtest/src/single_framework_test.cpp # libs/utils/gtest/CMakeLists.txt CMakeLists.txt | 4 +- bundles/http_admin/http_admin/src/http_admin.c | 7 +- .../log_admin/gtest/src/LogAdminTestSuite.cc | 46 +- bundles/logging/log_admin/src/celix_log_admin.c | 82 +- bundles/pubsub/pubsub_admin_tcp/CMakeLists.txt | 1 + .../pubsub/pubsub_admin_tcp/src/psa_activator.c | 4 +- .../src/pubsub_psa_tcp_constants.h | 37 +- .../pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c | 58 +- .../pubsub_admin_tcp/src/pubsub_tcp_common.c} | 24 +- .../pubsub_admin_tcp/src/pubsub_tcp_common.h | 2 + .../pubsub_admin_tcp/src/pubsub_tcp_handler.c | 860 ++++++++++--------- .../pubsub_admin_tcp/src/pubsub_tcp_handler.h | 8 +- .../src/pubsub_tcp_topic_receiver.c | 205 +++-- .../src/pubsub_tcp_topic_receiver.h | 3 +- .../pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c | 184 ++-- .../pubsub_admin_tcp/src/pubsub_tcp_topic_sender.h | 13 +- .../pubsub_admin_zmq/v2/src/pubsub_zmq_admin.c | 30 +- .../src/pubsub_wire_protocol_impl.c | 1 + bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c | 6 +- .../pubsub/pubsub_spi/src/pubsub_endpoint_match.c | 39 +- .../src/pubsub_topology_manager.c | 23 +- .../src/pubsub_topology_manager.h | 3 +- bundles/pubsub/pubsub_utils/include/pubsub_utils.h | 3 +- .../pubsub/pubsub_utils/include/pubsub_utils_url.h | 8 +- bundles/pubsub/pubsub_utils/src/pubsub_matching.c | 76 +- bundles/pubsub/pubsub_utils/src/pubsub_utils_url.c | 22 +- bundles/pubsub/test/CMakeLists.txt | 68 +- bundles/pubsub/test/meta_data/ping2.properties | 2 +- .../{ping2.properties => ping3.properties} | 5 +- bundles/pubsub/test/meta_data/pong2.properties | 4 +- .../{ping2.properties => pong3.properties} | 5 +- bundles/pubsub/test/test/loopback_activator.c | 3 +- bundles/pubsub/test/test/tst_endpoint_activator.c | 2 +- .../gtest/src/tst_activator.c | 1 + .../tms_tst/disc_mock/disc_mock_activator.c | 1 + bundles/shell/shell/src/help_command.c | 1 + bundles/shell/shell/src/shell.c | 43 +- bundles/shell/shell/src/shell_private.h | 2 +- bundles/shell/shell/test/CMakeLists.txt | 6 +- .../src/{shell_tests.cpp => ShellTestSuite.cpp} | 104 ++- libs/framework/CMakeLists.txt | 4 - libs/framework/gtest/CMakeLists.txt | 3 +- .../gtest/src/bundle_context_bundles_tests.cpp | 117 ++- .../gtest/src/bundle_context_services_test.cpp | 449 +++++++++- libs/framework/gtest/src/run_tests.cpp | 26 - libs/framework/gtest/src/single_framework_test.cpp | 25 + libs/framework/include/celix_bundle_context.h | 360 +++++++- libs/framework/include/celix_framework.h | 38 + libs/framework/include/service_registry.h | 45 +- libs/framework/include/service_tracker.h | 11 - libs/framework/src/bundle.c | 32 +- libs/framework/src/bundle_context.c | 938 +++++++++++++++++---- libs/framework/src/bundle_context_private.h | 29 +- libs/framework/src/celix_framework_factory.c | 1 - libs/framework/src/framework.c | 862 ++++++++++++------- libs/framework/src/framework_private.h | 124 ++- libs/framework/src/resolver.c | 3 + libs/framework/src/service_registry.c | 476 ++++++----- libs/framework/src/service_registry_private.h | 30 +- libs/framework/src/service_tracker.c | 854 +++++++------------ libs/framework/src/service_tracker_private.h | 59 +- libs/utils/gtest/CMakeLists.txt | 1 + libs/utils/gtest/src/TimeUtilsTestSuite.cc | 57 ++ libs/utils/include/celix_log_utils.h | 5 - libs/utils/include/celix_utils.h | 11 + libs/utils/private/test/utils_test.cpp | 16 +- libs/utils/src/celix_log_utils.c | 14 +- libs/utils/src/utils.c | 19 +- 68 files changed, 4182 insertions(+), 2423 deletions(-) diff --cc libs/framework/gtest/src/single_framework_test.cpp index 9244c8b,28d1a8a..3070ac4 --- a/libs/framework/gtest/src/single_framework_test.cpp +++ b/libs/framework/gtest/src/single_framework_test.cpp @@@ -18,34 -18,83 +18,54 @@@ */ #include <gtest/gtest.h> + #include <atomic> -extern "C" { - #include "celix_launcher.h" #include "celix_framework_factory.h" + #include "celix_framework.h" - static celix_framework_t *framework = nullptr; - static celix_bundle_context_t *context = nullptr; - - static void setupFm(void) { - int rc = 0; - - rc = celixLauncher_launch("config.properties", &framework); - ASSERT_EQ(CELIX_SUCCESS, rc); - - bundle_pt bundle = nullptr; - rc = framework_getFrameworkBundle(framework, &bundle); - ASSERT_EQ(CELIX_SUCCESS, rc); - - rc = bundle_getContext(bundle, &context); - ASSERT_EQ(CELIX_SUCCESS, rc); - } - - static void teardownFm(void) { - - celixLauncher_stop(framework); - celixLauncher_waitForShutdown(framework); - celixLauncher_destroy(framework); - - context = nullptr; - framework = nullptr; - } - - static void testFramework(void) { - //intentional empty. start/shutdown test - printf("testing startup/shutdown single framework\n"); - } +class CelixFramework : public ::testing::Test { +}; -} +TEST_F(CelixFramework, testFramework) { + int rc; + celix_framework_t *framework = nullptr; + celix_bundle_context_t *context = nullptr; + rc = celixLauncher_launch("config.properties", &framework); + EXPECT_EQ(CELIX_SUCCESS, rc); -class CelixFramework : public ::testing::Test { -public: - CelixFramework() { - setupFm(); - } + bundle_pt bundle = nullptr; + rc = framework_getFrameworkBundle(framework, &bundle); + EXPECT_EQ(CELIX_SUCCESS, rc); - ~CelixFramework() override { - teardownFm(); - } -}; + rc = bundle_getContext(bundle, &context); + EXPECT_EQ(CELIX_SUCCESS, rc); -TEST_F(CelixFramework, testFramework) { - testFramework(); + celixLauncher_stop(framework); + celixLauncher_waitForShutdown(framework); + celixLauncher_destroy(framework); } + TEST_F(CelixFramework, testEventQueue) { + long eid = celix_framework_nextEventId(framework); + EXPECT_GE(eid, 0); + celix_framework_waitForGenericEvent(framework, eid); //event never issued so should return directly + + std::atomic<int> count{0}; + celix_framework_fireGenericEvent(framework, eid, -1L, "test", static_cast<void*>(&count), [](void* data) { + auto *c = static_cast<std::atomic<int>*>(data); + *c += 1; + }, static_cast<void*>(&count), [](void* data) { + auto *c = static_cast<std::atomic<int>*>(data); + *c += 3; + }); + + celix_framework_waitForGenericEvent(framework, eid); + EXPECT_EQ(4, count); + } + class FrameworkFactory : public ::testing::Test { public: FrameworkFactory() = default; diff --cc libs/utils/gtest/CMakeLists.txt index b791c42,d00b14b..566ce56 --- a/libs/utils/gtest/CMakeLists.txt +++ b/libs/utils/gtest/CMakeLists.txt @@@ -18,7 -18,7 +18,8 @@@ add_executable(test_utils src/LogUtilsTestSuite.cc + src/VersionRangeTestSuite.cc + src/TimeUtilsTestSuite.cc ) target_link_libraries(test_utils PRIVATE Celix::utils GTest::gtest GTest::gtest_main)
