diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/gtest/src/RsaShmClientServerUnitTestSuite.cc b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/gtest/src/RsaShmClientServerUnitTestSuite.cc index 44ae8d99e..77ab646d5 100644 --- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/gtest/src/RsaShmClientServerUnitTestSuite.cc +++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/gtest/src/RsaShmClientServerUnitTestSuite.cc @@ -35,6 +35,7 @@ #include "socket_ei.h" #include "stdio_ei.h" #include "pthread_ei.h" +#include "celix_properties_ei.h" #include "thpool_ei.h" #include "celix_errno.h" #include @@ -80,6 +81,7 @@ class RsaShmClientServerUnitTestSuite : public ::testing::Test { celix_ei_expect_pthread_cond_timedwait(nullptr, 1, 0); celix_ei_expect_thpool_init(nullptr, 0, nullptr); celix_ei_expect_thpool_add_work(nullptr, 0, 0); + celix_ei_expect_celix_properties_saveToStream(nullptr, 0, CELIX_SUCCESS); } @@ -139,6 +141,44 @@ TEST_F(RsaShmClientServerUnitTestSuite, SendMsg) { rsaShmServer_destroy(server); } +TEST_F(RsaShmClientServerUnitTestSuite, SendMsgErrorEncodePropertiesTest) { + //Given a rsa shm server + rsa_shm_server_t *server = nullptr; + auto status = rsaShmServer_create(ctx.get(), "shm_test_server", logHelper.get(), ReceiveMsgCallback, nullptr, &server); + EXPECT_EQ(CELIX_SUCCESS, status); + EXPECT_NE(nullptr, server); + + //And a rsa shm client + rsa_shm_client_manager_t *clientManager = nullptr; + status = rsaShmClientManager_create(ctx.get(), logHelper.get(), &clientManager); + EXPECT_EQ(CELIX_SUCCESS, status); + EXPECT_NE(nullptr, clientManager); + + // And the client is attached to the server + long serverId = 100;//dummy id + status = rsaShmClientManager_createOrAttachClient(clientManager, "shm_test_server", serverId); + EXPECT_EQ(CELIX_SUCCESS, status); + + //When an error is prepared for saveToStream + celix_ei_expect_celix_properties_saveToStream((void*)rsaShmClientManager_sendMsgTo, 0, ENOMEM); + + //And a message is sent + celix_autoptr(celix_properties_t) metadata = celix_properties_create(); + celix_properties_set(metadata, "CustomKey", "test"); + struct iovec request = {.iov_base = (void*)"request", .iov_len = strlen("request")}; + struct iovec response = {.iov_base = nullptr, .iov_len = 0}; + status = rsaShmClientManager_sendMsgTo(clientManager, "shm_test_server", serverId, metadata, &request, &response); + + //Then the injected error is returned + EXPECT_EQ(ENOMEM, status); + + rsaShmClientManager_destroyOrDetachClient(clientManager, "shm_test_server", serverId); + + rsaShmClientManager_destroy(clientManager); + + rsaShmServer_destroy(server); +} + TEST_F(RsaShmClientServerUnitTestSuite, SendMsgWithNoServer) { rsa_shm_client_manager_t *clientManager = nullptr; auto status = rsaShmClientManager_create(ctx.get(), logHelper.get(), &clientManager); diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c index aa5a480b5..70ffba0b7 100644 --- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c +++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_client.c @@ -280,6 +280,7 @@ celix_status_t rsaShmClientManager_sendMsgTo(rsa_shm_client_manager_t *clientMan if (metadata != NULL) { status = celix_properties_saveToStream(metadata, fp, 0); if (status != CELIX_SUCCESS) { + fclose(fp); celix_logHelper_error( clientManager->logHelper, "RsaShmClient: Error encoding metadata to memory stream. %d.", status); celix_logHelper_logTssErrors(clientManager->logHelper, CELIX_LOG_LEVEL_ERROR); diff --git a/cmake/cmake_celix/ContainerPackaging.cmake b/cmake/cmake_celix/ContainerPackaging.cmake index 77044884c..71c8c3c19 100644 --- a/cmake/cmake_celix/ContainerPackaging.cmake +++ b/cmake/cmake_celix/ContainerPackaging.cmake @@ -217,7 +217,6 @@ function(add_celix_container) file(GENERATE OUTPUT "${STAGE1_LAUNCHER_SRC}" CONTENT "#include -#include #define CELIX_MULTI_LINE_STRING(...) #__VA_ARGS__ diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c index bd60e1837..287a59259 100644 --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@ -574,11 +574,9 @@ static bool framework_autoStartConfiguredBundlesForList(celix_framework_t* fw, } } else { fw_log(fw->logger, - CELIX_LOG_LEVEL_TRACE, - "Cannot start bundle %s (bnd id = %li), because it is already started\n", - bnd->symbolicName, + CELIX_LOG_LEVEL_WARNING, + "Cannot start bundle %s (bnd id = %li) again, already started\n", bnd->symbolicName, bndId); - allStarted = false; } } return allStarted; diff --git a/libs/utils/error_injector/celix_properties/CMakeLists.txt b/libs/utils/error_injector/celix_properties/CMakeLists.txt index aa177a63f..0155b75e7 100644 --- a/libs/utils/error_injector/celix_properties/CMakeLists.txt +++ b/libs/utils/error_injector/celix_properties/CMakeLists.txt @@ -28,6 +28,7 @@ target_link_options(properties_ei INTERFACE LINKER:--wrap,celix_properties_setVersion LINKER:--wrap,celix_properties_setEntry LINKER:--wrap,celix_properties_save + LINKER:--wrap,celix_properties_saveToStream LINKER:--wrap,celix_properties_load ) add_library(Celix::properties_ei ALIAS properties_ei) diff --git a/libs/utils/error_injector/celix_properties/include/celix_properties_ei.h b/libs/utils/error_injector/celix_properties/include/celix_properties_ei.h index 9291d0c5e..a98905c54 100644 --- a/libs/utils/error_injector/celix_properties/include/celix_properties_ei.h +++ b/libs/utils/error_injector/celix_properties/include/celix_properties_ei.h @@ -33,6 +33,7 @@ CELIX_EI_DECLARE(celix_properties_setLong, celix_status_t); CELIX_EI_DECLARE(celix_properties_setVersion, celix_status_t); CELIX_EI_DECLARE(celix_properties_setEntry, celix_status_t); CELIX_EI_DECLARE(celix_properties_save, celix_status_t); +CELIX_EI_DECLARE(celix_properties_saveToStream, celix_status_t); CELIX_EI_DECLARE(celix_properties_load, celix_status_t); #ifdef __cplusplus diff --git a/libs/utils/error_injector/celix_properties/src/celix_properties_ei.cc b/libs/utils/error_injector/celix_properties/src/celix_properties_ei.cc index 1ba0903ca..c0bfe60a4 100644 --- a/libs/utils/error_injector/celix_properties/src/celix_properties_ei.cc +++ b/libs/utils/error_injector/celix_properties/src/celix_properties_ei.cc @@ -75,6 +75,15 @@ __wrap_celix_properties_save(const celix_properties_t* properties, const char* f return __real_celix_properties_save(properties, filename, encodeFlags); } +celix_status_t +__real_celix_properties_saveToStream(const celix_properties_t* properties, FILE* stream, int encodeFlags); +CELIX_EI_DEFINE(celix_properties_saveToStream, celix_status_t) +celix_status_t +__wrap_celix_properties_saveToStream(const celix_properties_t* properties, FILE* stream, int encodeFlags) { + CELIX_EI_IMPL(celix_properties_saveToStream); + return __real_celix_properties_saveToStream(properties, stream, encodeFlags); +} + celix_status_t __real_celix_properties_load(const char* filename, int decodeFlags,