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

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

commit 410d959abf76d7a1649ebc7a3ded6427958a382d
Author: Pepijn Noltes <[email protected]>
AuthorDate: Mon Mar 9 13:37:15 2020 +0100

    #91 Refactors rsa tests, so that the individual test can be run separately 
and fixes an issue with recursive calls and double frees in libdfi.
---
 .../gtest/src/rsa_client_server_tests.cc           | 113 ++++++++++++++++-----
 libs/dfi/src/dyn_type.c                            |   3 +-
 2 files changed, 90 insertions(+), 26 deletions(-)

diff --git 
a/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_client_server_tests.cc
 
b/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_client_server_tests.cc
index 9c99504..9c42951 100644
--- 
a/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_client_server_tests.cc
+++ 
b/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_client_server_tests.cc
@@ -64,50 +64,89 @@ extern "C" {
         celix_frameworkFactory_destroyFramework(clientFramework);
     }
 
-    static void testCallback(void *handle __attribute__((unused)), void *svc) {
+    static void testComplex(void *handle __attribute__((unused)), void *svc) {
         auto *tst = static_cast<tst_service_t *>(svc);
 
-        bool ok;
-
-        bool discovered = tst->isCalcDiscovered(tst->handle);
+        bool discovered = tst->isRemoteExampleDiscovered(tst->handle);
         ASSERT_TRUE(discovered);
 
-        ok = tst->testCalculator(tst->handle);
+        bool ok = tst->testRemoteComplex(tst->handle);
         ASSERT_TRUE(ok);
+    };
+
+    static void testAction(void *handle __attribute__((unused)), void *svc) {
+        auto *tst = static_cast<tst_service_t *>(svc);
 
-        discovered = tst->isRemoteExampleDiscovered(tst->handle);
+        bool discovered = tst->isRemoteExampleDiscovered(tst->handle);
         ASSERT_TRUE(discovered);
 
-        ok = tst->testRemoteComplex(tst->handle);
+        bool ok = tst->testRemoteAction(tst->handle);
         ASSERT_TRUE(ok);
+    };
+
+    static void testNumbers(void *handle __attribute__((unused)), void *svc) {
+        auto *tst = static_cast<tst_service_t *>(svc);
 
-        ok = tst->testRemoteAction(tst->handle);
+        bool discovered = tst->isRemoteExampleDiscovered(tst->handle);
+        ASSERT_TRUE(discovered);
+
+        bool ok = tst->testRemoteNumbers(tst->handle);
         ASSERT_TRUE(ok);
+    };
 
-        ok = tst->testRemoteNumbers(tst->handle);
+    static void testString(void *handle __attribute__((unused)), void *svc) {
+        auto *tst = static_cast<tst_service_t *>(svc);
+
+        bool discovered = tst->isRemoteExampleDiscovered(tst->handle);
+        ASSERT_TRUE(discovered);
+
+        bool ok = tst->testRemoteString(tst->handle);
         ASSERT_TRUE(ok);
+    };
+
+    static void testEnum(void *handle __attribute__((unused)), void *svc) {
+        auto *tst = static_cast<tst_service_t *>(svc);
 
-        ok = tst->testRemoteString(tst->handle);
+        bool discovered = tst->isRemoteExampleDiscovered(tst->handle);
+        ASSERT_TRUE(discovered);
+
+        bool ok = tst->testRemoteEnum(tst->handle);
         ASSERT_TRUE(ok);
+    };
 
-        ok = tst->testRemoteConstString(tst->handle);
+    static void testConstString(void *handle __attribute__((unused)), void 
*svc) {
+        auto *tst = static_cast<tst_service_t *>(svc);
+
+        bool discovered = tst->isRemoteExampleDiscovered(tst->handle);
+        ASSERT_TRUE(discovered);
+
+        bool ok = tst->testRemoteConstString(tst->handle);
         ASSERT_TRUE(ok);
+    };
+
+    static void testCalculator(void *handle __attribute__((unused)), void 
*svc) {
+        auto *tst = static_cast<tst_service_t *>(svc);
 
-        //TODO fix for apple dfi handling, see issue #91
-//        ok = tst->testRemoteEnum(tst->handle);
-//        ASSERT_TRUE(ok);
+        bool ok;
+
+        bool discovered = tst->isCalcDiscovered(tst->handle);
+        ASSERT_TRUE(discovered);
+
+        ok = tst->testCalculator(tst->handle);
+        ASSERT_TRUE(ok);
     };
 
-    static void test(void) {
-        celix_service_use_options_t opts{};
-        opts.filter.serviceName = TST_SERVICE_NAME;
-        opts.use = testCallback;
-        opts.filter.ignoreServiceLanguage = true;
-        opts.waitTimeoutInSeconds = 2;
-        bool called = celix_bundleContext_useServiceWithOptions(clientContext, 
&opts);
-        ASSERT_TRUE(called);
-    }
+}
 
+template<typename F>
+static void test(F&& f) {
+    celix_service_use_options_t opts{};
+    opts.filter.serviceName = TST_SERVICE_NAME;
+    opts.use = f;
+    opts.filter.ignoreServiceLanguage = true;
+    opts.waitTimeoutInSeconds = 2;
+    bool called = celix_bundleContext_useServiceWithOptions(clientContext, 
&opts);
+    ASSERT_TRUE(called);
 }
 
 class RsaDfiClientServerTests : public ::testing::Test {
@@ -122,6 +161,30 @@ public:
 };
 
 
-TEST_F(RsaDfiClientServerTests, Test1) {
-    test();
+TEST_F(RsaDfiClientServerTests, TestRemoteCalculator) {
+    test(testCalculator);
+}
+
+TEST_F(RsaDfiClientServerTests, TestRemoteComplex) {
+    test(testComplex);
+}
+
+TEST_F(RsaDfiClientServerTests, TestRemoteNumbers) {
+    test(testNumbers);
+}
+
+TEST_F(RsaDfiClientServerTests, TestRemoteString) {
+    test(testString);
+}
+
+TEST_F(RsaDfiClientServerTests, TestRemoteConstString) {
+    test(testConstString);
+}
+
+TEST_F(RsaDfiClientServerTests, TestRemoteEnum) {
+    test(testEnum);
+}
+
+TEST_F(RsaDfiClientServerTests, TestRemoteAction) {
+    test(testAction);
 }
diff --git a/libs/dfi/src/dyn_type.c b/libs/dfi/src/dyn_type.c
index 09cca39..4f93fb9 100644
--- a/libs/dfi/src/dyn_type.c
+++ b/libs/dfi/src/dyn_type.c
@@ -679,7 +679,8 @@ void dynType_deepFree(dyn_type *type, void *loc, bool 
alsoDeleteSelf) {
         char *text = NULL;
         switch (type->type) {
             case DYN_TYPE_REF:
-                dynType_deepFree(type->ref.ref, loc, alsoDeleteSelf);
+                //NOTE: do not recursively forward asloDeleteSelf, because 
this is already handled in this function)
+                dynType_deepFree(type->ref.ref, loc, false);
                 break;
             case DYN_TYPE_COMPLEX :
                 dynType_freeComplexType(type, loc);

Reply via email to