Skip to content

Commit baa43d8

Browse files
committed
Fix failing unit tests
1 parent 4d2af42 commit baa43d8

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ RUSTEMU_INCLUDE_DIR := $(RUSTEMU_DIR)/include/
223223
RUSTEMU_TARGET_DIR := $(RUSTEMU_DIR)/target/thumbv7em-none-eabihf/release
224224
RUSTEMU_HEADER := $(RUSTEMU_INCLUDE_DIR)/rustemu.h
225225
RUSTEMU_LIBRARY := $(RUSTEMU_TARGET_DIR)/librustemu.a
226-
RUSTEMU_SRC := $(shell find $(RUSTEMU_DIR)/src -name '*.rs')
226+
RUSTEMU_SOURCES := $(shell find $(RUSTEMU_DIR)/src -name '*.rs')
227227

228228
INCLUDE_DIRS := $(INCLUDE_DIRS) \
229229
$(RUSTEMU_INCLUDE_DIR)
@@ -359,11 +359,11 @@ CLEAN_ARTIFACTS += $(TARGET_DFU)
359359
# Make sure build date and revision is updated on every incremental build
360360
$(OBJECT_DIR)/$(TARGET)/build/version.o : $(SRC)
361361

362-
$(RUSTEMU_LIBRARY): $(RUSTEMU_SRC)
363-
cd src/rustemu && cargo build --release --target thumbv7em-none-eabihf
362+
$(RUSTEMU_LIBRARY): $(RUSTEMU_SOURCES)
363+
cd $(RUSTEMU_DIR) && cargo build --release --target thumbv7em-none-eabihf
364364

365365
$(RUSTEMU_HEADER): $(RUSTEMU_LIBRARY)
366-
cd src/rustemu && cbindgen --lang c -o $(PWD)/$(RUSTEMU_HEADER)
366+
cd $(RUSTEMU_DIR) && cbindgen --lang c -o $(PWD)/$(RUSTEMU_HEADER)
367367

368368
# List of buildable ELF files and their object dependencies.
369369
# It would be nice to compute these lists, but that seems to be just beyond make.

src/test/Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ ROOT = ../..
1717
OBJECT_DIR = ../../obj/test
1818
TARGET_DIR = $(USER_DIR)/target
1919

20+
RUSTEMU_DIR := $(ROOT)/src/rustemu
21+
RUSTEMU_INCLUDE_DIR := $(RUSTEMU_DIR)/include/
22+
RUSTEMU_TARGET_DIR := $(RUSTEMU_DIR)/target/x86_64-unknown-linux-gnu/release
23+
RUSTEMU_HEADER := $(RUSTEMU_INCLUDE_DIR)/rustemu.h
24+
RUSTEMU_LIBRARY := $(RUSTEMU_TARGET_DIR)/librustemu.a
25+
RUSTEMU_SRC := $(shell find $(RUSTEMU_DIR)/src -name '*.rs')
26+
2027
include $(ROOT)/make/system-id.mk
2128
include $(ROOT)/make/targets_list.mk
2229

@@ -130,10 +137,6 @@ common_filter_unittest_SRC := \
130137
$(USER_DIR)/common/maths.c
131138

132139

133-
encoding_unittest_SRC := \
134-
$(USER_DIR)/common/encoding.c
135-
136-
137140
flight_failsafe_unittest_SRC := \
138141
$(USER_DIR)/common/bitarray.c \
139142
$(USER_DIR)/fc/rc_modes.c \
@@ -511,7 +514,7 @@ ifeq ($(shell $(CC) -v 2>&1 | grep -q "clang version" && echo "clang"),clang)
511514
# Travis reports CC_VERSION of 4.2.1
512515
CC_VERSION_MAJOR := $(firstword $(subst ., ,$(CC_VERSION)))
513516
CC_VERSION_CHECK_MIN := 7
514-
CC_VERSION_CHECK_MAX := 13
517+
CC_VERSION_CHECK_MAX := 15
515518

516519
# Added flags for clang 11 - 13 are not backwards compatible
517520
ifeq ($(shell expr $(CC_VERSION_MAJOR) \> 10 \& $(CC_VERSION_MAJOR) \< 14), 1)
@@ -566,6 +569,7 @@ C_FLAGS += $(COVERAGE_FLAGS)
566569
CXX_FLAGS += $(COVERAGE_FLAGS)
567570

568571
C_FLAGS += -D_GNU_SOURCE
572+
LD_FLAGS += -L$(RUSTEMU_TARGET_DIR) -lrustemu
569573

570574
# Set up the parameter group linker flags according to OS
571575
ifeq ($(OSFAMILY), macosx)
@@ -674,10 +678,15 @@ $(OBJECT_DIR)/gtest_main.a : $(OBJECT_DIR)/gtest-all.o $(OBJECT_DIR)/gtest_main.
674678
-include $(OBJECT_DIR)/gtest-all.d \
675679
$(OBJECT_DIR)/gtest_main.d
676680

681+
$(RUSTEMU_LIBRARY): $(RUSTEMU_SRC)
682+
cd $(ROOT)/src/rustemu && cargo build --release
683+
684+
$(RUSTEMU_HEADER): $(RUSTEMU_LIBRARY)
685+
cd $(ROOT)/src/rustemu && cbindgen --lang c -o $(PWD)/$(RUSTEMU_HEADER)
677686

678687
# includes in test dir must override includes in user dir, unless the user
679688
# specifies a list of endorsed directories in ${target}_INCLUDE_DIRS.
680-
test_include_dirs = $1 $(TEST_DIR) $(USER_DIR)
689+
test_include_dirs = $1 $(TEST_DIR) $(USER_DIR) $(RUSTEMU_INCLUDE_DIR)
681690
test_cflags = $(addprefix -I,$(call test_include_dirs,$1))
682691

683692

@@ -748,7 +757,7 @@ $(OBJECT_DIR)/$1/%.c.o: $(TARGET_DIR)/$(call get_base_target,$(call target,$1))/
748757
-c $$< -o $$@
749758
endif
750759

751-
$(OBJECT_DIR)/$1/$(basename $1).o: $(TEST_DIR)/$(basename $1).cc
760+
$(OBJECT_DIR)/$1/$(basename $1).o: $(RUSTEMU_HEADER) $(TEST_DIR)/$(basename $1).cc
752761
@echo "compiling $$<" "$(STDOUT)"
753762
$(V1) mkdir -p $$(dir $$@)
754763
$(V1) $(CXX) $(CXX_FLAGS) $$(call test_cflags,$$($1_INCLUDE_DIRS)) \

0 commit comments

Comments
 (0)