You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/04/11 06:12:03 UTC
[celix] branch master updated: Remove CELIX_EI_IMPL_NEGATIVE and CELIX_EI_IMPL_POSITIVE
This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/master by this push:
new b525f3ee Remove CELIX_EI_IMPL_NEGATIVE and CELIX_EI_IMPL_POSITIVE
new 5443d7eb Merge pull request #521 from xuzhenbao/err_injector_improve
b525f3ee is described below
commit b525f3ee0a1bae8346b58f645d28ead10802d070
Author: xuzhenbao <xu...@163.com>
AuthorDate: Tue Apr 11 10:51:47 2023 +0800
Remove CELIX_EI_IMPL_NEGATIVE and CELIX_EI_IMPL_POSITIVE
---
.../src/DiscoveryZeroconfActivatorTestSuite.cc | 3 --
.../src/DiscoveryZeroconfAnnouncerTestSuite.cc | 2 -
libs/error_injector/api/celix_error_injector.h | 48 ----------------------
.../src/celix_bundle_context_ei.cc | 4 +-
.../celix_threads/src/celix_threads_ei.cc | 4 +-
libs/error_injector/eventfd/include/eventfd_ei.h | 1 -
libs/error_injector/eventfd/src/eventfd_ei.cc | 5 +--
.../mdnsresponder/src/mdnsresponder_ei.cc | 10 ++---
8 files changed, 11 insertions(+), 66 deletions(-)
diff --git a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfActivatorTestSuite.cc b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfActivatorTestSuite.cc
index 9c510363..5e5d438f 100644
--- a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfActivatorTestSuite.cc
+++ b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfActivatorTestSuite.cc
@@ -41,7 +41,6 @@ public:
~DiscoveryZeroconfActivatorTestSuite() override {
celix_ei_expect_eventfd(nullptr, 0, 0);
- celix_ei_eventfd_errno = 0;
}
std::shared_ptr<celix_framework_t> fw{};
@@ -68,7 +67,6 @@ TEST_F(DiscoveryZeroconfActivatorTestSuite, DiscoveryZeroconfAnnouncerCreateFail
auto status = celix_bundleActivator_create(ctx.get(), &act);
EXPECT_EQ(CELIX_SUCCESS, status);
- celix_ei_eventfd_errno = ENOMEM;
celix_ei_expect_eventfd((void*)&discoveryZeroconfAnnouncer_create, 0, -1);
status = celix_bundleActivator_start(act, ctx.get());
EXPECT_EQ(CELIX_ENOMEM, status);
@@ -82,7 +80,6 @@ TEST_F(DiscoveryZeroconfActivatorTestSuite, DiscoveryZeroconfWatcherCreateFailed
auto status = celix_bundleActivator_create(ctx.get(), &act);
EXPECT_EQ(CELIX_SUCCESS, status);
- celix_ei_eventfd_errno = ENOMEM;
celix_ei_expect_eventfd((void *)&discoveryZeroconfWatcher_create, 0, -1);
status = celix_bundleActivator_start(act, ctx.get());
EXPECT_EQ(CELIX_ENOMEM, status);
diff --git a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc
index fceb2c15..0bad7c97 100644
--- a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc
+++ b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc
@@ -67,7 +67,6 @@ public:
~DiscoveryZeroconfAnnouncerTestSuite() override {
celix_ei_expect_eventfd(nullptr, 0, 0);
- celix_ei_eventfd_errno = 0;
celix_ei_expect_celixThreadMutex_create(nullptr, 0, 0);
celix_ei_expect_celix_bundleContext_getProperty(nullptr, 0, nullptr);
celix_ei_expect_celix_bundleContext_registerServiceWithOptionsAsync(nullptr, 0, 0);
@@ -94,7 +93,6 @@ TEST_F(DiscoveryZeroconfAnnouncerTestSuite, CreateAndDestroyAnnouncer) {
TEST_F(DiscoveryZeroconfAnnouncerTestSuite, CreateAnnouncerFailed1) {
discovery_zeroconf_announcer_t *announcer{nullptr};
celix_ei_expect_eventfd((void*)&discoveryZeroconfAnnouncer_create, 0, -1);
- celix_ei_eventfd_errno = ENOMEM;
auto status = discoveryZeroconfAnnouncer_create(ctx.get(), logHelper.get(), &announcer);
EXPECT_EQ(status, CELIX_ENOMEM);
}
diff --git a/libs/error_injector/api/celix_error_injector.h b/libs/error_injector/api/celix_error_injector.h
index 07c109a7..3eef3a78 100644
--- a/libs/error_injector/api/celix_error_injector.h
+++ b/libs/error_injector/api/celix_error_injector.h
@@ -93,54 +93,6 @@ do {
} \
} while(0)
-#define CELIX_EI_IMPL_POSITIVE(name) \
-do { \
- void *addr = CELIX_EI_UNKNOWN_CALLER; \
- if(name##_caller) { \
- if(name ## _caller != CELIX_EI_UNKNOWN_CALLER) { \
- /* we can not use CELIX_EI_GET_CALLER(addr, name ## _caller_level) */ \
- switch(name ## _caller_level) { \
- case 0: \
- CELIX_EI_GET_CALLER(addr, 0); \
- break; \
- case 1: \
- CELIX_EI_GET_CALLER(addr, 1); \
- break; \
- default: \
- assert(0); \
- } \
- } \
- if(name ## _caller == addr) { \
- if(__atomic_fetch_sub(&(name ## _ordinal), 1, __ATOMIC_RELAXED) == 1 && name ## _ret > 0) \
- return name ## _ret; \
- } \
- } \
-} while(0)
-
-#define CELIX_EI_IMPL_NEGATIVE(name) \
-do { \
- void *addr = CELIX_EI_UNKNOWN_CALLER; \
- if(name##_caller) { \
- if(name ## _caller != CELIX_EI_UNKNOWN_CALLER) { \
- /* we can not use CELIX_EI_GET_CALLER(addr, name ## _caller_level) */ \
- switch(name ## _caller_level) { \
- case 0: \
- CELIX_EI_GET_CALLER(addr, 0); \
- break; \
- case 1: \
- CELIX_EI_GET_CALLER(addr, 1); \
- break; \
- default: \
- assert(0); \
- } \
- } \
- if(name ## _caller == addr) { \
- if(__atomic_fetch_sub(&(name ## _ordinal), 1, __ATOMIC_RELAXED) == 1 && name ## _ret < 0) \
- return name ## _ret; \
- } \
- } \
-} while(0)
-
#ifdef __cplusplus
}
diff --git a/libs/error_injector/celix_bundle_ctx/src/celix_bundle_context_ei.cc b/libs/error_injector/celix_bundle_ctx/src/celix_bundle_context_ei.cc
index 1f1aa351..94acd323 100644
--- a/libs/error_injector/celix_bundle_ctx/src/celix_bundle_context_ei.cc
+++ b/libs/error_injector/celix_bundle_ctx/src/celix_bundle_context_ei.cc
@@ -39,7 +39,7 @@ long __wrap_celix_bundleContext_registerServiceWithOptionsAsync(celix_bundle_con
// It should free '__opts->properties', whether failure or success.
celix_properties_t __attribute__((cleanup(celix_properties_cleanup))) *props = celix_properties_copy(__opts->properties);
celix_properties_destroy(__opts->properties);
- CELIX_EI_IMPL_NEGATIVE(celix_bundleContext_registerServiceWithOptionsAsync);
+ CELIX_EI_IMPL(celix_bundleContext_registerServiceWithOptionsAsync);
celix_service_registration_options_t opts;
opts = *__opts;
opts.properties = celix_properties_copy(props);
@@ -49,7 +49,7 @@ long __wrap_celix_bundleContext_registerServiceWithOptionsAsync(celix_bundle_con
long __real_celix_bundleContext_trackServicesWithOptionsAsync(celix_bundle_context_t *__ctx, const celix_service_tracking_options_t *__opts);
CELIX_EI_DEFINE(celix_bundleContext_trackServicesWithOptionsAsync, long)
long __wrap_celix_bundleContext_trackServicesWithOptionsAsync(celix_bundle_context_t *__ctx, const celix_service_tracking_options_t *__opts) {
- CELIX_EI_IMPL_NEGATIVE(celix_bundleContext_trackServicesWithOptionsAsync);
+ CELIX_EI_IMPL(celix_bundleContext_trackServicesWithOptionsAsync);
return __real_celix_bundleContext_trackServicesWithOptionsAsync(__ctx, __opts);
}
}
\ No newline at end of file
diff --git a/libs/error_injector/celix_threads/src/celix_threads_ei.cc b/libs/error_injector/celix_threads/src/celix_threads_ei.cc
index 2a2efdfb..ab55cd88 100644
--- a/libs/error_injector/celix_threads/src/celix_threads_ei.cc
+++ b/libs/error_injector/celix_threads/src/celix_threads_ei.cc
@@ -26,14 +26,14 @@ extern "C" {
celix_status_t __real_celixThreadMutex_create(celix_thread_mutex_t *__mutex, celix_thread_mutexattr_t *__attr);
CELIX_EI_DEFINE(celixThreadMutex_create, celix_status_t)
celix_status_t __wrap_celixThreadMutex_create(celix_thread_mutex_t *__mutex, celix_thread_mutexattr_t *__attr) {
- CELIX_EI_IMPL_POSITIVE(celixThreadMutex_create);
+ CELIX_EI_IMPL(celixThreadMutex_create);
return __real_celixThreadMutex_create(__mutex, __attr);
}
celix_status_t __real_celixThread_create(celix_thread_t *__new_thread, celix_thread_attr_t *__attr, celix_thread_start_t __func, void *__data);
CELIX_EI_DEFINE(celixThread_create, celix_status_t)
celix_status_t __wrap_celixThread_create(celix_thread_t *__new_thread, celix_thread_attr_t *__attr, celix_thread_start_t __func, void *__data) {
- CELIX_EI_IMPL_POSITIVE(celixThread_create);
+ CELIX_EI_IMPL(celixThread_create);
return __real_celixThread_create(__new_thread, __attr, __func, __data);
}
}
diff --git a/libs/error_injector/eventfd/include/eventfd_ei.h b/libs/error_injector/eventfd/include/eventfd_ei.h
index a5c02a7a..1edf8645 100644
--- a/libs/error_injector/eventfd/include/eventfd_ei.h
+++ b/libs/error_injector/eventfd/include/eventfd_ei.h
@@ -24,7 +24,6 @@ extern "C" {
#endif
#include "celix_error_injector.h"
-extern int celix_ei_eventfd_errno;
CELIX_EI_DECLARE(eventfd, int);
#ifdef __cplusplus
diff --git a/libs/error_injector/eventfd/src/eventfd_ei.cc b/libs/error_injector/eventfd/src/eventfd_ei.cc
index 7d239761..98747314 100644
--- a/libs/error_injector/eventfd/src/eventfd_ei.cc
+++ b/libs/error_injector/eventfd/src/eventfd_ei.cc
@@ -21,12 +21,11 @@
#include <cerrno>
extern "C" {
-int celix_ei_eventfd_errno = 0;
int __real_eventfd(unsigned int __initval, int __flags);
CELIX_EI_DEFINE(eventfd, int)
int __wrap_eventfd(unsigned int __initval, int __flags) {
- errno = celix_ei_eventfd_errno;
- CELIX_EI_IMPL_NEGATIVE(eventfd);
+ errno = ENOMEM;
+ CELIX_EI_IMPL(eventfd);
errno = 0;
return __real_eventfd(__initval, __flags);
}
diff --git a/libs/error_injector/mdnsresponder/src/mdnsresponder_ei.cc b/libs/error_injector/mdnsresponder/src/mdnsresponder_ei.cc
index 55b696c6..abdda5c5 100644
--- a/libs/error_injector/mdnsresponder/src/mdnsresponder_ei.cc
+++ b/libs/error_injector/mdnsresponder/src/mdnsresponder_ei.cc
@@ -24,35 +24,35 @@ extern "C" {
DNSServiceErrorType __real_DNSServiceCreateConnection(DNSServiceRef *__sdRef);
CELIX_EI_DEFINE(DNSServiceCreateConnection, DNSServiceErrorType)
DNSServiceErrorType __wrap_DNSServiceCreateConnection(DNSServiceRef *__sdRef) {
- CELIX_EI_IMPL_NEGATIVE(DNSServiceCreateConnection);
+ CELIX_EI_IMPL(DNSServiceCreateConnection);
return __real_DNSServiceCreateConnection(__sdRef);
}
DNSServiceErrorType __real_DNSServiceProcessResult(DNSServiceRef __sdRef);
CELIX_EI_DEFINE(DNSServiceProcessResult, DNSServiceErrorType)
DNSServiceErrorType __wrap_DNSServiceProcessResult(DNSServiceRef __sdRef) {
- CELIX_EI_IMPL_NEGATIVE(DNSServiceProcessResult);
+ CELIX_EI_IMPL(DNSServiceProcessResult);
return __real_DNSServiceProcessResult(__sdRef);
}
DNSServiceErrorType __real_DNSServiceRegister(DNSServiceRef *__sdRef, DNSServiceFlags __flags, uint32_t __interfaceIndex, const char *__name, const char *__regtype, const char *__domain, const char *__host, uint16_t __port, uint16_t __txtLen, const void *__txtRecord, DNSServiceRegisterReply __callBack, void *__context);
CELIX_EI_DEFINE(DNSServiceRegister, DNSServiceErrorType)
DNSServiceErrorType __wrap_DNSServiceRegister(DNSServiceRef *__sdRef, DNSServiceFlags __flags, uint32_t __interfaceIndex, const char *__name, const char *__regtype, const char *__domain, const char *__host, uint16_t __port, uint16_t __txtLen, const void *__txtRecord, DNSServiceRegisterReply __callBack, void *__context) {
- CELIX_EI_IMPL_NEGATIVE(DNSServiceRegister);
+ CELIX_EI_IMPL(DNSServiceRegister);
return __real_DNSServiceRegister(__sdRef, __flags, __interfaceIndex, __name, __regtype, __domain, __host, __port, __txtLen, __txtRecord, __callBack, __context);
}
DNSServiceErrorType __real_TXTRecordSetValue(TXTRecordRef *__txtRec, const char *__key, uint8_t __valSize, const void *__val);
CELIX_EI_DEFINE(TXTRecordSetValue, DNSServiceErrorType)
DNSServiceErrorType __wrap_TXTRecordSetValue(TXTRecordRef *__txtRec, const char *__key, uint8_t __valSize, const void *__val) {
- CELIX_EI_IMPL_NEGATIVE(TXTRecordSetValue);
+ CELIX_EI_IMPL(TXTRecordSetValue);
return __real_TXTRecordSetValue(__txtRec, __key, __valSize, __val);
}
DNSServiceErrorType __real_DNSServiceBrowse(DNSServiceRef *__sdRef, DNSServiceFlags __flags, uint32_t __interfaceIndex, const char *__regtype, const char *__domain, DNSServiceBrowseReply __callBack, void *__context);
CELIX_EI_DEFINE(DNSServiceBrowse, DNSServiceErrorType)
DNSServiceErrorType __wrap_DNSServiceBrowse(DNSServiceRef *__sdRef, DNSServiceFlags __flags, uint32_t __interfaceIndex, const char *__regtype, const char *__domain, DNSServiceBrowseReply __callBack, void *__context) {
- CELIX_EI_IMPL_NEGATIVE(DNSServiceBrowse);
+ CELIX_EI_IMPL(DNSServiceBrowse);
return __real_DNSServiceBrowse(__sdRef, __flags, __interfaceIndex, __regtype, __domain, __callBack, __context);
}
}
\ No newline at end of file