Skip to content

Commit

Permalink
All tests are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Jan 13, 2025
1 parent c7dde4f commit f910e5e
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/reactor-uc/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ typedef struct FederatedOutputConnection FederatedOutputConnection;

#define LF_INITIALIZE_FEDERATED_OUTPUT_CONNECTION(ReactorName, OutputName, SerializeFunc) \
ReactorName##_##OutputName##_conn_ctor(&self->OutputName, self->super.parent, &self->super); \
self->outputs[_outputs_idx] = &self->OutputName.super; \
self->serialize_hooks[_outputs_idx] = SerializeFunc; \
self->outputs[_outputs_idx] = &self->OutputName.super; \
self->serialize_hooks[_outputs_idx] = SerializeFunc; \
_outputs_idx++;

typedef struct FederatedInputConnection FederatedInputConnection;
Expand Down
4 changes: 2 additions & 2 deletions include/reactor-uc/platform/posix/tcp_ip_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ struct TcpIpChannel {

int fd;
int client;
int send_failed_event_fds; // These file descriptors are used to signal the recv select to stop blocking
int terminate_event_fds[2];
int send_failed_event_fds[2]; // These file descriptors are used to signal the recv select to stop blocking
int terminate_event_fds;
NetworkChannelState state;
pthread_mutex_t mutex;

Expand Down
2 changes: 1 addition & 1 deletion src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void log_message(int level, const char *module, const char *fmt, ...) {
break;
}
#endif
log_printf("%"PRId64 " [%s] [%s] ",_lf_environment->get_elapsed_physical_time(_lf_environment), level_str, module);
log_printf("%" PRId64 " [%s] [%s] ", _lf_environment->get_elapsed_physical_time(_lf_environment), level_str, module);
Platform_vprintf(fmt, args);
#ifdef LF_COLORIZE_LOGS
log_printf(ANSI_COLOR_RESET);
Expand Down
1 change: 0 additions & 1 deletion src/platform/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

static PlatformPosix platform;


static instant_t convert_timespec_to_ns(struct timespec tp) { return ((instant_t)tp.tv_sec) * BILLION + tp.tv_nsec; }

void Platform_vprintf(const char *fmt, va_list args) { vprintf(fmt, args); }
Expand Down
4 changes: 2 additions & 2 deletions src/platform/posix/tcp_ip_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ static lf_ret_t _TcpIpChannel_reset_socket(TcpIpChannel *self) {
}
}

if (self->send_failed_event_fds > 0) {
if (close(self->send_failed_event_fds) < 0) {
if (self->send_failed_event_fds[0] > 0) {
if (close(self->send_failed_event_fds[0]) < 0) {
TCP_IP_CHANNEL_ERR("Error closing sending failed fds=%d", errno);
return LF_ERR;
}
Expand Down
7 changes: 7 additions & 0 deletions test/lf/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Very simple Makefile script to build and compile all the LF tests.
SRCS = $(wildcard src/*.lf)
BINS = $(patsubst src/%.lf, bin/%, $(SRCS))

SRCS_ONLY_BUILD = $(wildcard src/only_build/*.lf)
BINS_ONLY_BUILD = $(patsubst src/only_build/%.lf, bin/%, $(SRCS))

LFC_PATH=../../lfc
LFC = ${LFC_PATH}/build/install/lf-cli/bin/lfc

Expand All @@ -14,5 +18,8 @@ bin/%: src/%.lf
${LFC} $^ -c
./$@

bin/%: src/only_build/%.lf
${LFC} $^ -c

clean:
rm -rf build bin src-gen
10 changes: 8 additions & 2 deletions test/lf/src/FederatedBank.lf
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ reactor Fed(bank_idx: int = 0) {
output out: int
input in: int
input in2: int
state check: bool = false
state check1: bool = false
state check2: bool = false

reaction(in) -> out {=
printf("Received %d from src \n", in->value);
lf_set(out, self->bank_idx);
validate(in->value == 42);
validate(!self->check2);
self->check1 = true;
=}

reaction(in2) {=
printf("Received %d from myself\n", in2->value);
validate(in2->value == self->bank_idx);
validate(self->check1);
self->check2 = true;
=}

reaction(shutdown) {=
validate(self->check);
validate(self->check2);
validate(self->check1);
=}
}

Expand Down
1 change: 1 addition & 0 deletions test/lf/src/FederatedBankMultiport.lf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ reactor Fed(bank_idx: int = 0) {
reaction(in) {=
for (int i = 0; i<in_width; i++) {
if (lf_is_present(in[i])) {
validate(in[i]->value == i);
if (self->bank_idx == 0) {
printf("%"PRId64" Fed %u Received %d from %d \n", env->get_elapsed_logical_time(env), self->bank_idx, in[i]->value, i);
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit f910e5e

Please sign in to comment.