This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/async_svc_registration
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/async_svc_registration 
by this push:
     new 3776a46  Fixes an issue in the service tracker async test
3776a46 is described below

commit 3776a46662b1ac3cc1ca74e753b2aa2fd9740139
Author: Pepijn Noltes <[email protected]>
AuthorDate: Wed Dec 9 20:01:42 2020 +0100

    Fixes an issue in the service tracker async test
---
 libs/framework/gtest/src/bundle_context_services_test.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libs/framework/gtest/src/bundle_context_services_test.cpp 
b/libs/framework/gtest/src/bundle_context_services_test.cpp
index fac6276..316c912 100644
--- a/libs/framework/gtest/src/bundle_context_services_test.cpp
+++ b/libs/framework/gtest/src/bundle_context_services_test.cpp
@@ -490,15 +490,15 @@ TEST_F(CelixBundleContextServicesTests, 
servicesTrackerTest) {
 }
 
 TEST_F(CelixBundleContextServicesTests, servicesTrackerTestAsync) {
-    int count = 0;
+    std::atomic<int> count {0};
     auto add = [](void *handle, void *svc) {
         ASSERT_TRUE(svc != nullptr);
-        int *c = static_cast<int*>(handle);
+        auto *c = static_cast<std::atomic<int>*>(handle);
         *c += 1;
     };
     auto remove = [](void *handle, void *svc) {
         ASSERT_TRUE(svc != nullptr);
-        int *c = static_cast<int*>(handle);
+        auto *c = static_cast<std::atomic<int>*>(handle);
         *c -= 1;
     };
 
@@ -522,6 +522,8 @@ TEST_F(CelixBundleContextServicesTests, 
servicesTrackerTestAsync) {
 
     celix_bundleContext_stopTrackerAsync(ctx, trackerId, NULL, NULL);
     celix_bundleContext_unregisterServiceAsync(ctx, svcId2, NULL, NULL);
+
+    celix_framework_waitForEmptyEventQueue(fw);
 }
 
 TEST_F(CelixBundleContextServicesTests, servicesTrackerInvalidArgsTest) {

Reply via email to