From c1ab9a796568a46a62a68223fe818872cb5f0538 Mon Sep 17 00:00:00 2001 From: tanneberger Date: Thu, 21 Nov 2024 00:44:13 +0100 Subject: [PATCH] clean up add scheduler flag to tests --- include/reactor-uc/consts.h | 9 +++++++++ include/reactor-uc/macros.h | 7 +------ include/reactor-uc/reactor-uc.h | 13 ++++++++++--- include/reactor-uc/scheduler.h | 13 ++++++++++--- include/reactor-uc/schedulers/dynamic/scheduler.h | 1 - include/reactor-uc/trigger.h | 3 +-- src/schedulers/dynamic/scheduler.c | 3 ++- test/unit/CMakeLists.txt | 1 + test/unit/action_lib.h | 2 -- test/unit/startup_test.c | 1 - 10 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 include/reactor-uc/consts.h diff --git a/include/reactor-uc/consts.h b/include/reactor-uc/consts.h new file mode 100644 index 00000000..046ecf23 --- /dev/null +++ b/include/reactor-uc/consts.h @@ -0,0 +1,9 @@ +#ifndef REACTOR_UC_CONSTS_H +#define REACTOR_UC_CONSTS_H + +// TODO: The following macro is defined to avoid compiler warnings. Ideally we would +// not have to specify any alignment on any structs. It is a TODO to understand exactly why +// the compiler complains and what we can do about it. +#define MEM_ALIGNMENT 32 + +#endif diff --git a/include/reactor-uc/macros.h b/include/reactor-uc/macros.h index 1825d653..ff148a8b 100644 --- a/include/reactor-uc/macros.h +++ b/include/reactor-uc/macros.h @@ -455,7 +455,7 @@ typedef struct FederatedInputConnection FederatedInputConnection; #define ENTRY_POINT(MainReactorName, Timeout, KeepAlive) \ MainReactorName main_reactor; \ Environment env; \ - DynamicScheduler scheduler; \ + DynamicScheduler scheduler; \ void lf_exit(void) { Environment_free(&env); } \ void lf_start() { \ DynamicScheduler_ctor(&scheduler, &env); \ @@ -491,9 +491,4 @@ typedef struct FederatedInputConnection FederatedInputConnection; lf_exit(); \ } -// TODO: The following macro is defined to avoid compiler warnings. Ideally we would -// not have to specify any alignment on any structs. It is a TODO to understand exactly why -// the compiler complains and what we can do about it. -#define MEM_ALIGNMENT 32 - #endif diff --git a/include/reactor-uc/reactor-uc.h b/include/reactor-uc/reactor-uc.h index 1d588bd6..b0e0aec1 100644 --- a/include/reactor-uc/reactor-uc.h +++ b/include/reactor-uc/reactor-uc.h @@ -1,6 +1,14 @@ #ifndef REACTOR_UC_REACTOR_UC_H #define REACTOR_UC_REACTOR_UC_H +#if defined(SCHEDULER_DYNAMIC) +#include "./schedulers/dynamic/scheduler.h" +#elif defined(SCHEDULER_STATIC) +#include "schedulers/static/scheduler.h" +#include "schedulers/static/instructions.h" +#else +#endif + #include "reactor-uc/action.h" #include "reactor-uc/builtin_triggers.h" #include "reactor-uc/connection.h" @@ -8,7 +16,6 @@ #include "reactor-uc/error.h" #include "reactor-uc/federated.h" #include "reactor-uc/logging.h" -#include "reactor-uc/macros.h" #include "reactor-uc/platform.h" #include "reactor-uc/port.h" #include "reactor-uc/serialization.h" @@ -17,9 +24,9 @@ #include "reactor-uc/tag.h" #include "reactor-uc/timer.h" #include "reactor-uc/trigger.h" +#include "reactor-uc/queues.h" +#include "reactor-uc/macros.h" #include #include -#define REACTOR_UC_MEMORY_ALIGNMENT 32 - #endif diff --git a/include/reactor-uc/scheduler.h b/include/reactor-uc/scheduler.h index 66a7c072..30951976 100644 --- a/include/reactor-uc/scheduler.h +++ b/include/reactor-uc/scheduler.h @@ -1,9 +1,6 @@ #ifndef REACTOR_UC_SCHEDULER_H #define REACTOR_UC_SCHEDULER_H -#include "reactor-uc/error.h" -#include "reactor-uc/queues.h" - typedef struct Scheduler Scheduler; typedef struct Environment Environment; @@ -53,3 +50,13 @@ struct Scheduler { }; #endif + +#if defined(SCHEDULER_DYNAMIC) +#include "./schedulers/dynamic/scheduler.h" +#elif defined(SCHEDULER_STATIC) +#include "schedulers/static/scheduler.h" +#include "schedulers/static/instructions.h" +#else +#endif + + diff --git a/include/reactor-uc/schedulers/dynamic/scheduler.h b/include/reactor-uc/schedulers/dynamic/scheduler.h index ecb3ba23..262ddd92 100644 --- a/include/reactor-uc/schedulers/dynamic/scheduler.h +++ b/include/reactor-uc/schedulers/dynamic/scheduler.h @@ -4,7 +4,6 @@ #ifndef SCHEDULER_H #define SCHEDULER_H -#include "reactor-uc/error.h" #include "reactor-uc/queues.h" #include "reactor-uc/scheduler.h" diff --git a/include/reactor-uc/trigger.h b/include/reactor-uc/trigger.h index eacf375d..a59d7bfa 100644 --- a/include/reactor-uc/trigger.h +++ b/include/reactor-uc/trigger.h @@ -2,9 +2,8 @@ #define REACTOR_UC_TRIGGER_H #include "reactor-uc/event.h" -#include "reactor-uc/macros.h" +#include "reactor-uc/consts.h" #include "reactor-uc/reaction.h" -#include "reactor-uc/reactor.h" #include typedef struct Trigger Trigger; diff --git a/src/schedulers/dynamic/scheduler.c b/src/schedulers/dynamic/scheduler.c index 51496889..895a026f 100644 --- a/src/schedulers/dynamic/scheduler.c +++ b/src/schedulers/dynamic/scheduler.c @@ -3,7 +3,8 @@ #include "reactor-uc/scheduler.h" #include "reactor-uc/environment.h" #include "reactor-uc/logging.h" -#include "reactor-uc/reactor-uc.h" +#include "reactor-uc/federated.h" +#include "reactor-uc/timer.h" // Private functions diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index adcfe6e7..74fd62ed 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -14,6 +14,7 @@ file( foreach(FILE ${TEST_SOURCES}) string(REGEX REPLACE "[./]" "_" NAME ${FILE}) add_executable(${NAME} ${TEST_DIR}/${FILE} ${TEST_MOCK_SRCS}) + target_compile_definitions(${NAME} PRIVATE "PLATFORM_${PLATFORM}") add_test(NAME ${NAME} COMMAND ${NAME}) target_link_libraries( ${NAME} PRIVATE diff --git a/test/unit/action_lib.h b/test/unit/action_lib.h index 8a1326dd..220b17e7 100644 --- a/test/unit/action_lib.h +++ b/test/unit/action_lib.h @@ -2,8 +2,6 @@ #define ACTION_LIB_H #include "reactor-uc/reactor-uc.h" -#include - #ifdef ACTION_LIB_VOID_TYPE DEFINE_ACTION_STRUCT_VOID(ActionLib, act, LOGICAL_ACTION, 1, 1, 2); DEFINE_ACTION_CTOR_VOID(ActionLib, act, LOGICAL_ACTION, 1, 1, 2); diff --git a/test/unit/startup_test.c b/test/unit/startup_test.c index 7b123279..e6dce701 100644 --- a/test/unit/startup_test.c +++ b/test/unit/startup_test.c @@ -1,5 +1,4 @@ #include "reactor-uc/reactor-uc.h" - #include "unity.h" DEFINE_STARTUP_STRUCT(StartupTest, 1)