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

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

commit 9002e9ea63e70ac12a8bce67331a9eeea6a43364
Author: PengZheng <[email protected]>
AuthorDate: Fri May 5 14:42:20 2023 +0800

    Add a test case to illustrate lack of export symbols to be used as valid 
caller of the error injection target.
---
 libs/error_injector/api/celix_error_injector.h            | 12 ++++++++++++
 libs/framework/gtest/CMakeLists.txt                       |  2 +-
 .../src/CelixBundleContextBundlesWithErrorTestSuite.cc    | 15 +++++++++++++++
 libs/framework/src/module.c                               |  3 ++-
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/libs/error_injector/api/celix_error_injector.h 
b/libs/error_injector/api/celix_error_injector.h
index 3eef3a78..092c47eb 100644
--- a/libs/error_injector/api/celix_error_injector.h
+++ b/libs/error_injector/api/celix_error_injector.h
@@ -82,6 +82,18 @@ do {
             case 4:                                                            
                          \
                 CELIX_EI_GET_CALLER(addr, 4);                                  
                          \
                 break;                                                         
                          \
+            case 5:                                                            
                          \
+                CELIX_EI_GET_CALLER(addr, 5);                                  
                          \
+                break;                                                         
                          \
+            case 6:                                                            
                          \
+                CELIX_EI_GET_CALLER(addr, 6);                                  
                          \
+                break;                                                         
                          \
+            case 7:                                                            
                          \
+                CELIX_EI_GET_CALLER(addr, 7);                                  
                          \
+                break;                                                         
                          \
+            case 8:                                                            
                          \
+                CELIX_EI_GET_CALLER(addr, 8);                                  
                          \
+                break;                                                         
                          \
             default:                                                           
                          \
                 assert(0);                                                     
                          \
             }                                                                  
                          \
diff --git a/libs/framework/gtest/CMakeLists.txt 
b/libs/framework/gtest/CMakeLists.txt
index 5c7e3637..98db4391 100644
--- a/libs/framework/gtest/CMakeLists.txt
+++ b/libs/framework/gtest/CMakeLists.txt
@@ -130,7 +130,7 @@ if (LINKER_WRAP_SUPPORTED)
             SIMPLE_TEST_BUNDLE1_LOCATION="${SIMPLE_TEST_BUNDLE1}"
             SIMPLE_CXX_BUNDLE_LOC="${SIMPLE_CXX_BUNDLE_LOC}"
     )
-    target_include_directories(test_framework_with_ei PRIVATE ../src)
+    target_include_directories(test_framework_with_ei PRIVATE ../src 
../include_deprecated)
     add_celix_bundle_dependencies(test_framework_with_ei simple_test_bundle1 
simple_cxx_bundle)
     celix_target_embedded_bundles(test_framework_with_ei simple_test_bundle1)
     celix_deprecated_utils_headers(test_framework_with_ei)
diff --git 
a/libs/framework/gtest/src/CelixBundleContextBundlesWithErrorTestSuite.cc 
b/libs/framework/gtest/src/CelixBundleContextBundlesWithErrorTestSuite.cc
index 3959a6c3..c1b533d3 100644
--- a/libs/framework/gtest/src/CelixBundleContextBundlesWithErrorTestSuite.cc
+++ b/libs/framework/gtest/src/CelixBundleContextBundlesWithErrorTestSuite.cc
@@ -24,7 +24,9 @@
 extern "C" {
 #include "celix_libloader.h"
 }
+#include "celix_module_private.h"
 #include "celix_properties.h"
+#include "celix_utils_ei.h"
 #include "dlfcn_ei.h"
 
 class CelixBundleContextBundlesWithErrorTestSuite : public ::testing::Test {
@@ -46,6 +48,7 @@ public:
     ~CelixBundleContextBundlesWithErrorTestSuite() override {
         celix_frameworkFactory_destroyFramework(fw);
         celix_ei_expect_dlopen(nullptr, 0, nullptr);
+        celix_ei_expect_celix_utils_writeOrCreateString(nullptr, 0, nullptr);
     }
 
     
CelixBundleContextBundlesWithErrorTestSuite(CelixBundleContextBundlesWithErrorTestSuite&&)
 = delete;
@@ -77,3 +80,15 @@ TEST_F(CelixBundleContextBundlesWithErrorTestSuite, 
privateLibraryLoadErrorAbort
     });
     ASSERT_TRUE(called);
 }
+
+TEST_F(CelixBundleContextBundlesWithErrorTestSuite, failedToGetLibraryPath) {
+    celix_ei_expect_celix_utils_writeOrCreateString((void 
*)celix_framework_installBundle, 8, nullptr, 2);
+    long bndId = celix_bundleContext_installBundle(ctx, SIMPLE_CXX_BUNDLE_LOC, 
true);
+    ASSERT_TRUE(bndId > 0); //bundle is installed, but not started
+
+    bool called = celix_bundleContext_useBundle(ctx, bndId, nullptr, [](void 
*/*handle*/, const celix_bundle_t *bnd) {
+        auto state = celix_bundle_getState(bnd);
+        ASSERT_EQ(state, CELIX_BUNDLE_STATE_INSTALLED);
+    });
+    ASSERT_TRUE(called);
+}
diff --git a/libs/framework/src/module.c b/libs/framework/src/module.c
index 0c35462f..1dec4ffb 100644
--- a/libs/framework/src/module.c
+++ b/libs/framework/src/module.c
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -409,7 +410,7 @@ static celix_status_t 
celix_module_loadLibraryForManifestEntry(celix_module_t* m
 
     if (!path) {
         fw_logCode(module->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Cannot 
create full library path");
-        return status;
+        return errno;
     }
 
     status = celix_module_loadLibrary(module, path, handle);

Reply via email to