Skip to content

Commit

Permalink
clean up add scheduler flag to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tanneberger committed Nov 20, 2024
1 parent f89e0ad commit c1ab9a7
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 19 deletions.
9 changes: 9 additions & 0 deletions include/reactor-uc/consts.h
Original file line number Diff line number Diff line change
@@ -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
7 changes: 1 addition & 6 deletions include/reactor-uc/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down Expand Up @@ -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
13 changes: 10 additions & 3 deletions include/reactor-uc/reactor-uc.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#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"
#include "reactor-uc/environment.h"
#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"
Expand All @@ -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 <assert.h>
#include <stdio.h>

#define REACTOR_UC_MEMORY_ALIGNMENT 32

#endif
13 changes: 10 additions & 3 deletions include/reactor-uc/scheduler.h
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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


1 change: 0 additions & 1 deletion include/reactor-uc/schedulers/dynamic/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 1 addition & 2 deletions include/reactor-uc/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>

typedef struct Trigger Trigger;
Expand Down
3 changes: 2 additions & 1 deletion src/schedulers/dynamic/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/unit/action_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#define ACTION_LIB_H
#include "reactor-uc/reactor-uc.h"

#include <reactor-uc/schedulers/dynamic/scheduler.h>

#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);
Expand Down
1 change: 0 additions & 1 deletion test/unit/startup_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "reactor-uc/reactor-uc.h"

#include "unity.h"

DEFINE_STARTUP_STRUCT(StartupTest, 1)
Expand Down

0 comments on commit c1ab9a7

Please sign in to comment.