Skip to content

Commit

Permalink
gh-685: Add celix_bundle_getVersion error injection wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Jul 26, 2024
1 parent a123d96 commit 28ee4a1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmake/cmake_celix/templates/MANIFEST.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"CELIX_BUNDLE_GROUP" : "$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_GROUP>",
"CELIX_BUNDLE_IMPORT_LIBRARIES" : "$<JOIN:$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_IMPORT_LIBS>,$<COMMA>>",
"CELIX_BUNDLE_EXPORT_LIBRARIES" : "$<JOIN:$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_EXPORT_LIBS>,$<COMMA>>"
}
}
1 change: 1 addition & 0 deletions libs/framework/error_injector/celix_bundle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ target_link_libraries(bundle_ei PRIVATE Celix::framework)
target_link_options(bundle_ei INTERFACE
LINKER:--wrap,celix_bundle_getSymbolicName
LINKER:--wrap,celix_bundle_getManifestValue
LINKER:--wrap,celix_bundle_getVersion
)
add_library(Celix::bundle_ei ALIAS bundle_ei)
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
extern "C" {
#endif
#include "celix_error_injector.h"
#include "celix_version_type.h"

CELIX_EI_DECLARE(celix_bundle_getSymbolicName, const char*);

CELIX_EI_DECLARE(celix_bundle_getManifestValue, const char*);

CELIX_EI_DECLARE(celix_bundle_getVersion, const celix_version_t*);

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 11 additions & 4 deletions libs/framework/error_injector/celix_bundle/src/celix_bundle_ei.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@

extern "C" {

const char *__real_celix_bundle_getSymbolicName(const celix_bundle_t *bnd);
const char* __real_celix_bundle_getSymbolicName(const celix_bundle_t* bnd);
CELIX_EI_DEFINE(celix_bundle_getSymbolicName, const char*)
const char *__wrap_celix_bundle_getSymbolicName(const celix_bundle_t *bnd) {
const char* __wrap_celix_bundle_getSymbolicName(const celix_bundle_t* bnd) {
CELIX_EI_IMPL(celix_bundle_getSymbolicName);
return __real_celix_bundle_getSymbolicName(bnd);
}

const char *__real_celix_bundle_getManifestValue(const celix_bundle_t *bnd, const char *attribute);
const char* __real_celix_bundle_getManifestValue(const celix_bundle_t* bnd, const char* attribute);
CELIX_EI_DEFINE(celix_bundle_getManifestValue, const char*)
const char *__wrap_celix_bundle_getManifestValue(const celix_bundle_t *bnd, const char *attribute) {
const char* __wrap_celix_bundle_getManifestValue(const celix_bundle_t* bnd, const char* attribute) {
CELIX_EI_IMPL(celix_bundle_getManifestValue);
return __real_celix_bundle_getManifestValue(bnd, attribute);
}

const celix_version_t* __real_celix_bundle_getVersion(const celix_bundle_t* bnd);
CELIX_EI_DEFINE(celix_bundle_getVersion, const celix_version_t*)
const celix_version_t* __wrap_celix_bundle_getVersion(const celix_bundle_t* bnd) {
CELIX_EI_IMPL(celix_bundle_getVersion);
return __real_celix_bundle_getVersion(bnd);
}

}
23 changes: 0 additions & 23 deletions libs/utils/include/celix_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ extern "C" {
*/
#define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) : (status)

/*!
* Helper macro which helps with error propagation. It evaluates the provided expression that returns a status and
* returns the status if the status is not CELIX_SUCCESS (0). If the status is CELIX_SUCCESS (0) nothing is done.
*/
#define CELIX_EPROP(expr) \
do { \
celix_status_t __status = expr; \
if (__status != CELIX_SUCCESS) { \
return __status; \
} \
} while (0)

/*!
* Helper macro which check the current status and executes a goto the provided label if the
* status is not CELIX_SUCCESS (0)
Expand All @@ -79,17 +67,6 @@ extern "C" {
} \
} while (0)

/*!
* \defgroup celix_errno Error Codes
* \ingroup framework
* \{
*/

struct __attribute__((deprecated("use celix_status_t instead"))) celix_status {
int code;
char *error;
};

/*!
* Status type returned by all functions in Celix
*/
Expand Down

0 comments on commit 28ee4a1

Please sign in to comment.